diff options
author | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
---|---|---|
committer | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
commit | 06e5c21a835c0e923506c4ff27929f34e00761c2 (patch) | |
tree | 75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /contrib/libs/grpc | |
parent | 03f024c4412e3aa613bb543cf1660176320ba8f4 (diff) | |
download | ydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz |
fix ya.make
Diffstat (limited to 'contrib/libs/grpc')
366 files changed, 0 insertions, 57387 deletions
diff --git a/contrib/libs/grpc/.yandex_meta/devtools.copyrights.report b/contrib/libs/grpc/.yandex_meta/devtools.copyrights.report deleted file mode 100644 index 055427d972..0000000000 --- a/contrib/libs/grpc/.yandex_meta/devtools.copyrights.report +++ /dev/null @@ -1,2201 +0,0 @@ -# File format ($ symbol means the beginning of a line): -# -# $ # this message -# $ # ======================= -# $ # comments (all commentaries should starts with some number of spaces and # symbol) -# ${action} {license id} {license text hash} -# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make -# ${all_file_action} filename -# $ # user commentaries (many lines) -# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) -# ${action} {license spdx} {license text hash} -# $BELONGS ./ya/make/file/relative/path/3/ya.make -# ${all_file_action} filename -# $ # user commentaries -# $ generated description -# $ ... -# -# You can modify action, all_file_action and add commentaries -# Available actions: -# keep - keep license in contrib and use in credits -# skip - skip license -# remove - remove all files with this license -# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file -# -# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) -# We suppose that that files can contain some license info -# Available all file actions: -# FILE_IGNORE - ignore file (do nothing) -# FILE_INCLUDE - include all file data into licenses text file -# ======================= - -KEEP COPYRIGHT_SERVICE_LABEL 05bdd09fb9fdb384a61f2eb54df462d6 -BELONGS src/proto/grpc/status/ya.make - License text: - // Copyright 2016 Google Inc. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/status/status.proto [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 06745079442081a41390888905fc6bdb -BELONGS src/core/lib/ya.make src/cpp/common/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make ya.make - License text: - // Copyright 2021 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpcpp/create_channel_binder.h [1:1] - include/grpcpp/ext/admin_services.h [3:3] - include/grpcpp/security/authorization_policy_provider.h [1:1] - include/grpcpp/security/binder_credentials.h [1:1] - include/grpcpp/security/binder_security_policy.h [1:1] - include/grpcpp/security/tls_certificate_verifier.h [2:2] - include/grpcpp/test/client_context_test_peer.h [3:3] - src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc [1:1] - src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc [2:2] - src/core/ext/filters/client_channel/retry_filter.h [2:2] - src/core/ext/filters/client_idle/idle_filter_state.cc [1:1] - src/core/ext/filters/client_idle/idle_filter_state.h [1:1] - src/core/ext/filters/fault_injection/fault_injection_filter.cc [2:2] - src/core/ext/filters/fault_injection/fault_injection_filter.h [2:2] - src/core/ext/filters/fault_injection/service_config_parser.cc [2:2] - src/core/ext/filters/fault_injection/service_config_parser.h [2:2] - src/core/ext/filters/server_config_selector/server_config_selector.cc [2:2] - src/core/ext/filters/server_config_selector/server_config_selector.h [2:2] - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc [3:3] - src/core/ext/filters/server_config_selector/server_config_selector_filter.h [3:3] - src/core/ext/transport/binder/client/binder_connector.cc [1:1] - src/core/ext/transport/binder/client/binder_connector.h [1:1] - src/core/ext/transport/binder/client/channel_create.cc [1:1] - src/core/ext/transport/binder/client/channel_create_impl.cc [1:1] - src/core/ext/transport/binder/client/channel_create_impl.h [1:1] - src/core/ext/transport/binder/client/connection_id_generator.cc [1:1] - src/core/ext/transport/binder/client/connection_id_generator.h [1:1] - src/core/ext/transport/binder/client/endpoint_binder_pool.cc [1:1] - src/core/ext/transport/binder/client/endpoint_binder_pool.h [1:1] - src/core/ext/transport/binder/client/jni_utils.cc [1:1] - src/core/ext/transport/binder/client/jni_utils.h [1:1] - src/core/ext/transport/binder/client/security_policy_setting.cc [1:1] - src/core/ext/transport/binder/client/security_policy_setting.h [1:1] - src/core/ext/transport/binder/security_policy/binder_security_policy.cc [1:1] - src/core/ext/transport/binder/server/binder_server.cc [1:1] - src/core/ext/transport/binder/server/binder_server.h [1:1] - src/core/ext/transport/binder/server/binder_server_credentials.cc [1:1] - src/core/ext/transport/binder/transport/binder_stream.h [1:1] - src/core/ext/transport/binder/transport/binder_transport.cc [1:1] - src/core/ext/transport/binder/transport/binder_transport.h [1:1] - src/core/ext/transport/binder/utils/ndk_binder.cc [1:1] - src/core/ext/transport/binder/utils/ndk_binder.h [1:1] - src/core/ext/transport/binder/utils/transport_stream_receiver.h [1:1] - src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc [1:1] - src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h [1:1] - src/core/ext/transport/binder/wire_format/binder.h [1:1] - src/core/ext/transport/binder/wire_format/binder_android.cc [1:1] - src/core/ext/transport/binder/wire_format/binder_android.h [1:1] - src/core/ext/transport/binder/wire_format/binder_constants.cc [1:1] - src/core/ext/transport/binder/wire_format/binder_constants.h [1:1] - src/core/ext/transport/binder/wire_format/transaction.cc [1:1] - src/core/ext/transport/binder/wire_format/transaction.h [1:1] - src/core/ext/transport/binder/wire_format/wire_reader.h [1:1] - src/core/ext/transport/binder/wire_format/wire_reader_impl.cc [1:1] - src/core/ext/transport/binder/wire_format/wire_reader_impl.h [1:1] - src/core/ext/transport/binder/wire_format/wire_writer.cc [1:1] - src/core/ext/transport/binder/wire_format/wire_writer.h [1:1] - src/core/ext/transport/chttp2/transport/hpack_constants.h [1:1] - src/core/ext/transport/chttp2/transport/hpack_encoder_index.h [1:1] - src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc [1:1] - src/core/ext/transport/chttp2/transport/hpack_encoder_table.h [1:1] - src/core/ext/transport/chttp2/transport/hpack_utils.cc [1:1] - src/core/ext/transport/chttp2/transport/hpack_utils.h [1:1] - src/core/ext/transport/chttp2/transport/popularity_count.h [1:1] - src/core/ext/xds/xds_channel_stack_modifier.cc [3:3] - src/core/ext/xds/xds_channel_stack_modifier.h [3:3] - src/core/ext/xds/xds_http_fault_filter.cc [2:2] - src/core/ext/xds/xds_http_fault_filter.h [2:2] - src/core/ext/xds/xds_http_filters.cc [2:2] - src/core/ext/xds/xds_http_filters.h [2:2] - src/core/ext/xds/xds_routing.cc [3:3] - src/core/ext/xds/xds_routing.h [3:3] - src/core/lib/avl/avl.h [1:1] - src/core/lib/channel/call_tracer.h [3:3] - src/core/lib/channel/channel_args_preconditioning.cc [1:1] - src/core/lib/channel/channel_args_preconditioning.h [1:1] - src/core/lib/config/core_configuration.cc [1:1] - src/core/lib/config/core_configuration.h [1:1] - src/core/lib/event_engine/memory_allocator.cc [1:1] - src/core/lib/gprpp/bitset.h [1:1] - src/core/lib/gprpp/capture.h [1:1] - src/core/lib/gprpp/chunked_vector.h [1:1] - src/core/lib/gprpp/construct_destruct.h [1:1] - src/core/lib/gprpp/cpp_impl_of.h [1:1] - src/core/lib/gprpp/match.h [1:1] - src/core/lib/gprpp/overload.h [1:1] - src/core/lib/gprpp/table.h [1:1] - src/core/lib/matchers/matchers.cc [1:1] - src/core/lib/matchers/matchers.h [1:1] - src/core/lib/promise/activity.cc [1:1] - src/core/lib/promise/activity.h [1:1] - src/core/lib/promise/arena_promise.h [1:1] - src/core/lib/promise/context.h [1:1] - src/core/lib/promise/detail/basic_join.h [1:1] - src/core/lib/promise/detail/basic_seq.h [1:1] - src/core/lib/promise/detail/promise_factory.h [1:1] - src/core/lib/promise/detail/promise_like.h [1:1] - src/core/lib/promise/detail/status.h [1:1] - src/core/lib/promise/detail/switch.h [2:2] - src/core/lib/promise/exec_ctx_wakeup_scheduler.h [1:1] - src/core/lib/promise/for_each.h [1:1] - src/core/lib/promise/if.h [1:1] - src/core/lib/promise/intra_activity_waiter.h [1:1] - src/core/lib/promise/join.h [1:1] - src/core/lib/promise/latch.h [1:1] - src/core/lib/promise/loop.h [1:1] - src/core/lib/promise/map.h [1:1] - src/core/lib/promise/observable.h [1:1] - src/core/lib/promise/pipe.h [1:1] - src/core/lib/promise/poll.h [1:1] - src/core/lib/promise/promise.h [1:1] - src/core/lib/promise/race.h [1:1] - src/core/lib/promise/seq.h [1:1] - src/core/lib/promise/try_join.h [1:1] - src/core/lib/promise/try_seq.h [1:1] - src/core/lib/promise/wait_set.h [1:1] - src/core/lib/resource_quota/api.cc [1:1] - src/core/lib/resource_quota/api.h [1:1] - src/core/lib/resource_quota/memory_quota.cc [1:1] - src/core/lib/resource_quota/memory_quota.h [1:1] - src/core/lib/resource_quota/resource_quota.cc [1:1] - src/core/lib/resource_quota/resource_quota.h [1:1] - src/core/lib/resource_quota/thread_quota.cc [1:1] - src/core/lib/resource_quota/thread_quota.h [1:1] - src/core/lib/resource_quota/trace.cc [1:1] - src/core/lib/resource_quota/trace.h [1:1] - src/core/lib/security/authorization/authorization_engine.h [1:1] - src/core/lib/security/authorization/authorization_policy_provider.h [1:1] - src/core/lib/security/authorization/authorization_policy_provider_null_vtable.cc [1:1] - src/core/lib/security/authorization/authorization_policy_provider_vtable.cc [1:1] - src/core/lib/security/authorization/evaluate_args.cc [1:1] - src/core/lib/security/authorization/evaluate_args.h [1:1] - src/core/lib/security/authorization/grpc_authorization_engine.h [1:1] - src/core/lib/security/authorization/grpc_authorization_policy_provider.h [1:1] - src/core/lib/security/authorization/matchers.h [1:1] - src/core/lib/security/authorization/rbac_policy.h [1:1] - src/core/lib/security/authorization/rbac_translator.h [1:1] - src/core/lib/security/authorization/sdk_server_authz_filter.cc [1:1] - src/core/lib/security/authorization/sdk_server_authz_filter.h [1:1] - src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc [2:2] - src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h [2:2] - src/core/lib/slice/slice.h [1:1] - src/core/lib/slice/slice_refcount.cc [1:1] - src/core/lib/slice/slice_refcount.h [1:1] - src/core/lib/slice/slice_refcount_base.h [1:1] - src/core/lib/slice/slice_split.cc [1:1] - src/core/lib/surface/builtins.cc [1:1] - src/core/lib/surface/builtins.h [1:1] - src/core/lib/transport/parsed_metadata.cc [1:1] - src/core/lib/transport/parsed_metadata.h [1:1] - src/cpp/common/tls_certificate_verifier.cc [2:2] - test/core/util/build.cc [1:1] - test/core/util/build.h [1:1] - test/core/util/evaluate_args_test_util.h [1:1] - test/core/util/mock_authorization_endpoint.h [1:1] - test/cpp/end2end/admin_services_end2end_test.cc [3:3] - test/cpp/end2end/sdk_authz_end2end_test.cc [1:1] - test/cpp/util/tls_test_utils.cc [2:2] - test/cpp/util/tls_test_utils.h [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL 0e7dfde444a19e176393b344aaa268da -BELONGS ya.make - License text: - // Copyright 2016 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/reflection/v1/reflection.proto [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 0f2ee97b72f8652f2f1b888d86348121 -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/proto/grpc/testing/duplicate/ya.make src/proto/grpc/testing/ya.make src/python/grpcio/ya.make src/python/grpcio_health_checking/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make tools/codegen/core/ya.make ya.make - License text: - * Copyright 2015 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/byte_buffer.h [3:3] - include/grpc/byte_buffer_reader.h [3:3] - include/grpc/compression.h [3:3] - include/grpc/grpc_security.h [3:3] - include/grpc/impl/codegen/atm.h [3:3] - include/grpc/impl/codegen/atm_gcc_atomic.h [3:3] - include/grpc/impl/codegen/atm_gcc_sync.h [3:3] - include/grpc/impl/codegen/atm_windows.h [3:3] - include/grpc/impl/codegen/byte_buffer.h [3:3] - include/grpc/impl/codegen/byte_buffer_reader.h [3:3] - include/grpc/impl/codegen/grpc_types.h [3:3] - include/grpc/impl/codegen/log.h [3:3] - include/grpc/impl/codegen/port_platform.h [3:3] - include/grpc/impl/codegen/slice.h [3:3] - include/grpc/impl/codegen/status.h [3:3] - include/grpc/impl/codegen/sync_generic.h [3:3] - include/grpc/impl/codegen/sync_posix.h [3:3] - include/grpc/impl/codegen/sync_windows.h [3:3] - include/grpc/slice.h [3:3] - include/grpc/slice_buffer.h [3:3] - include/grpc/status.h [3:3] - include/grpc/support/alloc.h [3:3] - include/grpc/support/atm.h [3:3] - include/grpc/support/atm_gcc_atomic.h [3:3] - include/grpc/support/atm_gcc_sync.h [3:3] - include/grpc/support/atm_windows.h [3:3] - include/grpc/support/cpu.h [3:3] - include/grpc/support/log.h [3:3] - include/grpc/support/log_windows.h [3:3] - include/grpc/support/port_platform.h [3:3] - include/grpc/support/string_util.h [3:3] - include/grpc/support/sync.h [3:3] - include/grpc/support/sync_generic.h [3:3] - include/grpc/support/sync_posix.h [3:3] - include/grpc/support/sync_windows.h [3:3] - include/grpc/support/time.h [3:3] - include/grpc/support/workaround_list.h [3:3] - include/grpcpp/alarm.h [3:3] - include/grpcpp/channel.h [3:3] - include/grpcpp/client_context.h [3:3] - include/grpcpp/completion_queue.h [3:3] - include/grpcpp/create_channel.h [3:3] - include/grpcpp/ext/proto_server_reflection_plugin.h [3:3] - include/grpcpp/generic/generic_stub.h [3:3] - include/grpcpp/grpcpp.h [3:3] - include/grpcpp/impl/call.h [3:3] - include/grpcpp/impl/client_unary_call.h [3:3] - include/grpcpp/impl/codegen/async_generic_service.h [3:3] - include/grpcpp/impl/codegen/async_unary_call.h [3:3] - include/grpcpp/impl/codegen/call_hook.h [3:3] - include/grpcpp/impl/codegen/client_context.h [3:3] - include/grpcpp/impl/codegen/client_unary_call.h [3:3] - include/grpcpp/impl/codegen/completion_queue_tag.h [3:3] - include/grpcpp/impl/codegen/config_protobuf.h [3:3] - include/grpcpp/impl/codegen/core_codegen_interface.h [3:3] - include/grpcpp/impl/codegen/create_auth_context.h [3:3] - include/grpcpp/impl/codegen/metadata_map.h [3:3] - include/grpcpp/impl/codegen/method_handler.h [3:3] - include/grpcpp/impl/codegen/proto_buffer_reader.h [3:3] - include/grpcpp/impl/codegen/proto_utils.h [3:3] - include/grpcpp/impl/codegen/rpc_method.h [3:3] - include/grpcpp/impl/codegen/security/auth_context.h [3:3] - include/grpcpp/impl/codegen/serialization_traits.h [3:3] - include/grpcpp/impl/codegen/server_interface.h [3:3] - include/grpcpp/impl/codegen/service_type.h [3:3] - include/grpcpp/impl/codegen/slice.h [3:3] - include/grpcpp/impl/codegen/string_ref.h [3:3] - include/grpcpp/impl/codegen/stub_options.h [3:3] - include/grpcpp/impl/codegen/time.h [3:3] - include/grpcpp/impl/grpc_library.h [3:3] - include/grpcpp/impl/method_handler_impl.h [3:3] - include/grpcpp/impl/rpc_method.h [3:3] - include/grpcpp/impl/serialization_traits.h [3:3] - include/grpcpp/impl/server_builder_option.h [3:3] - include/grpcpp/impl/service_type.h [3:3] - include/grpcpp/security/auth_context.h [3:3] - include/grpcpp/security/auth_metadata_processor.h [3:3] - include/grpcpp/security/credentials.h [3:3] - include/grpcpp/security/server_credentials.h [3:3] - include/grpcpp/server.h [3:3] - include/grpcpp/server_context.h [3:3] - include/grpcpp/support/async_stream.h [3:3] - include/grpcpp/support/async_unary_call.h [3:3] - include/grpcpp/support/byte_buffer.h [3:3] - include/grpcpp/support/channel_arguments.h [3:3] - include/grpcpp/support/client_interceptor.h [3:3] - include/grpcpp/support/config.h [3:3] - include/grpcpp/support/interceptor.h [3:3] - include/grpcpp/support/method_handler.h [3:3] - include/grpcpp/support/server_interceptor.h [3:3] - include/grpcpp/support/slice.h [3:3] - include/grpcpp/support/status.h [3:3] - include/grpcpp/support/status_code_enum.h [3:3] - include/grpcpp/support/string_ref.h [3:3] - include/grpcpp/support/stub_options.h [3:3] - include/grpcpp/support/sync_stream.h [3:3] - include/grpcpp/support/time.h [3:3] - src/compiler/config.h [3:3] - src/compiler/cpp_generator.cc [3:3] - src/compiler/cpp_generator.h [3:3] - src/compiler/cpp_generator_helpers.h [3:3] - src/compiler/cpp_plugin.cc [3:3] - src/compiler/csharp_generator.cc [3:3] - src/compiler/csharp_generator.h [3:3] - src/compiler/csharp_generator_helpers.h [3:3] - src/compiler/generator_helpers.h [3:3] - src/compiler/objective_c_generator.cc [3:3] - src/compiler/objective_c_generator.h [3:3] - src/compiler/objective_c_generator_helpers.h [3:3] - src/compiler/protobuf_plugin.h [3:3] - src/compiler/python_generator.cc [3:3] - src/compiler/python_generator.h [3:3] - src/compiler/python_generator_helpers.h [3:3] - src/compiler/python_plugin.cc [3:3] - src/compiler/python_private_generator.h [3:3] - src/compiler/ruby_generator.cc [3:3] - src/compiler/ruby_generator.h [3:3] - src/compiler/ruby_generator_helpers-inl.h [3:3] - src/compiler/ruby_generator_map-inl.h [3:3] - src/compiler/ruby_generator_string-inl.h [3:3] - src/compiler/schema_interface.h [3:3] - src/core/ext/filters/census/grpc_context.cc [3:3] - src/core/ext/filters/client_channel/channel_connectivity.cc [2:2] - src/core/ext/filters/client_channel/client_channel.cc [2:2] - src/core/ext/filters/client_channel/client_channel.h [2:2] - src/core/ext/filters/client_channel/client_channel_factory.cc [3:3] - src/core/ext/filters/client_channel/client_channel_factory.h [2:2] - src/core/ext/filters/client_channel/client_channel_plugin.cc [3:3] - src/core/ext/filters/client_channel/connector.h [2:2] - src/core/ext/filters/client_channel/lb_policy.cc [3:3] - src/core/ext/filters/client_channel/lb_policy.h [2:2] - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h [3:3] - src/core/ext/filters/client_channel/lb_policy_factory.h [3:3] - src/core/ext/filters/client_channel/lb_policy_registry.cc [3:3] - src/core/ext/filters/client_channel/lb_policy_registry.h [3:3] - src/core/ext/filters/client_channel/resolver.cc [3:3] - src/core/ext/filters/client_channel/resolver.h [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc [3:3] - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc [3:3] - src/core/ext/filters/client_channel/resolver_factory.h [3:3] - src/core/ext/filters/client_channel/resolver_registry.cc [3:3] - src/core/ext/filters/client_channel/resolver_registry.h [3:3] - src/core/ext/filters/client_channel/retry_filter.cc [2:2] - src/core/ext/filters/client_channel/subchannel.cc [2:2] - src/core/ext/filters/client_channel/subchannel.h [2:2] - src/core/ext/filters/http/client/http_client_filter.cc [2:2] - src/core/ext/filters/http/client/http_client_filter.h [2:2] - src/core/ext/filters/http/message_compress/message_compress_filter.cc [3:3] - src/core/ext/filters/http/message_compress/message_compress_filter.h [3:3] - src/core/ext/filters/http/server/http_server_filter.cc [3:3] - src/core/ext/filters/http/server/http_server_filter.h [3:3] - src/core/ext/service_config/service_config.cc [2:2] - src/core/ext/service_config/service_config_parser.cc [2:2] - src/core/ext/transport/chttp2/alpn/alpn.cc [3:3] - src/core/ext/transport/chttp2/alpn/alpn.h [3:3] - src/core/ext/transport/chttp2/client/chttp2_connector.cc [3:3] - src/core/ext/transport/chttp2/client/chttp2_connector.h [3:3] - src/core/ext/transport/chttp2/client/insecure/channel_create.cc [2:2] - src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc [2:2] - src/core/ext/transport/chttp2/server/chttp2_server.cc [3:3] - src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc [3:3] - src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc [3:3] - src/core/ext/transport/chttp2/transport/bin_encoder.cc [3:3] - src/core/ext/transport/chttp2/transport/bin_encoder.h [3:3] - src/core/ext/transport/chttp2/transport/chttp2_plugin.cc [3:3] - src/core/ext/transport/chttp2/transport/chttp2_transport.h [3:3] - src/core/ext/transport/chttp2/transport/frame.h [3:3] - src/core/ext/transport/chttp2/transport/frame_data.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_data.h [3:3] - src/core/ext/transport/chttp2/transport/frame_goaway.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_goaway.h [3:3] - src/core/ext/transport/chttp2/transport/frame_ping.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_ping.h [3:3] - src/core/ext/transport/chttp2/transport/frame_rst_stream.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_rst_stream.h [3:3] - src/core/ext/transport/chttp2/transport/frame_settings.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_settings.h [3:3] - src/core/ext/transport/chttp2/transport/frame_window_update.cc [3:3] - src/core/ext/transport/chttp2/transport/frame_window_update.h [3:3] - src/core/ext/transport/chttp2/transport/hpack_encoder.cc [3:3] - src/core/ext/transport/chttp2/transport/hpack_encoder.h [3:3] - src/core/ext/transport/chttp2/transport/hpack_parser.cc [3:3] - src/core/ext/transport/chttp2/transport/hpack_parser.h [3:3] - src/core/ext/transport/chttp2/transport/hpack_parser_table.cc [3:3] - src/core/ext/transport/chttp2/transport/hpack_parser_table.h [3:3] - src/core/ext/transport/chttp2/transport/huffsyms.cc [3:3] - src/core/ext/transport/chttp2/transport/huffsyms.h [3:3] - src/core/ext/transport/chttp2/transport/internal.h [3:3] - src/core/ext/transport/chttp2/transport/parsing.cc [3:3] - src/core/ext/transport/chttp2/transport/stream_lists.cc [3:3] - src/core/ext/transport/chttp2/transport/stream_map.cc [3:3] - src/core/ext/transport/chttp2/transport/stream_map.h [3:3] - src/core/ext/transport/chttp2/transport/varint.cc [3:3] - src/core/ext/transport/chttp2/transport/varint.h [3:3] - src/core/ext/transport/chttp2/transport/writing.cc [3:3] - src/core/lib/address_utils/parse_address.h [3:3] - src/core/lib/address_utils/sockaddr_utils.h [3:3] - src/core/lib/channel/channel_args.cc [3:3] - src/core/lib/channel/channel_args.h [3:3] - src/core/lib/channel/channel_stack.cc [3:3] - src/core/lib/channel/channel_stack.h [3:3] - src/core/lib/channel/connected_channel.cc [3:3] - src/core/lib/channel/connected_channel.h [3:3] - src/core/lib/channel/context.h [3:3] - src/core/lib/compression/algorithm_metadata.h [3:3] - src/core/lib/compression/compression.cc [3:3] - src/core/lib/compression/compression_args.cc [3:3] - src/core/lib/compression/compression_args.h [3:3] - src/core/lib/compression/compression_internal.cc [3:3] - src/core/lib/compression/message_compress.cc [3:3] - src/core/lib/compression/message_compress.h [3:3] - src/core/lib/debug/trace.cc [3:3] - src/core/lib/debug/trace.h [3:3] - src/core/lib/gpr/alloc.cc [3:3] - src/core/lib/gpr/cpu_iphone.cc [3:3] - src/core/lib/gpr/cpu_linux.cc [3:3] - src/core/lib/gpr/cpu_posix.cc [3:3] - src/core/lib/gpr/cpu_windows.cc [3:3] - src/core/lib/gpr/env.h [3:3] - src/core/lib/gpr/env_linux.cc [3:3] - src/core/lib/gpr/env_posix.cc [3:3] - src/core/lib/gpr/env_windows.cc [3:3] - src/core/lib/gpr/log.cc [3:3] - src/core/lib/gpr/log_android.cc [3:3] - src/core/lib/gpr/log_linux.cc [3:3] - src/core/lib/gpr/log_posix.cc [3:3] - src/core/lib/gpr/log_windows.cc [3:3] - src/core/lib/gpr/murmur_hash.cc [3:3] - src/core/lib/gpr/murmur_hash.h [3:3] - src/core/lib/gpr/spinlock.h [3:3] - src/core/lib/gpr/string.cc [3:3] - src/core/lib/gpr/string.h [3:3] - src/core/lib/gpr/string_posix.cc [3:3] - src/core/lib/gpr/string_windows.cc [3:3] - src/core/lib/gpr/string_windows.h [3:3] - src/core/lib/gpr/sync.cc [3:3] - src/core/lib/gpr/sync_posix.cc [3:3] - src/core/lib/gpr/sync_windows.cc [3:3] - src/core/lib/gpr/time.cc [3:3] - src/core/lib/gpr/time_posix.cc [3:3] - src/core/lib/gpr/time_precise.cc [3:3] - src/core/lib/gpr/time_precise.h [3:3] - src/core/lib/gpr/time_windows.cc [3:3] - src/core/lib/gpr/tls.h [3:3] - src/core/lib/gpr/tmpfile.h [3:3] - src/core/lib/gpr/tmpfile_msys.cc [3:3] - src/core/lib/gpr/tmpfile_posix.cc [3:3] - src/core/lib/gpr/tmpfile_windows.cc [3:3] - src/core/lib/gpr/useful.h [3:3] - src/core/lib/gprpp/host_port.cc [3:3] - src/core/lib/gprpp/host_port.h [3:3] - src/core/lib/gprpp/thd.h [3:3] - src/core/lib/gprpp/thd_posix.cc [3:3] - src/core/lib/gprpp/thd_windows.cc [3:3] - src/core/lib/http/format_request.cc [3:3] - src/core/lib/http/format_request.h [3:3] - src/core/lib/http/httpcli.cc [3:3] - src/core/lib/http/httpcli.h [3:3] - src/core/lib/http/httpcli_security_connector.cc [3:3] - src/core/lib/http/parser.cc [3:3] - src/core/lib/http/parser.h [3:3] - src/core/lib/iomgr/block_annotate.h [3:3] - src/core/lib/iomgr/closure.h [3:3] - src/core/lib/iomgr/endpoint.cc [3:3] - src/core/lib/iomgr/endpoint.h [3:3] - src/core/lib/iomgr/endpoint_pair.h [3:3] - src/core/lib/iomgr/endpoint_pair_windows.cc [3:3] - src/core/lib/iomgr/ev_epollex_linux.h [3:3] - src/core/lib/iomgr/ev_posix.cc [3:3] - src/core/lib/iomgr/ev_posix.h [3:3] - src/core/lib/iomgr/ev_windows.cc [3:3] - src/core/lib/iomgr/exec_ctx.cc [3:3] - src/core/lib/iomgr/exec_ctx.h [3:3] - src/core/lib/iomgr/executor.cc [3:3] - src/core/lib/iomgr/executor.h [3:3] - src/core/lib/iomgr/grpc_if_nametoindex.h [3:3] - src/core/lib/iomgr/iocp_windows.cc [3:3] - src/core/lib/iomgr/iocp_windows.h [3:3] - src/core/lib/iomgr/iomgr.cc [3:3] - src/core/lib/iomgr/iomgr.h [3:3] - src/core/lib/iomgr/iomgr_internal.h [3:3] - src/core/lib/iomgr/iomgr_posix.cc [3:3] - src/core/lib/iomgr/iomgr_posix_cfstream.cc [3:3] - src/core/lib/iomgr/iomgr_windows.cc [3:3] - src/core/lib/iomgr/is_epollexclusive_available.h [3:3] - src/core/lib/iomgr/load_file.cc [3:3] - src/core/lib/iomgr/load_file.h [3:3] - src/core/lib/iomgr/polling_entity.h [3:3] - src/core/lib/iomgr/pollset.h [3:3] - src/core/lib/iomgr/pollset_set.h [3:3] - src/core/lib/iomgr/pollset_set_windows.cc [3:3] - src/core/lib/iomgr/pollset_set_windows.h [3:3] - src/core/lib/iomgr/pollset_windows.cc [3:3] - src/core/lib/iomgr/pollset_windows.h [3:3] - src/core/lib/iomgr/resolve_address.h [3:3] - src/core/lib/iomgr/resolve_address_posix.cc [3:3] - src/core/lib/iomgr/resolve_address_windows.cc [3:3] - src/core/lib/iomgr/sockaddr.h [3:3] - src/core/lib/iomgr/sockaddr_posix.h [3:3] - src/core/lib/iomgr/sockaddr_windows.h [3:3] - src/core/lib/iomgr/socket_mutator.cc [3:3] - src/core/lib/iomgr/socket_mutator.h [3:3] - src/core/lib/iomgr/socket_utils.h [3:3] - src/core/lib/iomgr/socket_utils_common_posix.cc [3:3] - src/core/lib/iomgr/socket_utils_linux.cc [3:3] - src/core/lib/iomgr/socket_utils_posix.cc [3:3] - src/core/lib/iomgr/socket_utils_posix.h [3:3] - src/core/lib/iomgr/socket_windows.cc [3:3] - src/core/lib/iomgr/socket_windows.h [3:3] - src/core/lib/iomgr/tcp_client.h [3:3] - src/core/lib/iomgr/tcp_client_posix.cc [3:3] - src/core/lib/iomgr/tcp_client_posix.h [3:3] - src/core/lib/iomgr/tcp_client_windows.cc [3:3] - src/core/lib/iomgr/tcp_posix.cc [3:3] - src/core/lib/iomgr/tcp_posix.h [3:3] - src/core/lib/iomgr/tcp_server.h [3:3] - src/core/lib/iomgr/tcp_server_posix.cc [3:3] - src/core/lib/iomgr/tcp_server_windows.cc [3:3] - src/core/lib/iomgr/tcp_windows.cc [3:3] - src/core/lib/iomgr/tcp_windows.h [3:3] - src/core/lib/iomgr/time_averaged_stats.cc [3:3] - src/core/lib/iomgr/time_averaged_stats.h [3:3] - src/core/lib/iomgr/timer.h [3:3] - src/core/lib/iomgr/timer_generic.cc [3:3] - src/core/lib/iomgr/timer_heap.cc [3:3] - src/core/lib/iomgr/timer_heap.h [3:3] - src/core/lib/iomgr/wakeup_fd_eventfd.cc [3:3] - src/core/lib/iomgr/wakeup_fd_nospecial.cc [3:3] - src/core/lib/iomgr/wakeup_fd_pipe.cc [3:3] - src/core/lib/iomgr/wakeup_fd_pipe.h [3:3] - src/core/lib/iomgr/wakeup_fd_posix.cc [3:3] - src/core/lib/iomgr/wakeup_fd_posix.h [3:3] - src/core/lib/json/json.h [3:3] - src/core/lib/json/json_writer.cc [3:3] - src/core/lib/profiling/basic_timers.cc [3:3] - src/core/lib/profiling/stap_timers.cc [3:3] - src/core/lib/profiling/timers.h [3:3] - src/core/lib/security/context/security_context.cc [3:3] - src/core/lib/security/context/security_context.h [3:3] - src/core/lib/security/credentials/composite/composite_credentials.h [3:3] - src/core/lib/security/credentials/credentials.cc [3:3] - src/core/lib/security/credentials/credentials.h [3:3] - src/core/lib/security/credentials/credentials_metadata.cc [3:3] - src/core/lib/security/credentials/google_default/google_default_credentials.cc [3:3] - src/core/lib/security/credentials/jwt/json_token.cc [3:3] - src/core/lib/security/credentials/jwt/json_token.h [3:3] - src/core/lib/security/credentials/jwt/jwt_verifier.cc [3:3] - src/core/lib/security/credentials/jwt/jwt_verifier.h [3:3] - src/core/lib/security/credentials/oauth2/oauth2_credentials.cc [3:3] - src/core/lib/security/security_connector/security_connector.cc [3:3] - src/core/lib/security/security_connector/security_connector.h [3:3] - src/core/lib/security/security_connector/ssl_utils.cc [3:3] - src/core/lib/security/security_connector/ssl_utils.h [3:3] - src/core/lib/security/transport/auth_filters.h [3:3] - src/core/lib/security/transport/client_auth_filter.cc [3:3] - src/core/lib/security/transport/secure_endpoint.cc [3:3] - src/core/lib/security/transport/secure_endpoint.h [3:3] - src/core/lib/security/transport/security_handshaker.cc [3:3] - src/core/lib/security/transport/security_handshaker.h [3:3] - src/core/lib/security/transport/server_auth_filter.cc [3:3] - src/core/lib/security/transport/tsi_error.cc [3:3] - src/core/lib/security/transport/tsi_error.h [3:3] - src/core/lib/security/util/json_util.cc [3:3] - src/core/lib/security/util/json_util.h [3:3] - src/core/lib/slice/b64.cc [3:3] - src/core/lib/slice/b64.h [3:3] - src/core/lib/slice/slice.cc [3:3] - src/core/lib/slice/slice_api.cc [3:3] - src/core/lib/slice/slice_buffer.cc [3:3] - src/core/lib/slice/slice_split.h [3:3] - src/core/lib/slice/slice_string_helpers.cc [3:3] - src/core/lib/slice/slice_string_helpers.h [3:3] - src/core/lib/slice/static_slice.cc [2:2] - src/core/lib/slice/static_slice.h [2:2] - src/core/lib/surface/api_trace.cc [3:3] - src/core/lib/surface/api_trace.h [3:3] - src/core/lib/surface/byte_buffer.cc [3:3] - src/core/lib/surface/byte_buffer_reader.cc [3:3] - src/core/lib/surface/call.cc [3:3] - src/core/lib/surface/call.h [3:3] - src/core/lib/surface/call_details.cc [3:3] - src/core/lib/surface/call_log_batch.cc [3:3] - src/core/lib/surface/call_test_only.h [3:3] - src/core/lib/surface/channel.cc [3:3] - src/core/lib/surface/channel.h [3:3] - src/core/lib/surface/channel_ping.cc [3:3] - src/core/lib/surface/channel_stack_type.h [3:3] - src/core/lib/surface/event_string.cc [3:3] - src/core/lib/surface/event_string.h [3:3] - src/core/lib/surface/init.cc [3:3] - src/core/lib/surface/init.h [3:3] - src/core/lib/surface/init_secure.cc [3:3] - src/core/lib/surface/init_unsecure.cc [3:3] - src/core/lib/surface/lame_client.cc [3:3] - src/core/lib/surface/metadata_array.cc [3:3] - src/core/lib/surface/server.h [2:2] - src/core/lib/surface/version.cc [3:3] - src/core/lib/transport/byte_stream.cc [3:3] - src/core/lib/transport/byte_stream.h [3:3] - src/core/lib/transport/connectivity_state.cc [3:3] - src/core/lib/transport/connectivity_state.h [3:3] - src/core/lib/transport/http2_errors.h [3:3] - src/core/lib/transport/metadata.cc [3:3] - src/core/lib/transport/metadata.h [3:3] - src/core/lib/transport/metadata_batch.cc [3:3] - src/core/lib/transport/metadata_batch.h [3:3] - src/core/lib/transport/static_metadata.cc [2:2] - src/core/lib/transport/static_metadata.h [2:2] - src/core/lib/transport/status_conversion.cc [3:3] - src/core/lib/transport/status_conversion.h [3:3] - src/core/lib/transport/timeout_encoding.cc [3:3] - src/core/lib/transport/timeout_encoding.h [3:3] - src/core/lib/transport/transport.cc [3:3] - src/core/lib/transport/transport.h [3:3] - src/core/lib/transport/transport_impl.h [3:3] - src/core/lib/transport/transport_op_string.cc [3:3] - src/core/lib/uri/uri_parser.cc [3:3] - src/core/lib/uri/uri_parser.h [3:3] - src/core/tsi/fake_transport_security.cc [3:3] - src/core/tsi/fake_transport_security.h [3:3] - src/core/tsi/ssl_transport_security.cc [3:3] - src/core/tsi/ssl_transport_security.h [3:3] - src/core/tsi/ssl_types.h [3:3] - src/core/tsi/transport_security.cc [3:3] - src/core/tsi/transport_security.h [3:3] - src/core/tsi/transport_security_interface.h [3:3] - src/cpp/client/channel_cc.cc [3:3] - src/cpp/client/client_context.cc [3:3] - src/cpp/client/create_channel.cc [3:3] - src/cpp/client/create_channel_internal.cc [3:3] - src/cpp/client/create_channel_internal.h [3:3] - src/cpp/client/credentials_cc.cc [3:3] - src/cpp/client/insecure_credentials.cc [3:3] - src/cpp/client/secure_credentials.cc [3:3] - src/cpp/client/secure_credentials.h [3:3] - src/cpp/common/auth_property_iterator.cc [3:3] - src/cpp/common/channel_arguments.cc [3:3] - src/cpp/common/completion_queue_cc.cc [2:2] - src/cpp/common/insecure_create_auth_context.cc [3:3] - src/cpp/common/rpc_method.cc [3:3] - src/cpp/common/secure_auth_context.cc [3:3] - src/cpp/common/secure_auth_context.h [3:3] - src/cpp/common/secure_channel_arguments.cc [3:3] - src/cpp/common/secure_create_auth_context.cc [3:3] - src/cpp/ext/proto_server_reflection.h [3:3] - src/cpp/ext/proto_server_reflection_plugin.cc [3:3] - src/cpp/server/async_generic_service.cc [3:3] - src/cpp/server/create_default_thread_pool.cc [3:3] - src/cpp/server/dynamic_thread_pool.cc [3:3] - src/cpp/server/dynamic_thread_pool.h [3:3] - src/cpp/server/insecure_server_credentials.cc [3:3] - src/cpp/server/secure_server_credentials.cc [3:3] - src/cpp/server/secure_server_credentials.h [3:3] - src/cpp/server/server_cc.cc [2:2] - src/cpp/server/server_context.cc [3:3] - src/cpp/server/server_credentials.cc [3:3] - src/cpp/server/thread_pool_interface.h [3:3] - src/cpp/util/byte_buffer_cc.cc [3:3] - src/cpp/util/status.cc [3:3] - src/cpp/util/string_ref.cc [3:3] - src/cpp/util/time_cc.cc [3:3] - src/proto/grpc/testing/benchmark_service.proto [1:1] - src/proto/grpc/testing/control.proto [1:1] - src/proto/grpc/testing/duplicate/echo_duplicate.proto [2:2] - src/proto/grpc/testing/echo.proto [2:2] - src/proto/grpc/testing/echo_messages.proto [2:2] - src/proto/grpc/testing/empty.proto [2:2] - src/proto/grpc/testing/payloads.proto [1:1] - src/proto/grpc/testing/report_qps_scenario_service.proto [1:1] - src/proto/grpc/testing/stats.proto [1:1] - src/proto/grpc/testing/worker_service.proto [1:1] - src/proto/math/math.proto [2:2] - src/python/grpcio/commands.py [1:1] - src/python/grpcio/grpc/_cython/__init__.py [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/__init__.py [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/cygrpc.pxd [1:1] - src/python/grpcio/grpc/_cython/cygrpc.pyx [1:1] - src/python/grpcio/grpc/_plugin_wrapping.py [1:1] - src/python/grpcio/grpc/_utilities.py [1:1] - src/python/grpcio/grpc/beta/__init__.py [1:1] - src/python/grpcio/grpc/beta/interfaces.py [1:1] - src/python/grpcio/grpc/beta/utilities.py [1:1] - src/python/grpcio/grpc/framework/__init__.py [1:1] - src/python/grpcio/grpc/framework/common/__init__.py [1:1] - src/python/grpcio/grpc/framework/common/cardinality.py [1:1] - src/python/grpcio/grpc/framework/common/style.py [1:1] - src/python/grpcio/grpc/framework/foundation/__init__.py [1:1] - src/python/grpcio/grpc/framework/foundation/abandonment.py [1:1] - src/python/grpcio/grpc/framework/foundation/callable_util.py [1:1] - src/python/grpcio/grpc/framework/foundation/future.py [1:1] - src/python/grpcio/grpc/framework/foundation/logging_pool.py [1:1] - src/python/grpcio/grpc/framework/foundation/stream.py [1:1] - src/python/grpcio/grpc/framework/foundation/stream_util.py [1:1] - src/python/grpcio/grpc/framework/interfaces/__init__.py [1:1] - src/python/grpcio/grpc/framework/interfaces/base/__init__.py [1:1] - src/python/grpcio/grpc/framework/interfaces/base/base.py [1:1] - src/python/grpcio/grpc/framework/interfaces/base/utilities.py [1:1] - src/python/grpcio/grpc/framework/interfaces/face/__init__.py [1:1] - src/python/grpcio/grpc/framework/interfaces/face/face.py [1:1] - src/python/grpcio/grpc/framework/interfaces/face/utilities.py [1:1] - src/python/grpcio/grpc_core_dependencies.py [1:1] - src/python/grpcio/grpc_version.py [1:1] - src/python/grpcio_health_checking/grpc_health/__init__.py [1:1] - src/python/grpcio_health_checking/grpc_health/v1/__init__.py [1:1] - src/python/grpcio_health_checking/grpc_health/v1/health.py [1:1] - src/python/grpcio_health_checking/health_commands.py [1:1] - src/python/grpcio_health_checking/setup.py [1:1] - src/python/grpcio_tests/commands.py [1:1] - src/python/grpcio_tests/setup.py [1:1] - src/python/grpcio_tests/tests/__init__.py [1:1] - src/python/grpcio_tests/tests/_loader.py [1:1] - src/python/grpcio_tests/tests/_result.py [1:1] - src/python/grpcio_tests/tests/_runner.py [1:1] - src/python/grpcio_tests/tests/interop/__init__.py [1:1] - src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py [1:1] - src/python/grpcio_tests/tests/interop/_intraop_test_case.py [1:1] - src/python/grpcio_tests/tests/interop/_secure_intraop_test.py [1:1] - src/python/grpcio_tests/tests/interop/client.py [1:1] - src/python/grpcio_tests/tests/interop/methods.py [1:1] - src/python/grpcio_tests/tests/interop/resources.py [1:1] - src/python/grpcio_tests/tests/interop/server.py [1:1] - src/python/grpcio_tests/tests/unit/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py [1:1] - src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/test_utilities.py [1:1] - src/python/grpcio_tests/tests/unit/beta/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py [1:1] - src/python/grpcio_tests/tests/unit/beta/_connectivity_channel_test.py [1:1] - src/python/grpcio_tests/tests/unit/beta/_not_found_test.py [1:1] - src/python/grpcio_tests/tests/unit/beta/_utilities_test.py [1:1] - src/python/grpcio_tests/tests/unit/beta/test_utilities.py [1:1] - src/python/grpcio_tests/tests/unit/framework/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/framework/common/test_constants.py [1:1] - src/python/grpcio_tests/tests/unit/framework/common/test_control.py [1:1] - src/python/grpcio_tests/tests/unit/framework/common/test_coverage.py [1:1] - src/python/grpcio_tests/tests/unit/framework/foundation/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/framework/foundation/_logging_pool_test.py [1:1] - src/python/grpcio_tests/tests/unit/framework/foundation/stream_testing.py [1:1] - src/python/grpcio_tests/tests/unit/resources.py [1:1] - src/python/grpcio_tests/tests/unit/test_common.py [1:1] - test/core/util/cmdline.cc [3:3] - test/core/util/cmdline.h [3:3] - test/core/util/cmdline_test.cc [3:3] - test/core/util/grpc_profiler.cc [3:3] - test/core/util/grpc_profiler.h [3:3] - test/core/util/histogram.cc [3:3] - test/core/util/histogram.h [3:3] - test/core/util/histogram_test.cc [3:3] - test/core/util/parse_hexstring.cc [3:3] - test/core/util/parse_hexstring.h [3:3] - test/core/util/port.cc [3:3] - test/core/util/port.h [3:3] - test/core/util/port_server_client.cc [3:3] - test/core/util/port_server_client.h [3:3] - test/core/util/reconnect_server.cc [3:3] - test/core/util/slice_splitter.cc [3:3] - test/core/util/slice_splitter.h [3:3] - test/core/util/subprocess.h [3:3] - test/core/util/subprocess_posix.cc [3:3] - test/core/util/test_config.cc [3:3] - test/core/util/test_config.h [3:3] - test/core/util/test_tcp_server.cc [3:3] - test/core/util/test_tcp_server.h [3:3] - test/core/util/tracer_util.cc [3:3] - test/core/util/tracer_util.h [3:3] - test/cpp/end2end/async_end2end_test.cc [3:3] - test/cpp/end2end/client_crash_test.cc [3:3] - test/cpp/end2end/client_crash_test_server.cc [3:3] - test/cpp/end2end/end2end_test.cc [3:3] - test/cpp/end2end/generic_end2end_test.cc [3:3] - test/cpp/end2end/mock_test.cc [3:3] - test/cpp/end2end/raw_end2end_test.cc [3:3] - test/cpp/end2end/server_crash_test.cc [3:3] - test/cpp/end2end/server_crash_test_client.cc [3:3] - test/cpp/end2end/shutdown_test.cc [3:3] - test/cpp/end2end/streaming_throughput_test.cc [3:3] - test/cpp/end2end/thread_stress_test.cc [3:3] - test/cpp/util/byte_buffer_test.cc [3:3] - test/cpp/util/channelz_sampler.cc [3:3] - test/cpp/util/cli_call.cc [3:3] - test/cpp/util/cli_call.h [3:3] - test/cpp/util/cli_call_test.cc [3:3] - test/cpp/util/grpc_cli.cc [3:3] - test/cpp/util/metrics_server.cc [3:3] - test/cpp/util/metrics_server.h [3:3] - test/cpp/util/slice_test.cc [3:3] - test/cpp/util/string_ref_helper.cc [3:3] - test/cpp/util/string_ref_helper.h [3:3] - test/cpp/util/string_ref_test.cc [3:3] - test/cpp/util/subprocess.cc [3:3] - test/cpp/util/subprocess.h [3:3] - test/cpp/util/test_config.h [3:3] - test/cpp/util/test_config_cc.cc [3:3] - test/cpp/util/time_test.cc [3:3] - tools/codegen/core/gen_hpack_tables.cc [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL 1393ed0d9a5e8e3a97f2447521ecb0a6 -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/proto/grpc/testing/ya.make src/python/grpcio/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make ya.make - License text: - * Copyright 2018 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc++/alarm.h [3:3] - include/grpc++/channel.h [3:3] - include/grpc++/client_context.h [3:3] - include/grpc++/completion_queue.h [3:3] - include/grpc++/create_channel.h [3:3] - include/grpc++/create_channel_posix.h [3:3] - include/grpc++/ext/health_check_service_server_builder_option.h [3:3] - include/grpc++/ext/proto_server_reflection_plugin.h [3:3] - include/grpc++/generic/async_generic_service.h [3:3] - include/grpc++/generic/generic_stub.h [3:3] - include/grpc++/grpc++.h [3:3] - include/grpc++/health_check_service_interface.h [3:3] - include/grpc++/impl/call.h [3:3] - include/grpc++/impl/channel_argument_option.h [3:3] - include/grpc++/impl/client_unary_call.h [3:3] - include/grpc++/impl/codegen/async_stream.h [3:3] - include/grpc++/impl/codegen/async_unary_call.h [3:3] - include/grpc++/impl/codegen/byte_buffer.h [3:3] - include/grpc++/impl/codegen/call.h [3:3] - include/grpc++/impl/codegen/call_hook.h [3:3] - include/grpc++/impl/codegen/channel_interface.h [3:3] - include/grpc++/impl/codegen/client_context.h [3:3] - include/grpc++/impl/codegen/client_unary_call.h [3:3] - include/grpc++/impl/codegen/completion_queue.h [3:3] - include/grpc++/impl/codegen/completion_queue_tag.h [3:3] - include/grpc++/impl/codegen/config.h [3:3] - include/grpc++/impl/codegen/config_protobuf.h [3:3] - include/grpc++/impl/codegen/core_codegen.h [3:3] - include/grpc++/impl/codegen/core_codegen_interface.h [3:3] - include/grpc++/impl/codegen/create_auth_context.h [3:3] - include/grpc++/impl/codegen/grpc_library.h [3:3] - include/grpc++/impl/codegen/metadata_map.h [3:3] - include/grpc++/impl/codegen/method_handler_impl.h [3:3] - include/grpc++/impl/codegen/proto_utils.h [3:3] - include/grpc++/impl/codegen/rpc_method.h [3:3] - include/grpc++/impl/codegen/rpc_service_method.h [3:3] - include/grpc++/impl/codegen/security/auth_context.h [3:3] - include/grpc++/impl/codegen/serialization_traits.h [3:3] - include/grpc++/impl/codegen/server_context.h [3:3] - include/grpc++/impl/codegen/server_interface.h [3:3] - include/grpc++/impl/codegen/service_type.h [3:3] - include/grpc++/impl/codegen/slice.h [3:3] - include/grpc++/impl/codegen/status.h [3:3] - include/grpc++/impl/codegen/status_code_enum.h [3:3] - include/grpc++/impl/codegen/string_ref.h [3:3] - include/grpc++/impl/codegen/stub_options.h [3:3] - include/grpc++/impl/codegen/sync_stream.h [3:3] - include/grpc++/impl/codegen/time.h [3:3] - include/grpc++/impl/grpc_library.h [3:3] - include/grpc++/impl/method_handler_impl.h [3:3] - include/grpc++/impl/rpc_method.h [3:3] - include/grpc++/impl/rpc_service_method.h [3:3] - include/grpc++/impl/serialization_traits.h [3:3] - include/grpc++/impl/server_builder_option.h [3:3] - include/grpc++/impl/server_builder_plugin.h [3:3] - include/grpc++/impl/server_initializer.h [3:3] - include/grpc++/impl/service_type.h [3:3] - include/grpc++/resource_quota.h [3:3] - include/grpc++/security/auth_context.h [3:3] - include/grpc++/security/auth_metadata_processor.h [3:3] - include/grpc++/security/credentials.h [3:3] - include/grpc++/security/server_credentials.h [3:3] - include/grpc++/server.h [3:3] - include/grpc++/server_builder.h [3:3] - include/grpc++/server_context.h [3:3] - include/grpc++/server_posix.h [3:3] - include/grpc++/support/async_stream.h [3:3] - include/grpc++/support/async_unary_call.h [3:3] - include/grpc++/support/byte_buffer.h [3:3] - include/grpc++/support/channel_arguments.h [3:3] - include/grpc++/support/config.h [3:3] - include/grpc++/support/error_details.h [3:3] - include/grpc++/support/slice.h [3:3] - include/grpc++/support/status.h [3:3] - include/grpc++/support/status_code_enum.h [3:3] - include/grpc++/support/string_ref.h [3:3] - include/grpc++/support/stub_options.h [3:3] - include/grpc++/support/sync_stream.h [3:3] - include/grpc++/support/time.h [3:3] - include/grpc++/test/mock_stream.h [3:3] - include/grpc++/test/server_context_test_spouse.h [3:3] - include/grpc/support/thd_id.h [3:3] - include/grpcpp/ext/channelz_service_plugin.h [3:3] - include/grpcpp/ext/server_load_reporting.h [3:3] - include/grpcpp/generic/async_generic_service.h [3:3] - include/grpcpp/impl/codegen/call.h [3:3] - include/grpcpp/impl/codegen/call_op_set.h [3:3] - include/grpcpp/impl/codegen/call_op_set_interface.h [3:3] - include/grpcpp/impl/codegen/callback_common.h [3:3] - include/grpcpp/impl/codegen/client_interceptor.h [3:3] - include/grpcpp/impl/codegen/intercepted_channel.h [3:3] - include/grpcpp/impl/codegen/interceptor.h [3:3] - include/grpcpp/impl/codegen/interceptor_common.h [3:3] - include/grpcpp/impl/codegen/method_handler_impl.h [3:3] - include/grpcpp/impl/codegen/proto_buffer_writer.h [3:3] - include/grpcpp/impl/codegen/server_interceptor.h [3:3] - include/grpcpp/support/client_callback.h [3:3] - include/grpcpp/support/proto_buffer_reader.h [3:3] - include/grpcpp/support/proto_buffer_writer.h [3:3] - include/grpcpp/support/server_callback.h [3:3] - src/core/ext/filters/client_channel/client_channel_channelz.cc [3:3] - src/core/ext/filters/client_channel/client_channel_channelz.h [3:3] - src/core/ext/filters/client_channel/global_subchannel_pool.cc [3:3] - src/core/ext/filters/client_channel/global_subchannel_pool.h [3:3] - src/core/ext/filters/client_channel/health/health_check_client.cc [3:3] - src/core/ext/filters/client_channel/health/health_check_client.h [3:3] - src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h [2:2] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h [3:3] - src/core/ext/filters/client_channel/lb_policy/priority/priority.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h [2:2] - src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/xds.h [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc [2:2] - src/core/ext/filters/client_channel/local_subchannel_pool.cc [3:3] - src/core/ext/filters/client_channel/local_subchannel_pool.h [3:3] - src/core/ext/filters/client_channel/resolver_result_parsing.cc [2:2] - src/core/ext/filters/client_channel/resolver_result_parsing.h [2:2] - src/core/ext/filters/client_channel/retry_service_config.cc [2:2] - src/core/ext/filters/client_channel/retry_service_config.h [2:2] - src/core/ext/filters/client_channel/server_address.cc [3:3] - src/core/ext/filters/client_channel/server_address.h [3:3] - src/core/ext/filters/client_channel/subchannel_pool_interface.cc [3:3] - src/core/ext/filters/client_channel/subchannel_pool_interface.h [3:3] - src/core/ext/filters/http/client_authority_filter.cc [3:3] - src/core/ext/filters/http/client_authority_filter.h [3:3] - src/core/ext/transport/chttp2/transport/chttp2_transport.cc [2:2] - src/core/ext/transport/chttp2/transport/context_list.cc [3:3] - src/core/ext/transport/chttp2/transport/context_list.h [3:3] - src/core/ext/xds/xds_api.cc [2:2] - src/core/ext/xds/xds_api.h [3:3] - src/core/ext/xds/xds_client.cc [2:2] - src/core/ext/xds/xds_client_stats.cc [3:3] - src/core/ext/xds/xds_client_stats.h [3:3] - src/core/lib/channel/channelz.h [3:3] - src/core/lib/gpr/alloc.h [3:3] - src/core/lib/iomgr/buffer_list.cc [3:3] - src/core/lib/iomgr/buffer_list.h [3:3] - src/core/lib/iomgr/cfstream_handle.cc [3:3] - src/core/lib/iomgr/cfstream_handle.h [3:3] - src/core/lib/iomgr/dynamic_annotations.h [3:3] - src/core/lib/iomgr/endpoint_cfstream.cc [3:3] - src/core/lib/iomgr/endpoint_cfstream.h [3:3] - src/core/lib/iomgr/error_cfstream.cc [3:3] - src/core/lib/iomgr/error_cfstream.h [3:3] - src/core/lib/iomgr/internal_errqueue.cc [3:3] - src/core/lib/iomgr/internal_errqueue.h [3:3] - src/core/lib/iomgr/iomgr_custom.cc [3:3] - src/core/lib/iomgr/iomgr_internal.cc [3:3] - src/core/lib/iomgr/pollset.cc [3:3] - src/core/lib/iomgr/pollset_custom.cc [3:3] - src/core/lib/iomgr/pollset_custom.h [3:3] - src/core/lib/iomgr/pollset_set.cc [3:3] - src/core/lib/iomgr/pollset_set_custom.h [3:3] - src/core/lib/iomgr/python_util.h [3:3] - src/core/lib/iomgr/resolve_address.cc [3:3] - src/core/lib/iomgr/resolve_address_custom.cc [3:3] - src/core/lib/iomgr/resolve_address_custom.h [3:3] - src/core/lib/iomgr/tcp_client.cc [3:3] - src/core/lib/iomgr/tcp_client_cfstream.cc [4:4] - src/core/lib/iomgr/tcp_client_custom.cc [3:3] - src/core/lib/iomgr/tcp_custom.cc [3:3] - src/core/lib/iomgr/tcp_custom.h [3:3] - src/core/lib/iomgr/tcp_server.cc [3:3] - src/core/lib/iomgr/tcp_server_custom.cc [3:3] - src/core/lib/iomgr/timer.cc [3:3] - src/core/lib/iomgr/timer_custom.h [3:3] - src/core/lib/security/credentials/alts/alts_credentials.cc [3:3] - src/core/lib/security/credentials/alts/alts_credentials.h [3:3] - src/core/lib/security/credentials/alts/check_gcp_environment.cc [3:3] - src/core/lib/security/credentials/alts/check_gcp_environment.h [3:3] - src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc [3:3] - src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc [3:3] - src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc [3:3] - src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc [3:3] - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc [3:3] - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h [3:3] - src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc [3:3] - src/core/lib/security/credentials/local/local_credentials.cc [3:3] - src/core/lib/security/credentials/local/local_credentials.h [3:3] - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc [3:3] - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h [3:3] - src/core/lib/security/credentials/tls/tls_credentials.cc [3:3] - src/core/lib/security/credentials/tls/tls_credentials.h [3:3] - src/core/lib/security/security_connector/alts/alts_security_connector.cc [3:3] - src/core/lib/security/security_connector/alts/alts_security_connector.h [3:3] - src/core/lib/security/security_connector/fake/fake_security_connector.cc [3:3] - src/core/lib/security/security_connector/fake/fake_security_connector.h [3:3] - src/core/lib/security/security_connector/load_system_roots.h [3:3] - src/core/lib/security/security_connector/load_system_roots_fallback.cc [3:3] - src/core/lib/security/security_connector/load_system_roots_linux.cc [3:3] - src/core/lib/security/security_connector/load_system_roots_linux.h [3:3] - src/core/lib/security/security_connector/local/local_security_connector.cc [3:3] - src/core/lib/security/security_connector/local/local_security_connector.h [3:3] - src/core/lib/security/security_connector/ssl/ssl_security_connector.cc [3:3] - src/core/lib/security/security_connector/ssl/ssl_security_connector.h [3:3] - src/core/lib/security/security_connector/tls/tls_security_connector.cc [3:3] - src/core/lib/security/security_connector/tls/tls_security_connector.h [3:3] - src/core/tsi/alts/crypt/aes_gcm.cc [3:3] - src/core/tsi/alts/crypt/gsec.cc [3:3] - src/core/tsi/alts/crypt/gsec.h [3:3] - src/core/tsi/alts/frame_protector/alts_counter.cc [3:3] - src/core/tsi/alts/frame_protector/alts_counter.h [3:3] - src/core/tsi/alts/frame_protector/alts_crypter.cc [3:3] - src/core/tsi/alts/frame_protector/alts_crypter.h [3:3] - src/core/tsi/alts/frame_protector/alts_frame_protector.cc [3:3] - src/core/tsi/alts/frame_protector/alts_frame_protector.h [3:3] - src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc [3:3] - src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h [3:3] - src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc [3:3] - src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc [3:3] - src/core/tsi/alts/frame_protector/frame_handler.cc [3:3] - src/core/tsi/alts/frame_protector/frame_handler.h [3:3] - src/core/tsi/alts/handshaker/alts_handshaker_client.cc [3:3] - src/core/tsi/alts/handshaker/alts_handshaker_client.h [3:3] - src/core/tsi/alts/handshaker/alts_shared_resource.cc [3:3] - src/core/tsi/alts/handshaker/alts_shared_resource.h [3:3] - src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc [3:3] - src/core/tsi/alts/handshaker/alts_tsi_handshaker.h [3:3] - src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h [3:3] - src/core/tsi/alts/handshaker/alts_tsi_utils.cc [3:3] - src/core/tsi/alts/handshaker/alts_tsi_utils.h [3:3] - src/core/tsi/alts/handshaker/proto/altscontext.proto [1:1] - src/core/tsi/alts/handshaker/proto/handshaker.proto [1:1] - src/core/tsi/alts/handshaker/proto/transport_security_common.proto [1:1] - src/core/tsi/alts/handshaker/transport_security_common_api.cc [3:3] - src/core/tsi/alts/handshaker/transport_security_common_api.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc [3:3] - src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h [3:3] - src/core/tsi/local_transport_security.cc [3:3] - src/core/tsi/local_transport_security.h [3:3] - src/core/tsi/ssl/session_cache/ssl_session.h [3:3] - src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc [3:3] - src/core/tsi/ssl/session_cache/ssl_session_cache.cc [3:3] - src/core/tsi/ssl/session_cache/ssl_session_cache.h [3:3] - src/core/tsi/ssl/session_cache/ssl_session_openssl.cc [3:3] - src/cpp/client/client_interceptor.cc [3:3] - src/cpp/common/alarm.cc [2:2] - src/cpp/server/channelz/channelz_service.cc [3:3] - src/cpp/server/channelz/channelz_service.h [3:3] - src/cpp/server/channelz/channelz_service_plugin.cc [3:3] - src/cpp/server/load_reporter/constants.h [3:3] - src/cpp/server/load_reporter/get_cpu_stats.h [3:3] - src/cpp/server/load_reporter/get_cpu_stats_linux.cc [3:3] - src/cpp/server/load_reporter/get_cpu_stats_macos.cc [3:3] - src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc [3:3] - src/cpp/server/load_reporter/get_cpu_stats_windows.cc [3:3] - src/cpp/server/load_reporter/load_data_store.cc [3:3] - src/cpp/server/load_reporter/load_data_store.h [3:3] - src/cpp/server/load_reporter/util.cc [3:3] - src/proto/grpc/lb/v1/load_reporter.proto [1:1] - src/proto/grpc/testing/empty_service.proto [2:2] - src/proto/grpc/testing/simple_messages.proto [2:2] - src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/fork_windows.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi [1:1] - src/python/grpcio/grpc/experimental/__init__.py [1:1] - src/python/grpcio/grpc/experimental/gevent.py [1:1] - src/python/grpcio/grpc/experimental/session_cache.py [1:1] - src/python/grpcio_testing/testing_commands.py [1:1] - src/python/grpcio_tests/tests/fork/__init__.py [1:1] - src/python/grpcio_tests/tests/fork/client.py [1:1] - src/python/grpcio_tests/tests/fork/methods.py [1:1] - src/python/grpcio_tests/tests/unit/_abort_test.py [1:1] - src/python/grpcio_tests/tests/unit/_channel_close_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_fork_test.py [1:1] - src/python/grpcio_tests/tests/unit/_error_message_encoding_test.py [1:1] - src/python/grpcio_tests/tests/unit/_logging_test.py [1:1] - src/python/grpcio_tests/tests/unit/_metadata_flags_test.py [1:1] - src/python/grpcio_tests/tests/unit/_server_shutdown_scenarios.py [1:1] - src/python/grpcio_tests/tests/unit/_server_shutdown_test.py [1:1] - src/python/grpcio_tests/tests/unit/_session_cache_test.py [1:1] - src/python/grpcio_tests/tests/unit/_version_test.py [1:1] - test/core/util/fuzzer_util.cc [3:3] - test/core/util/fuzzer_util.h [3:3] - test/core/util/test_lb_policies.cc [2:2] - test/core/util/test_lb_policies.h [2:2] - test/cpp/end2end/channelz_service_test.cc [3:3] - test/cpp/end2end/client_callback_end2end_test.cc [3:3] - test/cpp/end2end/client_interceptors_end2end_test.cc [3:3] - test/cpp/end2end/delegating_channel_test.cc [3:3] - test/cpp/end2end/interceptors_util.cc [3:3] - test/cpp/end2end/interceptors_util.h [3:3] - test/cpp/end2end/nonblocking_test.cc [3:3] - test/cpp/end2end/server_early_return_test.cc [3:3] - test/cpp/end2end/server_interceptors_end2end_test.cc [3:3] - test/cpp/end2end/server_load_reporting_end2end_test.cc [3:3] - test/cpp/end2end/test_health_check_service_impl.cc [3:3] - test/cpp/end2end/test_health_check_service_impl.h [3:3] - test/cpp/util/channel_trace_proto_helper.cc [3:3] - test/cpp/util/channel_trace_proto_helper.h [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL 14562f2a7eb107a8f822700bf0293d8d -BELONGS third_party/upb/ya.make - License text: - Copyright (c) 2009-2021, Google LLC - All rights reserved. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - third_party/upb/LICENSE [2:3] - third_party/upb/upb/decode.c [2:3] - third_party/upb/upb/decode.h [2:3] - third_party/upb/upb/decode_fast.c [2:3] - third_party/upb/upb/decode_fast.h [2:3] - third_party/upb/upb/decode_internal.h [2:3] - third_party/upb/upb/def.c [2:3] - third_party/upb/upb/def.h [2:3] - third_party/upb/upb/def.hpp [1:2] - third_party/upb/upb/encode.c [2:3] - third_party/upb/upb/encode.h [2:3] - third_party/upb/upb/msg.c [2:3] - third_party/upb/upb/msg.h [2:3] - third_party/upb/upb/msg_internal.h [2:3] - third_party/upb/upb/port_def.inc [2:3] - third_party/upb/upb/port_undef.inc [2:3] - third_party/upb/upb/reflection.c [2:3] - third_party/upb/upb/reflection.h [2:3] - third_party/upb/upb/table.c [2:3] - third_party/upb/upb/table_internal.h [2:3] - third_party/upb/upb/text_encode.c [2:3] - third_party/upb/upb/text_encode.h [2:3] - third_party/upb/upb/upb.c [2:3] - third_party/upb/upb/upb.h [2:3] - third_party/upb/upb/upb.hpp [1:2] - third_party/upb/upb/upb_internal.h [2:3] - -KEEP COPYRIGHT_SERVICE_LABEL 1ad5a8379223f39b4124906a5bd2437d -BELONGS src/python/grpcio/ya.make src/python/grpcio_tests/ya.make - License text: - \# Copyright 2019 The gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio/grpc/_compression.py [1:1] - src/python/grpcio_tests/tests/stress/unary_stream_benchmark.py [1:1] - src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py [1:1] - src/python/grpcio_tests/tests/unit/framework/common/__init__.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 1c0b49517f30a005a1f30fc39200d3ee -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/python/grpcio/ya.make src/python/grpcio_tests/ya.make test/cpp/end2end/ya.make ya.make - License text: - * Copyright 2019 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpcpp/impl/codegen/async_stream.h [3:3] - include/grpcpp/impl/codegen/client_callback.h [3:3] - include/grpcpp/impl/codegen/delegating_channel.h [3:3] - include/grpcpp/impl/codegen/message_allocator.h [3:3] - include/grpcpp/impl/codegen/server_callback.h [3:3] - include/grpcpp/impl/codegen/server_callback_handlers.h [3:3] - include/grpcpp/impl/codegen/server_context.h [3:3] - include/grpcpp/impl/codegen/sync.h [3:3] - include/grpcpp/impl/codegen/sync_stream.h [3:3] - include/grpcpp/opencensus.h [3:3] - include/grpcpp/security/alts_context.h [3:3] - include/grpcpp/security/alts_util.h [3:3] - include/grpcpp/security/cronet_credentials.h [3:3] - include/grpcpp/security/tls_credentials_options.h [3:3] - include/grpcpp/support/message_allocator.h [3:3] - include/grpcpp/support/validate_service_config.h [3:3] - include/grpcpp/test/default_reactor_test_peer.h [3:3] - src/compiler/config_protobuf.h [3:3] - src/compiler/cpp_plugin.h [3:3] - src/core/ext/filters/client_channel/backend_metric.cc [2:2] - src/core/ext/filters/client_channel/backend_metric.h [2:2] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/cds.cc [2:2] - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc [2:2] - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h [3:3] - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc [3:3] - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h [2:2] - src/core/ext/filters/client_channel/subchannel_interface.h [3:3] - src/core/ext/filters/client_idle/client_idle_filter.cc [3:3] - src/core/ext/xds/xds_bootstrap.cc [2:2] - src/core/ext/xds/xds_bootstrap.h [2:2] - src/core/ext/xds/xds_channel_args.h [2:2] - src/core/ext/xds/xds_client.h [2:2] - src/core/lib/gprpp/global_config.h [3:3] - src/core/lib/gprpp/global_config_custom.h [3:3] - src/core/lib/gprpp/global_config_env.cc [3:3] - src/core/lib/gprpp/global_config_env.h [3:3] - src/core/lib/gprpp/global_config_generic.h [3:3] - src/core/lib/gprpp/sync.h [3:3] - src/core/lib/iomgr/executor/mpmcqueue.cc [3:3] - src/core/lib/iomgr/executor/mpmcqueue.h [3:3] - src/core/lib/iomgr/executor/threadpool.cc [3:3] - src/core/lib/iomgr/executor/threadpool.h [3:3] - src/core/lib/iomgr/work_serializer.cc [3:3] - src/core/lib/iomgr/work_serializer.h [3:3] - src/core/lib/security/security_connector/ssl_utils_config.cc [3:3] - src/core/lib/security/security_connector/ssl_utils_config.h [3:3] - src/core/lib/slice/slice_utils.h [3:3] - src/cpp/client/client_callback.cc [2:2] - src/cpp/common/alts_context.cc [3:3] - src/cpp/common/alts_util.cc [3:3] - src/cpp/common/tls_credentials_options.cc [3:3] - src/cpp/common/validate_service_config.cc [3:3] - src/cpp/server/external_connection_acceptor_impl.cc [3:3] - src/cpp/server/external_connection_acceptor_impl.h [3:3] - src/cpp/server/server_callback.cc [2:2] - src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/rpc_status.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/rpc_status.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi [1:1] - src/python/grpcio/grpc/aio/__init__.py [1:1] - src/python/grpcio/grpc/aio/_call.py [1:1] - src/python/grpcio/grpc/aio/_channel.py [1:1] - src/python/grpcio/grpc/aio/_interceptor.py [1:1] - src/python/grpcio/grpc/aio/_utils.py [1:1] - src/python/grpcio_tests/tests/fork/_fork_interop_test.py [1:1] - src/python/grpcio_tests/tests_aio/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py [1:1] - test/cpp/end2end/flaky_network_test.cc [3:3] - test/cpp/end2end/message_allocator_end2end_test.cc [3:3] - test/cpp/end2end/port_sharing_end2end_test.cc [3:3] - test/cpp/end2end/time_change_test.cc [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL 249314deafd9b3e055b23b29bdbf09f3 -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/python/grpcio/ya.make src/python/grpcio_reflection/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make test/cpp/end2end/ya.make ya.make - License text: - * Copyright 2020 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/impl/codegen/sync_abseil.h [3:3] - include/grpc/support/sync_abseil.h [3:3] - include/grpcpp/security/tls_certificate_provider.h [2:2] - include/grpcpp/test/channel_test_peer.h [3:3] - include/grpcpp/xds_server_builder.h [3:3] - src/core/ext/filters/client_channel/config_selector.cc [2:2] - src/core/ext/filters/client_channel/config_selector.h [2:2] - src/core/ext/filters/client_channel/dynamic_filters.cc [2:2] - src/core/ext/filters/client_channel/dynamic_filters.h [2:2] - src/core/ext/filters/client_channel/lb_policy/address_filtering.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/address_filtering.h [2:2] - src/core/ext/filters/client_channel/lb_policy/rls/rls.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h [2:2] - src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc [2:2] - src/core/ext/filters/http/message_compress/message_decompress_filter.cc [3:3] - src/core/ext/filters/http/message_compress/message_decompress_filter.h [3:3] - src/core/ext/xds/certificate_provider_factory.h [3:3] - src/core/ext/xds/certificate_provider_registry.cc [3:3] - src/core/ext/xds/certificate_provider_registry.h [3:3] - src/core/ext/xds/certificate_provider_store.cc [3:3] - src/core/ext/xds/certificate_provider_store.h [3:3] - src/core/ext/xds/file_watcher_certificate_provider_factory.cc [3:3] - src/core/ext/xds/file_watcher_certificate_provider_factory.h [3:3] - src/core/ext/xds/xds_certificate_provider.cc [3:3] - src/core/ext/xds/xds_certificate_provider.h [3:3] - src/core/ext/xds/xds_server_config_fetcher.cc [3:3] - src/core/lib/gpr/sync_abseil.cc [3:3] - src/core/lib/gprpp/dual_ref_counted.h [2:2] - src/core/lib/gprpp/examine_stack.cc [3:3] - src/core/lib/gprpp/examine_stack.h [3:3] - src/core/lib/gprpp/stat.h [2:2] - src/core/lib/gprpp/stat_posix.cc [2:2] - src/core/lib/gprpp/stat_windows.cc [2:2] - src/core/lib/iomgr/dualstack_socket_posix.cc [3:3] - src/core/lib/iomgr/ev_apple.cc [3:3] - src/core/lib/iomgr/ev_apple.h [3:3] - src/core/lib/json/json_util.cc [3:3] - src/core/lib/json/json_util.h [3:3] - src/core/lib/security/authorization/cel_authorization_engine.h [2:2] - src/core/lib/security/authorization/mock_cel/activation.h [1:1] - src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h [1:1] - src/core/lib/security/authorization/mock_cel/cel_expression.h [1:1] - src/core/lib/security/authorization/mock_cel/cel_value.h [1:1] - src/core/lib/security/authorization/mock_cel/evaluator_core.h [1:1] - src/core/lib/security/authorization/mock_cel/flat_expr_builder.h [1:1] - src/core/lib/security/credentials/external/aws_external_account_credentials.cc [2:2] - src/core/lib/security/credentials/external/aws_external_account_credentials.h [2:2] - src/core/lib/security/credentials/external/aws_request_signer.cc [2:2] - src/core/lib/security/credentials/external/aws_request_signer.h [2:2] - src/core/lib/security/credentials/external/external_account_credentials.cc [2:2] - src/core/lib/security/credentials/external/external_account_credentials.h [2:2] - src/core/lib/security/credentials/external/file_external_account_credentials.cc [2:2] - src/core/lib/security/credentials/external/file_external_account_credentials.h [2:2] - src/core/lib/security/credentials/external/url_external_account_credentials.cc [2:2] - src/core/lib/security/credentials/external/url_external_account_credentials.h [2:2] - src/core/lib/security/credentials/insecure/insecure_credentials.cc [3:3] - src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc [2:2] - src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h [2:2] - src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc [2:2] - src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h [2:2] - src/core/lib/security/credentials/tls/tls_utils.cc [3:3] - src/core/lib/security/credentials/tls/tls_utils.h [3:3] - src/core/lib/security/credentials/xds/xds_credentials.cc [3:3] - src/core/lib/security/credentials/xds/xds_credentials.h [3:3] - src/core/lib/security/security_connector/insecure/insecure_security_connector.cc [3:3] - src/core/lib/security/security_connector/insecure/insecure_security_connector.h [3:3] - src/cpp/client/xds_credentials.cc [3:3] - src/cpp/common/tls_certificate_provider.cc [2:2] - src/cpp/server/xds_server_credentials.cc [3:3] - src/python/grpcio/grpc/aio/_metadata.py [1:1] - src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py [1:1] - src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py [1:1] - src/python/grpcio_tests/tests_aio/unit/_metadata_test.py [1:1] - test/core/util/resolve_localhost_ip46.cc [3:3] - test/core/util/resolve_localhost_ip46.h [3:3] - test/core/util/tls_utils.cc [2:2] - test/core/util/tls_utils.h [2:2] - test/cpp/end2end/context_allocator_end2end_test.cc [3:3] - test/cpp/end2end/rls_end2end_test.cc [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL 24f793f95f5c432d60ec3ef10b0e1a07 -BELONGS ya.make - License text: - Copyright 2016, Google Inc. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - LICENSE [208:208] - -KEEP COPYRIGHT_SERVICE_LABEL 2738b84693d58ad3ff70e7cfefe0c3de -BELONGS src/python/grpcio_tests/ya.make - License text: - \# Copyright 2019 The gRPC Authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio_tests/tests_aio/_sanity/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/benchmark/server.py [1:1] - src/python/grpcio_tests/tests_aio/unit/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/unit/call_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/channel_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/client_unary_unary_interceptor_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/connectivity_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/init_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/server_test.py [1:1] - src/python/grpcio_tests/tests_py3_only/unit/__init__.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 3b3b16ffa1ced0a3528ed514cd0e24f4 -BELONGS src/core/lib/ya.make - License text: - // Copyright 2021 the gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/core/lib/gprpp/status_helper.cc [3:3] - src/core/lib/gprpp/status_helper.h [3:3] - src/core/lib/gprpp/time_util.cc [2:2] - src/core/lib/gprpp/time_util.h [2:2] - -KEEP COPYRIGHT_SERVICE_LABEL 3f8e6ecc96f8543539ce4b548cdc9afb -BELONGS src/core/lib/ya.make src/proto/grpc/testing/xds/ya.make src/python/grpcio/ya.make src/python/grpcio_tests/ya.make ya.make - License text: - // Copyright 2021 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/event_engine/endpoint_config.h [1:1] - include/grpc/event_engine/event_engine.h [1:1] - include/grpc/event_engine/internal/memory_allocator_impl.h [1:1] - include/grpc/event_engine/memory_allocator.h [1:1] - include/grpc/event_engine/memory_request.h [1:1] - include/grpc/event_engine/port.h [1:1] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc [1:1] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc [1:1] - src/core/lib/event_engine/channel_args_endpoint_config.cc [1:1] - src/core/lib/event_engine/channel_args_endpoint_config.h [1:1] - src/core/lib/event_engine/event_engine.cc [1:1] - src/core/lib/event_engine/event_engine_factory.cc [1:1] - src/core/lib/event_engine/event_engine_factory.h [1:1] - src/core/lib/event_engine/sockaddr.cc [1:1] - src/core/lib/event_engine/sockaddr.h [1:1] - src/core/lib/iomgr/endpoint_pair_event_engine.cc [1:1] - src/core/lib/iomgr/event_engine/closure.cc [1:1] - src/core/lib/iomgr/event_engine/closure.h [1:1] - src/core/lib/iomgr/event_engine/endpoint.cc [1:1] - src/core/lib/iomgr/event_engine/endpoint.h [1:1] - src/core/lib/iomgr/event_engine/iomgr.cc [1:1] - src/core/lib/iomgr/event_engine/pollset.cc [1:1] - src/core/lib/iomgr/event_engine/pollset.h [1:1] - src/core/lib/iomgr/event_engine/promise.h [1:1] - src/core/lib/iomgr/event_engine/resolved_address_internal.cc [1:1] - src/core/lib/iomgr/event_engine/resolved_address_internal.h [1:1] - src/core/lib/iomgr/event_engine/resolver.cc [1:1] - src/core/lib/iomgr/event_engine/tcp.cc [1:1] - src/core/lib/iomgr/event_engine/timer.cc [1:1] - src/proto/grpc/testing/xds/v3/config_dump.proto [1:1] - src/proto/grpc/testing/xds/v3/csds.proto [1:1] - src/proto/grpc/testing/xds/v3/extension.proto [1:1] - src/proto/grpc/testing/xds/v3/router.proto [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/csds.pyx.pxi [1:1] - src/python/grpcio_admin/grpc_admin/__init__.py [1:1] - src/python/grpcio_admin/grpc_version.py [1:1] - src/python/grpcio_admin/setup.py [1:1] - src/python/grpcio_csds/grpc_csds/__init__.py [1:1] - src/python/grpcio_csds/grpc_version.py [1:1] - src/python/grpcio_csds/setup.py [1:1] - src/python/grpcio_tests/tests/admin/test_admin.py [1:1] - src/python/grpcio_tests/tests/csds/test_csds.py [1:1] - src/python/grpcio_tests/tests_aio/unit/server_time_remaining_test.py [1:1] - src/python/grpcio_tests/tests_gevent/__init__.py [1:1] - src/python/grpcio_tests/tests_gevent/unit/__init__.py [1:1] - src/python/grpcio_tests/tests_gevent/unit/_test_server.py [1:1] - src/python/grpcio_tests/tests_gevent/unit/close_channel_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 47856a1da8680a4ba503954f87b9eb2c -BELONGS test/core/util/ya.make - License text: - * Copyright 2020 the gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - test/core/util/stack_tracer.cc [3:3] - test/core/util/stack_tracer.h [3:3] - test/core/util/stack_tracer_test.cc [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL 57712bcea01f379c970232b100dc2326 -BELONGS src/python/grpcio/ya.make src/python/grpcio_tests/ya.make - License text: - \# Copyright 2020 The gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio/grpc/_cython/_cygrpc/thread.pyx.pxi [1:1] - src/python/grpcio/grpc/_runtime_protos.py [1:1] - src/python/grpcio/grpc/_simple_stubs.py [1:1] - src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py [1:1] - src/python/grpcio_tests/tests_py3_only/__init__.py [1:1] - src/python/grpcio_tests/tests_py3_only/interop/xds_interop_client.py [1:1] - src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 64f680c19b2530ac0e770568283d4c61 -BELONGS ya.make - License text: - Copyright 2014 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - NOTICE.txt [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 6c4d5c3cb6b36f7e11218f2c7dc77ebd -BELONGS src/python/grpcio_tests/ya.make - License text: - \# Copyright 2019 the gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio_tests/tests/unit/_signal_client.py [1:1] - src/python/grpcio_tests/tests/unit/_signal_handling_test.py [1:1] - src/python/grpcio_tests/tests/unit/_tcp_proxy.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 772d70e950c69b1a32c0a0047f47ee2d -BELONGS third_party/address_sorting/ya.make - License text: - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - third_party/address_sorting/LICENSE [1:2] - third_party/address_sorting/address_sorting.c [4:5] - third_party/address_sorting/address_sorting_internal.h [4:5] - third_party/address_sorting/address_sorting_posix.c [4:5] - third_party/address_sorting/address_sorting_windows.c [4:5] - third_party/address_sorting/include/address_sorting/address_sorting.h [4:5] - -KEEP COPYRIGHT_SERVICE_LABEL 7b51323881f67ba78a30a266dca846ec -BELONGS src/proto/grpc/channelz/ya.make src/python/grpcio/ya.make src/python/grpcio_channelz/ya.make src/python/grpcio_status/ya.make src/python/grpcio_tests/ya.make ya.make - License text: - // Copyright 2018 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/channelz/channelz.proto [1:1] - src/proto/grpc/gcp/altscontext.proto [1:1] - src/proto/grpc/gcp/handshaker.proto [1:1] - src/proto/grpc/gcp/transport_security_common.proto [1:1] - src/python/grpcio/_parallel_compile_patch.py [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/_hooks.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/_hooks.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/channelz.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/propagation_bits.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/propagation_bits.pyx.pxi [1:1] - src/python/grpcio_channelz/channelz_commands.py [1:1] - src/python/grpcio_channelz/grpc_channelz/__init__.py [1:1] - src/python/grpcio_channelz/grpc_channelz/v1/__init__.py [1:1] - src/python/grpcio_channelz/grpc_channelz/v1/channelz.py [1:1] - src/python/grpcio_channelz/grpc_version.py [1:1] - src/python/grpcio_channelz/setup.py [1:1] - src/python/grpcio_status/grpc_status/__init__.py [1:1] - src/python/grpcio_status/grpc_status/rpc_status.py [1:1] - src/python/grpcio_status/grpc_version.py [1:1] - src/python/grpcio_status/setup.py [1:1] - src/python/grpcio_status/status_commands.py [1:1] - src/python/grpcio_tests/tests/channelz/__init__.py [1:1] - src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py [1:1] - src/python/grpcio_tests/tests/status/__init__.py [1:1] - src/python/grpcio_tests/tests/status/_grpc_status_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 8183794cfdcd444d086a2c63a36d9beb -BELONGS src/proto/grpc/testing/xds/ya.make src/python/grpcio/ya.make src/python/grpcio_channelz/ya.make src/python/grpcio_health_checking/ya.make src/python/grpcio_status/ya.make src/python/grpcio_tests/ya.make ya.make - License text: - // Copyright 2020 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/lookup/v1/rls.proto [1:1] - src/proto/grpc/lookup/v1/rls_config.proto [1:1] - src/proto/grpc/testing/xds/v3/address.proto [1:1] - src/proto/grpc/testing/xds/v3/ads.proto [1:1] - src/proto/grpc/testing/xds/v3/aggregate_cluster.proto [1:1] - src/proto/grpc/testing/xds/v3/base.proto [1:1] - src/proto/grpc/testing/xds/v3/cluster.proto [1:1] - src/proto/grpc/testing/xds/v3/config_source.proto [1:1] - src/proto/grpc/testing/xds/v3/discovery.proto [1:1] - src/proto/grpc/testing/xds/v3/endpoint.proto [1:1] - src/proto/grpc/testing/xds/v3/fault.proto [1:1] - src/proto/grpc/testing/xds/v3/fault_common.proto [1:1] - src/proto/grpc/testing/xds/v3/http_connection_manager.proto [1:1] - src/proto/grpc/testing/xds/v3/listener.proto [1:1] - src/proto/grpc/testing/xds/v3/load_report.proto [1:1] - src/proto/grpc/testing/xds/v3/lrs.proto [1:1] - src/proto/grpc/testing/xds/v3/orca_load_report.proto [1:1] - src/proto/grpc/testing/xds/v3/percent.proto [1:1] - src/proto/grpc/testing/xds/v3/protocol.proto [1:1] - src/proto/grpc/testing/xds/v3/range.proto [1:1] - src/proto/grpc/testing/xds/v3/regex.proto [1:1] - src/proto/grpc/testing/xds/v3/route.proto [1:1] - src/proto/grpc/testing/xds/v3/string.proto [1:1] - src/proto/grpc/testing/xds/v3/tls.proto [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi [1:1] - src/python/grpcio/grpc/aio/_base_channel.py [1:1] - src/python/grpcio/grpc/aio/_base_server.py [1:1] - src/python/grpcio/grpc/experimental/aio/__init__.py [1:1] - src/python/grpcio_channelz/grpc_channelz/v1/_async.py [1:1] - src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py [1:1] - src/python/grpcio_health_checking/grpc_health/v1/_async.py [1:1] - src/python/grpcio_status/grpc_status/_async.py [1:1] - src/python/grpcio_status/grpc_status/_common.py [1:1] - src/python/grpcio_tests/tests/unit/_rpc_test_helpers.py [1:1] - src/python/grpcio_tests/tests_aio/benchmark/benchmark_client.py [1:1] - src/python/grpcio_tests/tests_aio/benchmark/benchmark_servicer.py [1:1] - src/python/grpcio_tests/tests_aio/benchmark/worker.py [1:1] - src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py [1:1] - src/python/grpcio_tests/tests_aio/channelz/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/channelz/channelz_servicer_test.py [1:1] - src/python/grpcio_tests/tests_aio/health_check/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py [1:1] - src/python/grpcio_tests/tests_aio/interop/local_interop_test.py [1:1] - src/python/grpcio_tests/tests_aio/status/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/status/grpc_status_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/_common.py [1:1] - src/python/grpcio_tests/tests_aio/unit/_constants.py [1:1] - src/python/grpcio_tests/tests_aio/unit/auth_context_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/channel_ready_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/compatibility_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/compression_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/context_peer_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/done_callback_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/metadata_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/outside_init_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/timeout_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/wait_for_connection_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/wait_for_ready_test.py [1:1] - src/python/grpcio_tests/tests_py3_only/unit/_leak_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL 90fc8bbf7a57ec743af147a4496a5eb2 -BELONGS src/proto/grpc/testing/xds/ya.make src/python/grpcio/ya.make src/python/grpcio_tests/ya.make test/cpp/end2end/ya.make - License text: - // Copyright 2019 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/testing/xds/ads_for_test.proto [1:1] - src/proto/grpc/testing/xds/cds_for_test.proto [1:1] - src/proto/grpc/testing/xds/eds_for_test.proto [1:1] - src/proto/grpc/testing/xds/lds_rds_for_test.proto [1:1] - src/proto/grpc/testing/xds/lrs_for_test.proto [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/common.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi [1:1] - src/python/grpcio/grpc/aio/_base_call.py [1:1] - src/python/grpcio/grpc/aio/_server.py [1:1] - src/python/grpcio/grpc/aio/_typing.py [1:1] - src/python/grpcio_tests/tests/bazel_namespace_package_hack.py [1:1] - src/python/grpcio_tests/tests/interop/service.py [1:1] - src/python/grpcio_tests/tests/unit/_dns_resolver_test.py [1:1] - src/python/grpcio_tests/tests/unit/_grpc_shutdown_test.py [1:1] - src/python/grpcio_tests/tests/unit/_local_credentials_test.py [1:1] - src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py [1:1] - src/python/grpcio_tests/tests_aio/interop/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/interop/client.py [1:1] - src/python/grpcio_tests/tests_aio/interop/methods.py [1:1] - src/python/grpcio_tests/tests_aio/interop/server.py [1:1] - src/python/grpcio_tests/tests_aio/unit/_test_base.py [1:1] - src/python/grpcio_tests/tests_aio/unit/_test_server.py [1:1] - src/python/grpcio_tests/tests_aio/unit/abort_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/aio_rpc_error_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/channel_argument_test.py [1:1] - test/cpp/end2end/cfstream_test.cc [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL c822b8e4a7bf3b1525b6d5673145a917 -BELONGS src/python/grpcio_tests/ya.make - License text: - \# Copyright 2020 The gRPC Authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio_tests/tests_aio/unit/client_stream_stream_interceptor_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/client_stream_unary_interceptor_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/client_unary_stream_interceptor_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/close_channel_test.py [1:1] - src/python/grpcio_tests/tests_aio/unit/secure_call_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL cd2dccf3745a79cfb4fea6a49cb170ae -BELONGS src/core/lib/ya.make src/proto/grpc/testing/ya.make src/python/grpcio/ya.make test/core/util/ya.make test/cpp/util/ya.make ya.make - License text: - * Copyright 2015-2016 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/census.h [3:3] - include/grpc/grpc.h [3:3] - include/grpcpp/impl/codegen/completion_queue.h [3:3] - include/grpcpp/server_builder.h [3:3] - src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc [3:3] - src/core/lib/iomgr/ev_poll_posix.h [3:3] - src/core/lib/json/json_reader.cc [3:3] - src/core/lib/security/credentials/composite/composite_credentials.cc [3:3] - src/core/lib/surface/completion_queue.cc [3:3] - src/core/lib/surface/completion_queue.h [3:3] - src/core/lib/surface/server.cc [2:2] - src/cpp/server/server_builder.cc [3:3] - src/proto/grpc/testing/messages.proto [2:2] - src/proto/grpc/testing/metrics.proto [1:1] - src/proto/grpc/testing/test.proto [2:2] - src/python/grpcio/grpc/__init__.py [1:1] - src/python/grpcio/grpc/beta/implementations.py [1:1] - test/core/util/reconnect_server.h [3:3] - test/cpp/util/create_test_channel.cc [3:3] - test/cpp/util/create_test_channel.h [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL ce123482847d9599548cd2797b1f2978 -BELONGS src/core/lib/ya.make src/proto/grpc/core/ya.make src/proto/grpc/testing/ya.make src/python/grpcio/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make ya.make - License text: - * Copyright 2017 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/fork.h [3:3] - include/grpc/impl/codegen/fork.h [3:3] - include/grpc/impl/codegen/sync_custom.h [3:3] - include/grpc/load_reporting.h [3:3] - include/grpc/support/sync_custom.h [3:3] - include/grpcpp/impl/channel_argument_option.h [3:3] - include/grpcpp/impl/codegen/byte_buffer.h [3:3] - include/grpcpp/support/error_details.h [3:3] - include/grpcpp/test/mock_stream.h [3:3] - src/core/ext/filters/client_channel/backup_poller.cc [3:3] - src/core/ext/filters/client_channel/backup_poller.h [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h [3:3] - src/core/ext/filters/client_channel/proxy_mapper.h [3:3] - src/core/ext/filters/client_channel/proxy_mapper_registry.cc [3:3] - src/core/ext/filters/client_channel/proxy_mapper_registry.h [3:3] - src/core/ext/filters/client_channel/retry_throttle.cc [3:3] - src/core/ext/filters/client_channel/retry_throttle.h [3:3] - src/core/ext/filters/http/http_filters_plugin.cc [3:3] - src/core/ext/filters/max_age/max_age_filter.cc [3:3] - src/core/ext/filters/max_age/max_age_filter.h [2:2] - src/core/ext/transport/chttp2/transport/flow_control.cc [3:3] - src/core/ext/transport/chttp2/transport/flow_control.h [3:3] - src/core/ext/transport/chttp2/transport/http2_settings.cc [2:2] - src/core/ext/transport/chttp2/transport/http2_settings.h [2:2] - src/core/ext/transport/inproc/inproc_plugin.cc [3:3] - src/core/ext/transport/inproc/inproc_transport.cc [3:3] - src/core/ext/transport/inproc/inproc_transport.h [3:3] - src/core/lib/channel/channel_trace.cc [3:3] - src/core/lib/channel/channel_trace.h [3:3] - src/core/lib/channel/channelz.cc [3:3] - src/core/lib/channel/channelz_registry.cc [3:3] - src/core/lib/channel/channelz_registry.h [3:3] - src/core/lib/channel/status_util.cc [3:3] - src/core/lib/channel/status_util.h [3:3] - src/core/lib/compression/compression_internal.h [3:3] - src/core/lib/compression/stream_compression.cc [3:3] - src/core/lib/compression/stream_compression.h [3:3] - src/core/lib/compression/stream_compression_gzip.cc [3:3] - src/core/lib/compression/stream_compression_gzip.h [3:3] - src/core/lib/compression/stream_compression_identity.cc [3:3] - src/core/lib/compression/stream_compression_identity.h [3:3] - src/core/lib/debug/stats.cc [3:3] - src/core/lib/debug/stats.h [3:3] - src/core/lib/debug/stats_data.cc [2:2] - src/core/lib/debug/stats_data.h [2:2] - src/core/lib/gpr/atm.cc [3:3] - src/core/lib/gprpp/arena.cc [3:3] - src/core/lib/gprpp/arena.h [3:3] - src/core/lib/gprpp/atomic_utils.h [3:3] - src/core/lib/gprpp/debug_location.h [3:3] - src/core/lib/gprpp/fork.cc [3:3] - src/core/lib/gprpp/fork.h [3:3] - src/core/lib/gprpp/memory.h [3:3] - src/core/lib/gprpp/orphanable.h [3:3] - src/core/lib/gprpp/ref_counted.h [3:3] - src/core/lib/gprpp/ref_counted_ptr.h [3:3] - src/core/lib/iomgr/call_combiner.cc [3:3] - src/core/lib/iomgr/call_combiner.h [3:3] - src/core/lib/iomgr/ev_epoll1_linux.cc [3:3] - src/core/lib/iomgr/ev_epoll1_linux.h [3:3] - src/core/lib/iomgr/ev_epollex_linux.cc [3:3] - src/core/lib/iomgr/fork_posix.cc [3:3] - src/core/lib/iomgr/fork_windows.cc [3:3] - src/core/lib/iomgr/gethostname.h [3:3] - src/core/lib/iomgr/gethostname_fallback.cc [3:3] - src/core/lib/iomgr/gethostname_host_name_max.cc [3:3] - src/core/lib/iomgr/gethostname_sysconf.cc [3:3] - src/core/lib/iomgr/iomgr_custom.h [3:3] - src/core/lib/iomgr/is_epollexclusive_available.cc [3:3] - src/core/lib/iomgr/lockfree_event.cc [3:3] - src/core/lib/iomgr/lockfree_event.h [3:3] - src/core/lib/iomgr/nameser.h [3:3] - src/core/lib/iomgr/socket_factory_posix.cc [3:3] - src/core/lib/iomgr/socket_factory_posix.h [3:3] - src/core/lib/iomgr/sys_epoll_wrapper.h [3:3] - src/core/lib/iomgr/tcp_server_utils_posix.h [3:3] - src/core/lib/iomgr/tcp_server_utils_posix_common.cc [3:3] - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc [3:3] - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc [3:3] - src/core/lib/iomgr/timer_custom.cc [3:3] - src/core/lib/iomgr/timer_manager.cc [3:3] - src/core/lib/iomgr/timer_manager.h [3:3] - src/core/lib/surface/completion_queue_factory.cc [3:3] - src/core/lib/surface/completion_queue_factory.h [3:3] - src/core/lib/surface/validate_metadata.h [3:3] - src/core/lib/transport/status_metadata.cc [3:3] - src/core/lib/transport/status_metadata.h [3:3] - src/core/tsi/test_creds/BUILD [1:1] - src/core/tsi/transport_security_grpc.cc [3:3] - src/core/tsi/transport_security_grpc.h [3:3] - src/cpp/server/channel_argument_option.cc [3:3] - src/cpp/util/error_details.cc [3:3] - src/proto/grpc/core/stats.proto [1:1] - src/proto/grpc/testing/proxy-service.proto [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi [1:1] - src/python/grpcio/grpc/_grpcio_metadata.py [1:1] - src/python/grpcio/grpc/_interceptor.py [1:1] - src/python/grpcio/grpc/beta/_metadata.py [1:1] - src/python/grpcio_testing/grpc_testing/__init__.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/__init__.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_channel.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_invocation.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py [1:1] - src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py [1:1] - src/python/grpcio_testing/grpc_testing/_common.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/__init__.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_handler.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_rpc.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_server.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_server_rpc.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_service.py [1:1] - src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py [1:1] - src/python/grpcio_testing/grpc_testing/_time.py [1:1] - src/python/grpcio_testing/grpc_version.py [1:1] - src/python/grpcio_testing/setup.py [1:1] - src/python/grpcio_tests/tests/testing/__init__.py [1:1] - src/python/grpcio_tests/tests/testing/_application_common.py [1:1] - src/python/grpcio_tests/tests/testing/_application_testing_common.py [1:1] - src/python/grpcio_tests/tests/testing/_client_application.py [1:1] - src/python/grpcio_tests/tests/testing/_client_test.py [1:1] - src/python/grpcio_tests/tests/testing/_server_application.py [1:1] - src/python/grpcio_tests/tests/testing/_server_test.py [1:1] - src/python/grpcio_tests/tests/testing/_time_test.py [1:1] - src/python/grpcio_tests/tests/testing/proto/__init__.py [1:1] - src/python/grpcio_tests/tests/unit/_auth_context_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_common.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_server_test.py [1:1] - src/python/grpcio_tests/tests/unit/_interceptor_test.py [1:1] - src/python/grpcio_tests/tests/unit/_reconnect_test.py [1:1] - src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py [1:1] - src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py [1:1] - test/core/util/fuzzer_one_entry_runner.sh [5:5] - test/core/util/port_isolated_runtime_environment.cc [3:3] - test/core/util/run_with_poller.sh [2:2] - test/cpp/end2end/counted_service.h [2:2] - test/cpp/end2end/exception_test.cc [3:3] - test/cpp/end2end/grpclb_end2end_test.cc [2:2] - test/cpp/util/error_details_test.cc [3:3] - -KEEP COPYRIGHT_SERVICE_LABEL d1f37f63030e0e8933bd29b33aedaaa6 -BELONGS src/python/grpcio_tests/ya.make - License text: - \# Copyright 2018 The gRPC Authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio_tests/tests/unit/_server_test.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL e4754455d390a3393237498e20414796 -BELONGS src/python/grpcio_tests/ya.make - License text: - \# Copyright 2021 The gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/python/grpcio_tests/tests/unit/_xds_credentials_test.py [1:1] - src/python/grpcio_tests/tests_py3_only/interop/xds_interop_server.py [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL f053023fe408f1896a456d1d28958df9 -BELONGS src/proto/grpc/health/v1/ya.make ya.make - License text: - // Copyright 2015 The gRPC Authors - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - src/proto/grpc/health/v1/health.proto [1:1] - src/proto/grpc/lb/v1/load_balancer.proto [1:1] - -KEEP COPYRIGHT_SERVICE_LABEL f8fb9a8ebe3e4b096090bd006ebb72cc -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/proto/grpc/reflection/v1alpha/ya.make src/proto/grpc/testing/ya.make src/python/grpcio/ya.make src/python/grpcio_health_checking/ya.make src/python/grpcio_reflection/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make ya.make - License text: - * Copyright 2016 gRPC authors. - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - include/grpc/grpc_cronet.h [3:3] - include/grpc/grpc_posix.h [3:3] - include/grpc/grpc_security_constants.h [3:3] - include/grpc/impl/codegen/compression_types.h [3:3] - include/grpc/impl/codegen/connectivity_state.h [3:3] - include/grpc/impl/codegen/gpr_slice.h [3:3] - include/grpc/impl/codegen/gpr_types.h [3:3] - include/grpc/impl/codegen/propagation_bits.h [3:3] - include/grpc/impl/codegen/sync.h [3:3] - include/grpcpp/create_channel_posix.h [3:3] - include/grpcpp/ext/health_check_service_server_builder_option.h [3:3] - include/grpcpp/health_check_service_interface.h [3:3] - include/grpcpp/impl/codegen/channel_interface.h [3:3] - include/grpcpp/impl/codegen/config.h [3:3] - include/grpcpp/impl/codegen/core_codegen.h [3:3] - include/grpcpp/impl/codegen/grpc_library.h [3:3] - include/grpcpp/impl/codegen/rpc_service_method.h [3:3] - include/grpcpp/impl/codegen/status.h [3:3] - include/grpcpp/impl/codegen/status_code_enum.h [3:3] - include/grpcpp/impl/rpc_service_method.h [3:3] - include/grpcpp/impl/server_builder_plugin.h [3:3] - include/grpcpp/impl/server_initializer.h [3:3] - include/grpcpp/resource_quota.h [3:3] - include/grpcpp/server_posix.h [3:3] - include/grpcpp/test/server_context_test_spouse.h [3:3] - src/compiler/node_generator.cc [3:3] - src/compiler/node_generator.h [3:3] - src/compiler/node_generator_helpers.h [3:3] - src/compiler/php_generator.cc [3:3] - src/compiler/php_generator_helpers.h [3:3] - src/core/ext/filters/client_channel/http_connect_handshaker.cc [3:3] - src/core/ext/filters/client_channel/http_connect_handshaker.h [3:3] - src/core/ext/filters/client_channel/http_proxy.cc [3:3] - src/core/ext/filters/client_channel/http_proxy.h [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc [2:2] - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc [3:3] - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc [3:3] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc [3:3] - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc [2:2] - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h [2:2] - src/core/ext/filters/deadline/deadline_filter.cc [2:2] - src/core/ext/filters/deadline/deadline_filter.h [2:2] - src/core/ext/filters/message_size/message_size_filter.cc [2:2] - src/core/ext/filters/message_size/message_size_filter.h [2:2] - src/core/ext/service_config/service_config.h [2:2] - src/core/ext/service_config/service_config_call_data.h [2:2] - src/core/ext/service_config/service_config_parser.h [2:2] - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc [3:3] - src/core/ext/transport/chttp2/server/chttp2_server.h [3:3] - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc [3:3] - src/core/ext/transport/chttp2/transport/bin_decoder.cc [3:3] - src/core/ext/transport/chttp2/transport/bin_decoder.h [3:3] - src/core/lib/address_utils/parse_address.cc [3:3] - src/core/lib/address_utils/sockaddr_utils.cc [3:3] - src/core/lib/backoff/backoff.cc [3:3] - src/core/lib/backoff/backoff.h [3:3] - src/core/lib/channel/channel_stack_builder.cc [3:3] - src/core/lib/channel/channel_stack_builder.h [3:3] - src/core/lib/channel/handshaker.cc [3:3] - src/core/lib/channel/handshaker.h [3:3] - src/core/lib/channel/handshaker_factory.h [3:3] - src/core/lib/channel/handshaker_registry.cc [3:3] - src/core/lib/channel/handshaker_registry.h [3:3] - src/core/lib/gpr/string_util_windows.cc [3:3] - src/core/lib/gpr/wrap_memcpy.cc [3:3] - src/core/lib/gprpp/manual_constructor.h [3:3] - src/core/lib/gprpp/mpscq.cc [3:3] - src/core/lib/gprpp/mpscq.h [3:3] - src/core/lib/iomgr/combiner.cc [3:3] - src/core/lib/iomgr/combiner.h [3:3] - src/core/lib/iomgr/endpoint_pair_posix.cc [3:3] - src/core/lib/iomgr/error.cc [3:3] - src/core/lib/iomgr/error.h [3:3] - src/core/lib/iomgr/error_internal.h [3:3] - src/core/lib/iomgr/ev_poll_posix.cc [3:3] - src/core/lib/iomgr/grpc_if_nametoindex_posix.cc [3:3] - src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc [3:3] - src/core/lib/iomgr/polling_entity.cc [3:3] - src/core/lib/iomgr/pollset_set_custom.cc [3:3] - src/core/lib/iomgr/port.h [3:3] - src/core/lib/iomgr/socket_utils_windows.cc [3:3] - src/core/lib/iomgr/timer_generic.h [3:3] - src/core/lib/iomgr/unix_sockets_posix.cc [3:3] - src/core/lib/iomgr/unix_sockets_posix.h [3:3] - src/core/lib/iomgr/unix_sockets_posix_noop.cc [3:3] - src/core/lib/security/credentials/fake/fake_credentials.cc [3:3] - src/core/lib/security/credentials/fake/fake_credentials.h [3:3] - src/core/lib/security/credentials/google_default/credentials_generic.cc [3:3] - src/core/lib/security/credentials/google_default/google_default_credentials.h [3:3] - src/core/lib/security/credentials/iam/iam_credentials.cc [3:3] - src/core/lib/security/credentials/iam/iam_credentials.h [3:3] - src/core/lib/security/credentials/jwt/jwt_credentials.cc [3:3] - src/core/lib/security/credentials/jwt/jwt_credentials.h [3:3] - src/core/lib/security/credentials/oauth2/oauth2_credentials.h [3:3] - src/core/lib/security/credentials/plugin/plugin_credentials.cc [3:3] - src/core/lib/security/credentials/plugin/plugin_credentials.h [3:3] - src/core/lib/security/credentials/ssl/ssl_credentials.cc [3:3] - src/core/lib/security/credentials/ssl/ssl_credentials.h [3:3] - src/core/lib/slice/percent_encoding.cc [3:3] - src/core/lib/slice/percent_encoding.h [3:3] - src/core/lib/slice/slice_intern.cc [3:3] - src/core/lib/slice/slice_internal.h [3:3] - src/core/lib/surface/channel_init.cc [3:3] - src/core/lib/surface/channel_init.h [3:3] - src/core/lib/surface/channel_stack_type.cc [3:3] - src/core/lib/surface/lame_client.h [3:3] - src/core/lib/surface/validate_metadata.cc [3:3] - src/core/lib/transport/bdp_estimator.cc [3:3] - src/core/lib/transport/bdp_estimator.h [3:3] - src/core/lib/transport/error_utils.cc [3:3] - src/core/lib/transport/error_utils.h [3:3] - src/core/lib/transport/pid_controller.cc [3:3] - src/core/lib/transport/pid_controller.h [3:3] - src/core/plugin_registry/grpc_plugin_registry.cc [3:3] - src/core/plugin_registry/grpc_unsecure_plugin_registry.cc [3:3] - src/cpp/client/create_channel_posix.cc [3:3] - src/cpp/codegen/codegen_init.cc [3:3] - src/cpp/common/channel_filter.cc [3:3] - src/cpp/common/channel_filter.h [3:3] - src/cpp/common/core_codegen.cc [3:3] - src/cpp/common/resource_quota_cc.cc [3:3] - src/cpp/common/version_cc.cc [3:3] - src/cpp/ext/proto_server_reflection.cc [3:3] - src/cpp/server/health/default_health_check_service.cc [3:3] - src/cpp/server/health/default_health_check_service.h [3:3] - src/cpp/server/health/health_check_service.cc [3:3] - src/cpp/server/health/health_check_service_server_builder_option.cc [3:3] - src/cpp/server/server_posix.cc [3:3] - src/cpp/thread_manager/thread_manager.cc [3:3] - src/cpp/thread_manager/thread_manager.h [3:3] - src/proto/grpc/reflection/v1alpha/reflection.proto [1:1] - src/proto/grpc/testing/compiler_test.proto [1:1] - src/proto/grpc/testing/proto2/empty2.proto [2:2] - src/proto/grpc/testing/proto2/empty2_extensions.proto [1:1] - src/python/grpcio/_spawn_patch.py [1:1] - src/python/grpcio/grpc/_auth.py [1:1] - src/python/grpcio/grpc/_channel.py [1:1] - src/python/grpcio/grpc/_common.py [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi [1:1] - src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi [1:1] - src/python/grpcio/grpc/_server.py [1:1] - src/python/grpcio/grpc/beta/_client_adaptations.py [1:1] - src/python/grpcio/grpc/beta/_server_adaptations.py [1:1] - src/python/grpcio/support.py [1:1] - src/python/grpcio_health_checking/grpc_version.py [1:1] - src/python/grpcio_reflection/grpc_reflection/__init__.py [1:1] - src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py [1:1] - src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py [1:1] - src/python/grpcio_reflection/grpc_version.py [1:1] - src/python/grpcio_reflection/reflection_commands.py [1:1] - src/python/grpcio_reflection/setup.py [1:1] - src/python/grpcio_tests/grpc_version.py [1:1] - src/python/grpcio_tests/tests/_sanity/__init__.py [1:1] - src/python/grpcio_tests/tests/_sanity/_sanity_test.py [1:1] - src/python/grpcio_tests/tests/health_check/__init__.py [1:1] - src/python/grpcio_tests/tests/health_check/_health_servicer_test.py [1:1] - src/python/grpcio_tests/tests/http2/negative_http2_client.py [1:1] - src/python/grpcio_tests/tests/qps/__init__.py [1:1] - src/python/grpcio_tests/tests/qps/benchmark_client.py [1:1] - src/python/grpcio_tests/tests/qps/benchmark_server.py [1:1] - src/python/grpcio_tests/tests/qps/client_runner.py [1:1] - src/python/grpcio_tests/tests/qps/histogram.py [1:1] - src/python/grpcio_tests/tests/qps/qps_worker.py [1:1] - src/python/grpcio_tests/tests/qps/worker_server.py [1:1] - src/python/grpcio_tests/tests/reflection/__init__.py [1:1] - src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py [1:1] - src/python/grpcio_tests/tests/stress/__init__.py [1:1] - src/python/grpcio_tests/tests/stress/client.py [1:1] - src/python/grpcio_tests/tests/stress/metrics_server.py [1:1] - src/python/grpcio_tests/tests/stress/test_runner.py [1:1] - src/python/grpcio_tests/tests/unit/_api_test.py [1:1] - src/python/grpcio_tests/tests/unit/_auth_test.py [1:1] - src/python/grpcio_tests/tests/unit/_channel_args_test.py [1:1] - src/python/grpcio_tests/tests/unit/_compression_test.py [1:1] - src/python/grpcio_tests/tests/unit/_credentials_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_channel_test.py [1:1] - src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py [1:1] - src/python/grpcio_tests/tests/unit/_empty_message_test.py [1:1] - src/python/grpcio_tests/tests/unit/_exit_scenarios.py [1:1] - src/python/grpcio_tests/tests/unit/_exit_test.py [1:1] - src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py [1:1] - src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py [1:1] - src/python/grpcio_tests/tests/unit/_invocation_defects_test.py [1:1] - src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py [1:1] - src/python/grpcio_tests/tests/unit/_metadata_test.py [1:1] - src/python/grpcio_tests/tests/unit/_rpc_part_1_test.py [1:1] - src/python/grpcio_tests/tests/unit/_rpc_part_2_test.py [1:1] - src/python/grpcio_tests/tests/unit/beta/_implementations_test.py [1:1] - src/python/grpcio_tests/tests/unit/thread_pool.py [1:1] - src/python/grpcio_tests/tests_aio/reflection/__init__.py [1:1] - src/python/grpcio_tests/tests_aio/reflection/reflection_servicer_test.py [1:1] - test/core/util/fuzzer_corpus_test.cc [3:3] - test/core/util/grpc_fuzzer.bzl [1:1] - test/core/util/memory_counters.cc [3:3] - test/core/util/memory_counters.h [3:3] - test/core/util/mock_endpoint.cc [3:3] - test/core/util/mock_endpoint.h [3:3] - test/core/util/one_corpus_entry_fuzzer.cc [3:3] - test/core/util/passthru_endpoint.cc [3:3] - test/core/util/passthru_endpoint.h [3:3] - test/core/util/subprocess_windows.cc [3:3] - test/cpp/end2end/client_lb_end2end_test.cc [3:3] - test/cpp/end2end/filter_end2end_test.cc [3:3] - test/cpp/end2end/health_service_end2end_test.cc [3:3] - test/cpp/end2end/hybrid_end2end_test.cc [3:3] - test/cpp/end2end/proto_server_reflection_test.cc [3:3] - test/cpp/end2end/server_builder_plugin_test.cc [3:3] - test/cpp/end2end/service_config_end2end_test.cc [3:3] - test/cpp/end2end/test_service_impl.cc [3:3] - test/cpp/end2end/test_service_impl.h [3:3] - test/cpp/util/byte_buffer_proto_helper.cc [3:3] - test/cpp/util/byte_buffer_proto_helper.h [3:3] - test/cpp/util/channelz_sampler_test.cc [3:3] - test/cpp/util/cli_credentials.cc [3:3] - test/cpp/util/cli_credentials.h [3:3] - test/cpp/util/config_grpc_cli.h [3:3] - test/cpp/util/grpc_tool.cc [3:3] - test/cpp/util/grpc_tool.h [3:3] - test/cpp/util/grpc_tool_test.cc [3:3] - test/cpp/util/proto_file_parser.cc [3:3] - test/cpp/util/proto_file_parser.h [3:3] - test/cpp/util/proto_reflection_descriptor_database.cc [3:3] - test/cpp/util/proto_reflection_descriptor_database.h [3:3] - test/cpp/util/service_describer.cc [3:3] - test/cpp/util/service_describer.h [3:3] - test/cpp/util/test_credentials_provider.cc [4:4] - test/cpp/util/test_credentials_provider.h [3:3] diff --git a/contrib/libs/grpc/.yandex_meta/devtools.licenses.report b/contrib/libs/grpc/.yandex_meta/devtools.licenses.report deleted file mode 100644 index ace9249d09..0000000000 --- a/contrib/libs/grpc/.yandex_meta/devtools.licenses.report +++ /dev/null @@ -1,2250 +0,0 @@ -# File format ($ symbol means the beginning of a line): -# -# $ # this message -# $ # ======================= -# $ # comments (all commentaries should starts with some number of spaces and # symbol) -# ${action} {license spdx} {license text hash} -# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make -# ${all_file_action} filename -# $ # user commentaries (many lines) -# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) -# ${action} {license spdx} {license text hash} -# $BELONGS ./ya/make/file/relative/path/3/ya.make -# ${all_file_action} filename -# $ # user commentaries -# $ generated description -# $ ... -# -# You can modify action, all_file_action and add commentaries -# Available actions: -# keep - keep license in contrib and use in credits -# skip - skip license -# remove - remove all files with this license -# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file -# -# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) -# We suppose that that files can contain some license info -# Available all file actions: -# FILE_IGNORE - ignore file (do nothing) -# FILE_INCLUDE - include all file data into licenses text file -# ======================= - -SKIP Python-2.0 084da548815188967cad816891b84e50 -BELONGS src/python/grpcio/ya.make - License text: - \# limitations under the License. - """gRPC's Python API.""" - Scancode info: - Original SPDX id: Python-2.0 - Score : 66.67 - Match type : TAG - Links : http://docs.python.org/license.html, http://spdx.org/licenses/Python-2.0, https://spdx.org/licenses/Python-2.0 - Files with this license: - src/python/grpcio/grpc/__init__.py [13:14] - -KEEP BSD-3-Clause 1074fcc8fed6e87c183fda7df379eff5 -BELONGS third_party/upb/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 97.64 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/upb/upb/msg_internal.h [5:25] - -SKIP Apache-2.0 19395e57ad88c62801cecab69fb3a75b -BELONGS src/python/grpcio_tests/ya.make -FILE_INCLUDE LICENSE found in files: src/python/grpcio_tests/setup.py at line 33 -FILE_INCLUDE third_party/address_sorting/LICENSE found in files: src/python/grpcio_tests/setup.py at line 33 -FILE_INCLUDE third_party/upb/LICENSE found in files: src/python/grpcio_tests/setup.py at line 33 - License text: - LICENSE = 'Apache License 2.0' - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : REFERENCE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - src/python/grpcio_tests/setup.py [33:33] - -KEEP BSD-3-Clause 26c9318cf95923719e6a1cbb87990e08 -BELONGS third_party/address_sorting/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 100.00 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/address_sorting/LICENSE [4:26] - -KEEP Apache-2.0 2b42edef8fa55315f34f2370b4715ca9 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : TEXT - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - LICENSE [2:202] - -KEEP Apache-2.0 3160c6dcebc5d43cad9fcfc384380762 -BELONGS src/python/grpcio_health_checking/ya.make src/python/grpcio_reflection/ya.make src/python/grpcio_status/ya.make ya.make - License text: - license='Apache License 2.0', - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : REFERENCE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - src/python/grpcio_admin/setup.py [49:49] - src/python/grpcio_csds/setup.py [50:50] - src/python/grpcio_health_checking/setup.py [95:95] - src/python/grpcio_reflection/setup.py [91:91] - src/python/grpcio_status/setup.py [93:93] - src/python/grpcio_testing/setup.py [72:72] - -KEEP Apache-2.0 3b0ea1fb66390711cb1f160e05b0e2a4 -BELONGS src/core/lib/ya.make src/cpp/common/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make tools/codegen/core/ya.make ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - include/grpc++/alarm.h [5:15] - include/grpc++/channel.h [5:15] - include/grpc++/client_context.h [5:15] - include/grpc++/completion_queue.h [5:15] - include/grpc++/create_channel.h [5:15] - include/grpc++/create_channel_posix.h [5:15] - include/grpc++/ext/health_check_service_server_builder_option.h [5:15] - include/grpc++/ext/proto_server_reflection_plugin.h [5:15] - include/grpc++/generic/async_generic_service.h [5:15] - include/grpc++/generic/generic_stub.h [5:15] - include/grpc++/grpc++.h [5:15] - include/grpc++/health_check_service_interface.h [5:15] - include/grpc++/impl/call.h [5:15] - include/grpc++/impl/channel_argument_option.h [5:15] - include/grpc++/impl/client_unary_call.h [5:15] - include/grpc++/impl/codegen/async_stream.h [5:15] - include/grpc++/impl/codegen/async_unary_call.h [5:15] - include/grpc++/impl/codegen/byte_buffer.h [5:15] - include/grpc++/impl/codegen/call.h [5:15] - include/grpc++/impl/codegen/call_hook.h [5:15] - include/grpc++/impl/codegen/channel_interface.h [5:15] - include/grpc++/impl/codegen/client_context.h [5:15] - include/grpc++/impl/codegen/client_unary_call.h [5:15] - include/grpc++/impl/codegen/completion_queue.h [5:15] - include/grpc++/impl/codegen/completion_queue_tag.h [5:15] - include/grpc++/impl/codegen/config.h [5:15] - include/grpc++/impl/codegen/config_protobuf.h [5:15] - include/grpc++/impl/codegen/core_codegen.h [5:15] - include/grpc++/impl/codegen/core_codegen_interface.h [5:15] - include/grpc++/impl/codegen/create_auth_context.h [5:15] - include/grpc++/impl/codegen/grpc_library.h [5:15] - include/grpc++/impl/codegen/metadata_map.h [5:15] - include/grpc++/impl/codegen/method_handler_impl.h [5:15] - include/grpc++/impl/codegen/proto_utils.h [5:15] - include/grpc++/impl/codegen/rpc_method.h [5:15] - include/grpc++/impl/codegen/rpc_service_method.h [5:15] - include/grpc++/impl/codegen/security/auth_context.h [5:15] - include/grpc++/impl/codegen/serialization_traits.h [5:15] - include/grpc++/impl/codegen/server_context.h [5:15] - include/grpc++/impl/codegen/server_interface.h [5:15] - include/grpc++/impl/codegen/service_type.h [5:15] - include/grpc++/impl/codegen/slice.h [5:15] - include/grpc++/impl/codegen/status.h [5:15] - include/grpc++/impl/codegen/status_code_enum.h [5:15] - include/grpc++/impl/codegen/string_ref.h [5:15] - include/grpc++/impl/codegen/stub_options.h [5:15] - include/grpc++/impl/codegen/sync_stream.h [5:15] - include/grpc++/impl/codegen/time.h [5:15] - include/grpc++/impl/grpc_library.h [5:15] - include/grpc++/impl/method_handler_impl.h [5:15] - include/grpc++/impl/rpc_method.h [5:15] - include/grpc++/impl/rpc_service_method.h [5:15] - include/grpc++/impl/serialization_traits.h [5:15] - include/grpc++/impl/server_builder_option.h [5:15] - include/grpc++/impl/server_builder_plugin.h [5:15] - include/grpc++/impl/server_initializer.h [5:15] - include/grpc++/impl/service_type.h [5:15] - include/grpc++/resource_quota.h [5:15] - include/grpc++/security/auth_context.h [5:15] - include/grpc++/security/auth_metadata_processor.h [5:15] - include/grpc++/security/credentials.h [5:15] - include/grpc++/security/server_credentials.h [5:15] - include/grpc++/server.h [5:15] - include/grpc++/server_builder.h [5:15] - include/grpc++/server_context.h [5:15] - include/grpc++/server_posix.h [5:15] - include/grpc++/support/async_stream.h [5:15] - include/grpc++/support/async_unary_call.h [5:15] - include/grpc++/support/byte_buffer.h [5:15] - include/grpc++/support/channel_arguments.h [5:15] - include/grpc++/support/config.h [5:15] - include/grpc++/support/error_details.h [5:15] - include/grpc++/support/slice.h [5:15] - include/grpc++/support/status.h [5:15] - include/grpc++/support/status_code_enum.h [5:15] - include/grpc++/support/string_ref.h [5:15] - include/grpc++/support/stub_options.h [5:15] - include/grpc++/support/sync_stream.h [5:15] - include/grpc++/support/time.h [5:15] - include/grpc++/test/mock_stream.h [5:15] - include/grpc++/test/server_context_test_spouse.h [5:15] - include/grpc/byte_buffer.h [5:15] - include/grpc/byte_buffer_reader.h [5:15] - include/grpc/census.h [5:15] - include/grpc/compression.h [5:15] - include/grpc/fork.h [5:15] - include/grpc/grpc.h [5:15] - include/grpc/grpc_cronet.h [5:15] - include/grpc/grpc_posix.h [5:15] - include/grpc/grpc_security.h [5:15] - include/grpc/grpc_security_constants.h [5:15] - include/grpc/impl/codegen/atm.h [5:15] - include/grpc/impl/codegen/atm_gcc_atomic.h [5:15] - include/grpc/impl/codegen/atm_gcc_sync.h [5:15] - include/grpc/impl/codegen/atm_windows.h [5:15] - include/grpc/impl/codegen/byte_buffer.h [5:15] - include/grpc/impl/codegen/byte_buffer_reader.h [5:15] - include/grpc/impl/codegen/compression_types.h [5:15] - include/grpc/impl/codegen/connectivity_state.h [5:15] - include/grpc/impl/codegen/fork.h [5:15] - include/grpc/impl/codegen/gpr_slice.h [5:15] - include/grpc/impl/codegen/gpr_types.h [5:15] - include/grpc/impl/codegen/grpc_types.h [5:15] - include/grpc/impl/codegen/log.h [5:15] - include/grpc/impl/codegen/port_platform.h [5:15] - include/grpc/impl/codegen/propagation_bits.h [5:15] - include/grpc/impl/codegen/slice.h [5:15] - include/grpc/impl/codegen/status.h [5:15] - include/grpc/impl/codegen/sync.h [5:15] - include/grpc/impl/codegen/sync_abseil.h [5:15] - include/grpc/impl/codegen/sync_custom.h [5:15] - include/grpc/impl/codegen/sync_generic.h [5:15] - include/grpc/impl/codegen/sync_posix.h [5:15] - include/grpc/impl/codegen/sync_windows.h [5:15] - include/grpc/load_reporting.h [5:15] - include/grpc/slice.h [5:15] - include/grpc/slice_buffer.h [5:15] - include/grpc/status.h [5:15] - include/grpc/support/alloc.h [5:15] - include/grpc/support/atm.h [5:15] - include/grpc/support/atm_gcc_atomic.h [5:15] - include/grpc/support/atm_gcc_sync.h [5:15] - include/grpc/support/atm_windows.h [5:15] - include/grpc/support/cpu.h [5:15] - include/grpc/support/log.h [5:15] - include/grpc/support/log_windows.h [5:15] - include/grpc/support/port_platform.h [5:15] - include/grpc/support/string_util.h [5:15] - include/grpc/support/sync.h [5:15] - include/grpc/support/sync_abseil.h [5:15] - include/grpc/support/sync_custom.h [5:15] - include/grpc/support/sync_generic.h [5:15] - include/grpc/support/sync_posix.h [5:15] - include/grpc/support/sync_windows.h [5:15] - include/grpc/support/thd_id.h [5:15] - include/grpc/support/time.h [5:15] - include/grpc/support/workaround_list.h [5:15] - include/grpcpp/alarm.h [5:15] - include/grpcpp/channel.h [5:15] - include/grpcpp/client_context.h [5:15] - include/grpcpp/completion_queue.h [5:15] - include/grpcpp/create_channel.h [5:15] - include/grpcpp/create_channel_posix.h [5:15] - include/grpcpp/ext/channelz_service_plugin.h [5:15] - include/grpcpp/ext/health_check_service_server_builder_option.h [5:15] - include/grpcpp/ext/proto_server_reflection_plugin.h [5:15] - include/grpcpp/ext/server_load_reporting.h [5:15] - include/grpcpp/generic/async_generic_service.h [5:15] - include/grpcpp/generic/generic_stub.h [5:15] - include/grpcpp/grpcpp.h [5:15] - include/grpcpp/health_check_service_interface.h [5:15] - include/grpcpp/impl/call.h [5:15] - include/grpcpp/impl/channel_argument_option.h [5:15] - include/grpcpp/impl/client_unary_call.h [5:15] - include/grpcpp/impl/codegen/async_generic_service.h [5:15] - include/grpcpp/impl/codegen/async_stream.h [5:15] - include/grpcpp/impl/codegen/async_unary_call.h [5:15] - include/grpcpp/impl/codegen/byte_buffer.h [5:15] - include/grpcpp/impl/codegen/call.h [5:15] - include/grpcpp/impl/codegen/call_hook.h [5:15] - include/grpcpp/impl/codegen/call_op_set.h [5:15] - include/grpcpp/impl/codegen/call_op_set_interface.h [5:15] - include/grpcpp/impl/codegen/callback_common.h [5:15] - include/grpcpp/impl/codegen/channel_interface.h [5:15] - include/grpcpp/impl/codegen/client_callback.h [5:15] - include/grpcpp/impl/codegen/client_context.h [5:15] - include/grpcpp/impl/codegen/client_interceptor.h [5:15] - include/grpcpp/impl/codegen/client_unary_call.h [5:15] - include/grpcpp/impl/codegen/completion_queue.h [5:15] - include/grpcpp/impl/codegen/completion_queue_tag.h [5:15] - include/grpcpp/impl/codegen/config.h [5:15] - include/grpcpp/impl/codegen/config_protobuf.h [5:15] - include/grpcpp/impl/codegen/core_codegen.h [5:15] - include/grpcpp/impl/codegen/core_codegen_interface.h [5:15] - include/grpcpp/impl/codegen/create_auth_context.h [5:15] - include/grpcpp/impl/codegen/delegating_channel.h [5:15] - include/grpcpp/impl/codegen/grpc_library.h [5:15] - include/grpcpp/impl/codegen/intercepted_channel.h [5:15] - include/grpcpp/impl/codegen/interceptor.h [5:15] - include/grpcpp/impl/codegen/interceptor_common.h [5:15] - include/grpcpp/impl/codegen/message_allocator.h [5:15] - include/grpcpp/impl/codegen/metadata_map.h [5:15] - include/grpcpp/impl/codegen/method_handler.h [5:15] - include/grpcpp/impl/codegen/method_handler_impl.h [5:15] - include/grpcpp/impl/codegen/proto_buffer_reader.h [5:15] - include/grpcpp/impl/codegen/proto_buffer_writer.h [5:15] - include/grpcpp/impl/codegen/proto_utils.h [5:15] - include/grpcpp/impl/codegen/rpc_method.h [5:15] - include/grpcpp/impl/codegen/rpc_service_method.h [5:15] - include/grpcpp/impl/codegen/security/auth_context.h [5:15] - include/grpcpp/impl/codegen/serialization_traits.h [5:15] - include/grpcpp/impl/codegen/server_callback.h [5:15] - include/grpcpp/impl/codegen/server_callback_handlers.h [5:15] - include/grpcpp/impl/codegen/server_context.h [5:15] - include/grpcpp/impl/codegen/server_interceptor.h [5:15] - include/grpcpp/impl/codegen/server_interface.h [5:15] - include/grpcpp/impl/codegen/service_type.h [5:15] - include/grpcpp/impl/codegen/slice.h [5:15] - include/grpcpp/impl/codegen/status.h [5:15] - include/grpcpp/impl/codegen/status_code_enum.h [5:15] - include/grpcpp/impl/codegen/string_ref.h [5:15] - include/grpcpp/impl/codegen/stub_options.h [5:15] - include/grpcpp/impl/codegen/sync.h [5:15] - include/grpcpp/impl/codegen/sync_stream.h [5:15] - include/grpcpp/impl/codegen/time.h [5:15] - include/grpcpp/impl/grpc_library.h [5:15] - include/grpcpp/impl/method_handler_impl.h [5:15] - include/grpcpp/impl/rpc_method.h [5:15] - include/grpcpp/impl/rpc_service_method.h [5:15] - include/grpcpp/impl/serialization_traits.h [5:15] - include/grpcpp/impl/server_builder_option.h [5:15] - include/grpcpp/impl/server_builder_plugin.h [5:15] - include/grpcpp/impl/server_initializer.h [5:15] - include/grpcpp/impl/service_type.h [5:15] - include/grpcpp/opencensus.h [5:15] - include/grpcpp/resource_quota.h [5:15] - include/grpcpp/security/alts_context.h [5:15] - include/grpcpp/security/alts_util.h [5:15] - include/grpcpp/security/auth_context.h [5:15] - include/grpcpp/security/auth_metadata_processor.h [5:15] - include/grpcpp/security/credentials.h [5:15] - include/grpcpp/security/cronet_credentials.h [5:15] - include/grpcpp/security/server_credentials.h [5:15] - include/grpcpp/security/tls_credentials_options.h [5:15] - include/grpcpp/server.h [5:15] - include/grpcpp/server_builder.h [5:15] - include/grpcpp/server_context.h [5:15] - include/grpcpp/server_posix.h [5:15] - include/grpcpp/support/async_stream.h [5:15] - include/grpcpp/support/async_unary_call.h [5:15] - include/grpcpp/support/byte_buffer.h [5:15] - include/grpcpp/support/channel_arguments.h [5:15] - include/grpcpp/support/client_callback.h [5:15] - include/grpcpp/support/client_interceptor.h [5:15] - include/grpcpp/support/config.h [5:15] - include/grpcpp/support/error_details.h [5:15] - include/grpcpp/support/interceptor.h [5:15] - include/grpcpp/support/message_allocator.h [5:15] - include/grpcpp/support/method_handler.h [5:15] - include/grpcpp/support/proto_buffer_reader.h [5:15] - include/grpcpp/support/proto_buffer_writer.h [5:15] - include/grpcpp/support/server_callback.h [5:15] - include/grpcpp/support/server_interceptor.h [5:15] - include/grpcpp/support/slice.h [5:15] - include/grpcpp/support/status.h [5:15] - include/grpcpp/support/status_code_enum.h [5:15] - include/grpcpp/support/string_ref.h [5:15] - include/grpcpp/support/stub_options.h [5:15] - include/grpcpp/support/sync_stream.h [5:15] - include/grpcpp/support/time.h [5:15] - include/grpcpp/support/validate_service_config.h [5:15] - include/grpcpp/test/channel_test_peer.h [5:15] - include/grpcpp/test/client_context_test_peer.h [5:15] - include/grpcpp/test/default_reactor_test_peer.h [5:15] - include/grpcpp/test/mock_stream.h [5:15] - include/grpcpp/test/server_context_test_spouse.h [5:15] - src/compiler/config.h [5:15] - src/compiler/config_protobuf.h [5:15] - src/compiler/cpp_generator.cc [5:15] - src/compiler/cpp_generator.h [5:15] - src/compiler/cpp_generator_helpers.h [5:15] - src/compiler/cpp_plugin.cc [5:15] - src/compiler/cpp_plugin.h [5:15] - src/compiler/csharp_generator.cc [5:15] - src/compiler/csharp_generator.h [5:15] - src/compiler/csharp_generator_helpers.h [5:15] - src/compiler/generator_helpers.h [5:15] - src/compiler/node_generator.cc [5:15] - src/compiler/node_generator.h [5:15] - src/compiler/node_generator_helpers.h [5:15] - src/compiler/objective_c_generator.cc [5:15] - src/compiler/objective_c_generator.h [5:15] - src/compiler/objective_c_generator_helpers.h [5:15] - src/compiler/php_generator.cc [5:15] - src/compiler/php_generator_helpers.h [5:15] - src/compiler/protobuf_plugin.h [5:15] - src/compiler/python_generator.cc [5:15] - src/compiler/python_generator.h [5:15] - src/compiler/python_generator_helpers.h [5:15] - src/compiler/python_plugin.cc [5:15] - src/compiler/python_private_generator.h [5:15] - src/compiler/ruby_generator.cc [5:15] - src/compiler/ruby_generator.h [5:15] - src/compiler/ruby_generator_helpers-inl.h [5:15] - src/compiler/ruby_generator_map-inl.h [5:15] - src/compiler/ruby_generator_string-inl.h [5:15] - src/compiler/schema_interface.h [5:15] - src/core/ext/filters/census/grpc_context.cc [5:15] - src/core/ext/filters/client_channel/backup_poller.cc [5:15] - src/core/ext/filters/client_channel/backup_poller.h [5:15] - src/core/ext/filters/client_channel/client_channel_channelz.cc [5:15] - src/core/ext/filters/client_channel/client_channel_channelz.h [5:15] - src/core/ext/filters/client_channel/client_channel_factory.cc [5:15] - src/core/ext/filters/client_channel/client_channel_plugin.cc [5:15] - src/core/ext/filters/client_channel/global_subchannel_pool.h [5:15] - src/core/ext/filters/client_channel/health/health_check_client.cc [5:15] - src/core/ext/filters/client_channel/health/health_check_client.h [5:15] - src/core/ext/filters/client_channel/http_connect_handshaker.cc [5:15] - src/core/ext/filters/client_channel/http_connect_handshaker.h [5:15] - src/core/ext/filters/client_channel/http_proxy.cc [5:15] - src/core/ext/filters/client_channel/http_proxy.h [5:15] - src/core/ext/filters/client_channel/lb_policy.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h [5:15] - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc [5:15] - src/core/ext/filters/client_channel/lb_policy/subchannel_list.h [5:15] - src/core/ext/filters/client_channel/lb_policy_factory.h [5:15] - src/core/ext/filters/client_channel/lb_policy_registry.cc [5:15] - src/core/ext/filters/client_channel/lb_policy_registry.h [5:15] - src/core/ext/filters/client_channel/local_subchannel_pool.h [5:15] - src/core/ext/filters/client_channel/proxy_mapper.h [5:15] - src/core/ext/filters/client_channel/proxy_mapper_registry.cc [5:15] - src/core/ext/filters/client_channel/proxy_mapper_registry.h [5:15] - src/core/ext/filters/client_channel/resolver.cc [5:15] - src/core/ext/filters/client_channel/resolver.h [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc [5:15] - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h [5:15] - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc [5:15] - src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc [5:15] - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc [5:15] - src/core/ext/filters/client_channel/resolver_factory.h [5:15] - src/core/ext/filters/client_channel/resolver_registry.cc [5:15] - src/core/ext/filters/client_channel/resolver_registry.h [5:15] - src/core/ext/filters/client_channel/retry_throttle.cc [5:15] - src/core/ext/filters/client_channel/retry_throttle.h [5:15] - src/core/ext/filters/client_channel/server_address.cc [5:15] - src/core/ext/filters/client_channel/server_address.h [5:15] - src/core/ext/filters/client_channel/subchannel_interface.h [5:15] - src/core/ext/filters/client_channel/subchannel_pool_interface.h [5:15] - src/core/ext/filters/client_idle/client_idle_filter.cc [5:15] - src/core/ext/filters/http/client/http_client_filter.cc [4:14] - src/core/ext/filters/http/client/http_client_filter.h [4:14] - src/core/ext/filters/http/client_authority_filter.cc [5:15] - src/core/ext/filters/http/client_authority_filter.h [5:15] - src/core/ext/filters/http/http_filters_plugin.cc [5:15] - src/core/ext/filters/http/message_compress/message_compress_filter.cc [5:15] - src/core/ext/filters/http/message_compress/message_compress_filter.h [5:15] - src/core/ext/filters/http/server/http_server_filter.cc [5:15] - src/core/ext/filters/http/server/http_server_filter.h [5:15] - src/core/ext/filters/max_age/max_age_filter.cc [5:15] - src/core/ext/transport/chttp2/alpn/alpn.cc [5:15] - src/core/ext/transport/chttp2/alpn/alpn.h [5:15] - src/core/ext/transport/chttp2/client/chttp2_connector.cc [5:15] - src/core/ext/transport/chttp2/client/chttp2_connector.h [5:15] - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc [5:15] - src/core/ext/transport/chttp2/server/chttp2_server.cc [5:15] - src/core/ext/transport/chttp2/server/chttp2_server.h [5:15] - src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc [5:15] - src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc [5:15] - src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc [5:15] - src/core/ext/transport/chttp2/transport/bin_decoder.cc [5:15] - src/core/ext/transport/chttp2/transport/bin_decoder.h [5:15] - src/core/ext/transport/chttp2/transport/bin_encoder.cc [5:15] - src/core/ext/transport/chttp2/transport/bin_encoder.h [5:15] - src/core/ext/transport/chttp2/transport/chttp2_plugin.cc [5:15] - src/core/ext/transport/chttp2/transport/chttp2_transport.h [5:15] - src/core/ext/transport/chttp2/transport/context_list.cc [5:15] - src/core/ext/transport/chttp2/transport/context_list.h [5:15] - src/core/ext/transport/chttp2/transport/flow_control.cc [5:15] - src/core/ext/transport/chttp2/transport/flow_control.h [5:15] - src/core/ext/transport/chttp2/transport/frame.h [5:15] - src/core/ext/transport/chttp2/transport/frame_data.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_data.h [5:15] - src/core/ext/transport/chttp2/transport/frame_goaway.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_goaway.h [5:15] - src/core/ext/transport/chttp2/transport/frame_ping.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_ping.h [5:15] - src/core/ext/transport/chttp2/transport/frame_rst_stream.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_rst_stream.h [5:15] - src/core/ext/transport/chttp2/transport/frame_settings.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_settings.h [5:15] - src/core/ext/transport/chttp2/transport/frame_window_update.cc [5:15] - src/core/ext/transport/chttp2/transport/frame_window_update.h [5:15] - src/core/ext/transport/chttp2/transport/hpack_encoder.cc [5:15] - src/core/ext/transport/chttp2/transport/hpack_encoder.h [5:15] - src/core/ext/transport/chttp2/transport/hpack_parser.cc [5:15] - src/core/ext/transport/chttp2/transport/hpack_parser.h [5:15] - src/core/ext/transport/chttp2/transport/hpack_parser_table.cc [5:15] - src/core/ext/transport/chttp2/transport/hpack_parser_table.h [5:15] - src/core/ext/transport/chttp2/transport/http2_settings.cc [4:14] - src/core/ext/transport/chttp2/transport/http2_settings.h [4:14] - src/core/ext/transport/chttp2/transport/huffsyms.cc [5:15] - src/core/ext/transport/chttp2/transport/huffsyms.h [5:15] - src/core/ext/transport/chttp2/transport/internal.h [5:15] - src/core/ext/transport/chttp2/transport/parsing.cc [5:15] - src/core/ext/transport/chttp2/transport/stream_lists.cc [5:15] - src/core/ext/transport/chttp2/transport/stream_map.cc [5:15] - src/core/ext/transport/chttp2/transport/stream_map.h [5:15] - src/core/ext/transport/chttp2/transport/varint.cc [5:15] - src/core/ext/transport/chttp2/transport/varint.h [5:15] - src/core/ext/transport/chttp2/transport/writing.cc [5:15] - src/core/ext/transport/inproc/inproc_plugin.cc [5:15] - src/core/ext/transport/inproc/inproc_transport.cc [5:15] - src/core/ext/transport/inproc/inproc_transport.h [5:15] - src/core/ext/xds/xds_api.h [5:15] - src/core/ext/xds/xds_client_stats.cc [5:15] - src/core/ext/xds/xds_client_stats.h [5:15] - src/core/lib/address_utils/parse_address.cc [5:15] - src/core/lib/address_utils/parse_address.h [5:15] - src/core/lib/address_utils/sockaddr_utils.cc [5:15] - src/core/lib/address_utils/sockaddr_utils.h [5:15] - src/core/lib/backoff/backoff.cc [5:15] - src/core/lib/backoff/backoff.h [5:15] - src/core/lib/channel/channel_args.cc [5:15] - src/core/lib/channel/channel_args.h [5:15] - src/core/lib/channel/channel_stack.cc [5:15] - src/core/lib/channel/channel_stack.h [5:15] - src/core/lib/channel/channel_stack_builder.cc [5:15] - src/core/lib/channel/channel_stack_builder.h [5:15] - src/core/lib/channel/channel_trace.cc [5:15] - src/core/lib/channel/channel_trace.h [5:15] - src/core/lib/channel/channelz.cc [5:15] - src/core/lib/channel/channelz.h [5:15] - src/core/lib/channel/channelz_registry.cc [5:15] - src/core/lib/channel/channelz_registry.h [5:15] - src/core/lib/channel/connected_channel.cc [5:15] - src/core/lib/channel/connected_channel.h [5:15] - src/core/lib/channel/context.h [5:15] - src/core/lib/channel/handshaker.cc [5:15] - src/core/lib/channel/handshaker.h [5:15] - src/core/lib/channel/handshaker_factory.h [5:15] - src/core/lib/channel/handshaker_registry.cc [5:15] - src/core/lib/channel/handshaker_registry.h [5:15] - src/core/lib/channel/status_util.cc [5:15] - src/core/lib/channel/status_util.h [5:15] - src/core/lib/compression/algorithm_metadata.h [5:15] - src/core/lib/compression/compression.cc [5:15] - src/core/lib/compression/compression_args.cc [5:15] - src/core/lib/compression/compression_args.h [5:15] - src/core/lib/compression/compression_internal.cc [5:15] - src/core/lib/compression/compression_internal.h [5:15] - src/core/lib/compression/message_compress.cc [5:15] - src/core/lib/compression/message_compress.h [5:15] - src/core/lib/compression/stream_compression.cc [5:15] - src/core/lib/compression/stream_compression.h [5:15] - src/core/lib/compression/stream_compression_gzip.cc [5:15] - src/core/lib/compression/stream_compression_gzip.h [5:15] - src/core/lib/compression/stream_compression_identity.cc [5:15] - src/core/lib/compression/stream_compression_identity.h [5:15] - src/core/lib/debug/stats.cc [5:15] - src/core/lib/debug/stats.h [5:15] - src/core/lib/debug/stats_data.cc [4:14] - src/core/lib/debug/stats_data.h [4:14] - src/core/lib/debug/trace.cc [5:15] - src/core/lib/debug/trace.h [5:15] - src/core/lib/gpr/alloc.cc [5:15] - src/core/lib/gpr/alloc.h [5:15] - src/core/lib/gpr/atm.cc [5:15] - src/core/lib/gpr/cpu_iphone.cc [5:15] - src/core/lib/gpr/cpu_linux.cc [5:15] - src/core/lib/gpr/cpu_posix.cc [5:15] - src/core/lib/gpr/cpu_windows.cc [5:15] - src/core/lib/gpr/env.h [5:15] - src/core/lib/gpr/env_linux.cc [5:15] - src/core/lib/gpr/env_posix.cc [5:15] - src/core/lib/gpr/env_windows.cc [5:15] - src/core/lib/gpr/log.cc [5:15] - src/core/lib/gpr/log_android.cc [5:15] - src/core/lib/gpr/log_linux.cc [5:15] - src/core/lib/gpr/log_posix.cc [5:15] - src/core/lib/gpr/log_windows.cc [5:15] - src/core/lib/gpr/murmur_hash.cc [5:15] - src/core/lib/gpr/murmur_hash.h [5:15] - src/core/lib/gpr/spinlock.h [5:15] - src/core/lib/gpr/string.cc [5:15] - src/core/lib/gpr/string.h [5:15] - src/core/lib/gpr/string_posix.cc [5:15] - src/core/lib/gpr/string_util_windows.cc [5:15] - src/core/lib/gpr/string_windows.cc [5:15] - src/core/lib/gpr/string_windows.h [5:15] - src/core/lib/gpr/sync.cc [5:15] - src/core/lib/gpr/sync_abseil.cc [5:15] - src/core/lib/gpr/sync_posix.cc [5:15] - src/core/lib/gpr/sync_windows.cc [5:15] - src/core/lib/gpr/time.cc [5:15] - src/core/lib/gpr/time_posix.cc [5:15] - src/core/lib/gpr/time_precise.cc [5:15] - src/core/lib/gpr/time_precise.h [5:15] - src/core/lib/gpr/time_windows.cc [5:15] - src/core/lib/gpr/tls.h [5:15] - src/core/lib/gpr/tmpfile.h [5:15] - src/core/lib/gpr/tmpfile_msys.cc [5:15] - src/core/lib/gpr/tmpfile_posix.cc [5:15] - src/core/lib/gpr/tmpfile_windows.cc [5:15] - src/core/lib/gpr/useful.h [5:15] - src/core/lib/gpr/wrap_memcpy.cc [5:15] - src/core/lib/gprpp/arena.cc [5:15] - src/core/lib/gprpp/arena.h [5:15] - src/core/lib/gprpp/atomic_utils.h [5:15] - src/core/lib/gprpp/debug_location.h [5:15] - src/core/lib/gprpp/examine_stack.cc [5:15] - src/core/lib/gprpp/examine_stack.h [5:15] - src/core/lib/gprpp/fork.cc [5:15] - src/core/lib/gprpp/fork.h [5:15] - src/core/lib/gprpp/global_config.h [5:15] - src/core/lib/gprpp/global_config_custom.h [5:15] - src/core/lib/gprpp/global_config_env.cc [5:15] - src/core/lib/gprpp/global_config_env.h [5:15] - src/core/lib/gprpp/global_config_generic.h [5:15] - src/core/lib/gprpp/host_port.cc [5:15] - src/core/lib/gprpp/host_port.h [5:15] - src/core/lib/gprpp/manual_constructor.h [5:15] - src/core/lib/gprpp/memory.h [5:15] - src/core/lib/gprpp/mpscq.cc [5:15] - src/core/lib/gprpp/mpscq.h [5:15] - src/core/lib/gprpp/orphanable.h [5:15] - src/core/lib/gprpp/ref_counted.h [5:15] - src/core/lib/gprpp/ref_counted_ptr.h [5:15] - src/core/lib/gprpp/sync.h [5:15] - src/core/lib/gprpp/thd.h [5:15] - src/core/lib/gprpp/thd_posix.cc [5:15] - src/core/lib/gprpp/thd_windows.cc [5:15] - src/core/lib/http/format_request.cc [5:15] - src/core/lib/http/format_request.h [5:15] - src/core/lib/http/httpcli.cc [5:15] - src/core/lib/http/httpcli.h [5:15] - src/core/lib/http/httpcli_security_connector.cc [5:15] - src/core/lib/http/parser.cc [5:15] - src/core/lib/http/parser.h [5:15] - src/core/lib/iomgr/block_annotate.h [5:15] - src/core/lib/iomgr/buffer_list.cc [5:15] - src/core/lib/iomgr/buffer_list.h [5:15] - src/core/lib/iomgr/call_combiner.cc [5:15] - src/core/lib/iomgr/call_combiner.h [5:15] - src/core/lib/iomgr/cfstream_handle.cc [5:15] - src/core/lib/iomgr/cfstream_handle.h [5:15] - src/core/lib/iomgr/closure.h [5:15] - src/core/lib/iomgr/combiner.cc [5:15] - src/core/lib/iomgr/combiner.h [5:15] - src/core/lib/iomgr/dualstack_socket_posix.cc [5:15] - src/core/lib/iomgr/dynamic_annotations.h [5:15] - src/core/lib/iomgr/endpoint.cc [5:15] - src/core/lib/iomgr/endpoint.h [5:15] - src/core/lib/iomgr/endpoint_cfstream.cc [5:15] - src/core/lib/iomgr/endpoint_cfstream.h [5:15] - src/core/lib/iomgr/endpoint_pair.h [5:15] - src/core/lib/iomgr/endpoint_pair_posix.cc [5:15] - src/core/lib/iomgr/endpoint_pair_windows.cc [5:15] - src/core/lib/iomgr/error.cc [5:15] - src/core/lib/iomgr/error.h [5:15] - src/core/lib/iomgr/error_cfstream.cc [5:15] - src/core/lib/iomgr/error_cfstream.h [5:15] - src/core/lib/iomgr/error_internal.h [5:15] - src/core/lib/iomgr/ev_apple.cc [5:15] - src/core/lib/iomgr/ev_apple.h [5:15] - src/core/lib/iomgr/ev_epoll1_linux.cc [5:15] - src/core/lib/iomgr/ev_epoll1_linux.h [5:15] - src/core/lib/iomgr/ev_epollex_linux.cc [5:15] - src/core/lib/iomgr/ev_epollex_linux.h [5:15] - src/core/lib/iomgr/ev_poll_posix.cc [5:15] - src/core/lib/iomgr/ev_poll_posix.h [5:15] - src/core/lib/iomgr/ev_posix.cc [5:15] - src/core/lib/iomgr/ev_posix.h [5:15] - src/core/lib/iomgr/ev_windows.cc [5:15] - src/core/lib/iomgr/exec_ctx.cc [5:15] - src/core/lib/iomgr/exec_ctx.h [5:15] - src/core/lib/iomgr/executor.cc [5:15] - src/core/lib/iomgr/executor.h [5:15] - src/core/lib/iomgr/executor/mpmcqueue.cc [5:15] - src/core/lib/iomgr/executor/mpmcqueue.h [5:15] - src/core/lib/iomgr/executor/threadpool.cc [5:15] - src/core/lib/iomgr/executor/threadpool.h [5:15] - src/core/lib/iomgr/fork_posix.cc [5:15] - src/core/lib/iomgr/fork_windows.cc [5:15] - src/core/lib/iomgr/gethostname.h [5:15] - src/core/lib/iomgr/gethostname_fallback.cc [5:15] - src/core/lib/iomgr/gethostname_host_name_max.cc [5:15] - src/core/lib/iomgr/gethostname_sysconf.cc [5:15] - src/core/lib/iomgr/grpc_if_nametoindex.h [5:15] - src/core/lib/iomgr/grpc_if_nametoindex_posix.cc [5:15] - src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc [5:15] - src/core/lib/iomgr/internal_errqueue.cc [5:15] - src/core/lib/iomgr/internal_errqueue.h [5:15] - src/core/lib/iomgr/iocp_windows.cc [5:15] - src/core/lib/iomgr/iocp_windows.h [5:15] - src/core/lib/iomgr/iomgr.cc [5:15] - src/core/lib/iomgr/iomgr.h [5:15] - src/core/lib/iomgr/iomgr_custom.cc [5:15] - src/core/lib/iomgr/iomgr_custom.h [5:15] - src/core/lib/iomgr/iomgr_internal.cc [5:15] - src/core/lib/iomgr/iomgr_internal.h [5:15] - src/core/lib/iomgr/iomgr_posix.cc [5:15] - src/core/lib/iomgr/iomgr_posix_cfstream.cc [5:15] - src/core/lib/iomgr/iomgr_windows.cc [5:15] - src/core/lib/iomgr/is_epollexclusive_available.cc [5:15] - src/core/lib/iomgr/is_epollexclusive_available.h [5:15] - src/core/lib/iomgr/load_file.cc [5:15] - src/core/lib/iomgr/load_file.h [5:15] - src/core/lib/iomgr/lockfree_event.cc [5:15] - src/core/lib/iomgr/lockfree_event.h [5:15] - src/core/lib/iomgr/nameser.h [5:15] - src/core/lib/iomgr/polling_entity.cc [5:15] - src/core/lib/iomgr/polling_entity.h [5:15] - src/core/lib/iomgr/pollset.cc [5:15] - src/core/lib/iomgr/pollset.h [5:15] - src/core/lib/iomgr/pollset_custom.cc [5:15] - src/core/lib/iomgr/pollset_custom.h [5:15] - src/core/lib/iomgr/pollset_set.cc [5:15] - src/core/lib/iomgr/pollset_set.h [5:15] - src/core/lib/iomgr/pollset_set_custom.cc [5:15] - src/core/lib/iomgr/pollset_set_custom.h [5:15] - src/core/lib/iomgr/pollset_set_windows.cc [5:15] - src/core/lib/iomgr/pollset_set_windows.h [5:15] - src/core/lib/iomgr/pollset_windows.cc [5:15] - src/core/lib/iomgr/pollset_windows.h [5:15] - src/core/lib/iomgr/port.h [5:15] - src/core/lib/iomgr/python_util.h [5:15] - src/core/lib/iomgr/resolve_address.cc [5:15] - src/core/lib/iomgr/resolve_address.h [5:15] - src/core/lib/iomgr/resolve_address_custom.cc [5:15] - src/core/lib/iomgr/resolve_address_custom.h [5:15] - src/core/lib/iomgr/resolve_address_posix.cc [5:15] - src/core/lib/iomgr/resolve_address_windows.cc [5:15] - src/core/lib/iomgr/sockaddr.h [5:15] - src/core/lib/iomgr/sockaddr_posix.h [5:15] - src/core/lib/iomgr/sockaddr_windows.h [5:15] - src/core/lib/iomgr/socket_factory_posix.cc [5:15] - src/core/lib/iomgr/socket_factory_posix.h [5:15] - src/core/lib/iomgr/socket_mutator.cc [5:15] - src/core/lib/iomgr/socket_mutator.h [5:15] - src/core/lib/iomgr/socket_utils.h [5:15] - src/core/lib/iomgr/socket_utils_common_posix.cc [5:15] - src/core/lib/iomgr/socket_utils_linux.cc [5:15] - src/core/lib/iomgr/socket_utils_posix.cc [5:15] - src/core/lib/iomgr/socket_utils_posix.h [5:15] - src/core/lib/iomgr/socket_utils_windows.cc [5:15] - src/core/lib/iomgr/socket_windows.cc [5:15] - src/core/lib/iomgr/socket_windows.h [5:15] - src/core/lib/iomgr/sys_epoll_wrapper.h [5:15] - src/core/lib/iomgr/tcp_client.cc [5:15] - src/core/lib/iomgr/tcp_client.h [5:15] - src/core/lib/iomgr/tcp_client_cfstream.cc [6:16] - src/core/lib/iomgr/tcp_client_custom.cc [5:15] - src/core/lib/iomgr/tcp_client_posix.cc [5:15] - src/core/lib/iomgr/tcp_client_posix.h [5:15] - src/core/lib/iomgr/tcp_client_windows.cc [5:15] - src/core/lib/iomgr/tcp_custom.cc [5:15] - src/core/lib/iomgr/tcp_custom.h [5:15] - src/core/lib/iomgr/tcp_posix.cc [5:15] - src/core/lib/iomgr/tcp_posix.h [5:15] - src/core/lib/iomgr/tcp_server.cc [5:15] - src/core/lib/iomgr/tcp_server.h [5:15] - src/core/lib/iomgr/tcp_server_custom.cc [5:15] - src/core/lib/iomgr/tcp_server_posix.cc [5:15] - src/core/lib/iomgr/tcp_server_utils_posix.h [5:15] - src/core/lib/iomgr/tcp_server_utils_posix_common.cc [5:15] - src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc [5:15] - src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc [5:15] - src/core/lib/iomgr/tcp_server_windows.cc [5:15] - src/core/lib/iomgr/tcp_windows.cc [5:15] - src/core/lib/iomgr/tcp_windows.h [5:15] - src/core/lib/iomgr/time_averaged_stats.cc [5:15] - src/core/lib/iomgr/time_averaged_stats.h [5:15] - src/core/lib/iomgr/timer.cc [5:15] - src/core/lib/iomgr/timer.h [5:15] - src/core/lib/iomgr/timer_custom.cc [5:15] - src/core/lib/iomgr/timer_custom.h [5:15] - src/core/lib/iomgr/timer_generic.cc [5:15] - src/core/lib/iomgr/timer_generic.h [5:15] - src/core/lib/iomgr/timer_heap.cc [5:15] - src/core/lib/iomgr/timer_heap.h [5:15] - src/core/lib/iomgr/timer_manager.cc [5:15] - src/core/lib/iomgr/timer_manager.h [5:15] - src/core/lib/iomgr/unix_sockets_posix.cc [5:15] - src/core/lib/iomgr/unix_sockets_posix.h [5:15] - src/core/lib/iomgr/unix_sockets_posix_noop.cc [5:15] - src/core/lib/iomgr/wakeup_fd_eventfd.cc [5:15] - src/core/lib/iomgr/wakeup_fd_nospecial.cc [5:15] - src/core/lib/iomgr/wakeup_fd_pipe.cc [5:15] - src/core/lib/iomgr/wakeup_fd_pipe.h [5:15] - src/core/lib/iomgr/wakeup_fd_posix.cc [5:15] - src/core/lib/iomgr/wakeup_fd_posix.h [5:15] - src/core/lib/iomgr/work_serializer.cc [5:15] - src/core/lib/iomgr/work_serializer.h [5:15] - src/core/lib/json/json.h [5:15] - src/core/lib/json/json_reader.cc [5:15] - src/core/lib/json/json_writer.cc [5:15] - src/core/lib/profiling/basic_timers.cc [5:15] - src/core/lib/profiling/stap_timers.cc [5:15] - src/core/lib/profiling/timers.h [5:15] - src/core/lib/promise/detail/switch.h [4:14] - src/core/lib/security/context/security_context.cc [5:15] - src/core/lib/security/context/security_context.h [5:15] - src/core/lib/security/credentials/alts/alts_credentials.cc [5:15] - src/core/lib/security/credentials/alts/alts_credentials.h [5:15] - src/core/lib/security/credentials/alts/check_gcp_environment.cc [5:15] - src/core/lib/security/credentials/alts/check_gcp_environment.h [5:15] - src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc [5:15] - src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc [5:15] - src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc [5:15] - src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc [5:15] - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc [5:15] - src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h [5:15] - src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc [5:15] - src/core/lib/security/credentials/composite/composite_credentials.cc [5:15] - src/core/lib/security/credentials/composite/composite_credentials.h [5:15] - src/core/lib/security/credentials/credentials.cc [5:15] - src/core/lib/security/credentials/credentials.h [5:15] - src/core/lib/security/credentials/credentials_metadata.cc [5:15] - src/core/lib/security/credentials/fake/fake_credentials.cc [5:15] - src/core/lib/security/credentials/fake/fake_credentials.h [5:15] - src/core/lib/security/credentials/google_default/credentials_generic.cc [5:15] - src/core/lib/security/credentials/google_default/google_default_credentials.cc [5:15] - src/core/lib/security/credentials/google_default/google_default_credentials.h [5:15] - src/core/lib/security/credentials/iam/iam_credentials.cc [5:15] - src/core/lib/security/credentials/iam/iam_credentials.h [5:15] - src/core/lib/security/credentials/jwt/json_token.cc [5:15] - src/core/lib/security/credentials/jwt/json_token.h [5:15] - src/core/lib/security/credentials/jwt/jwt_credentials.cc [5:15] - src/core/lib/security/credentials/jwt/jwt_credentials.h [5:15] - src/core/lib/security/credentials/jwt/jwt_verifier.cc [5:15] - src/core/lib/security/credentials/jwt/jwt_verifier.h [5:15] - src/core/lib/security/credentials/local/local_credentials.cc [5:15] - src/core/lib/security/credentials/local/local_credentials.h [5:15] - src/core/lib/security/credentials/oauth2/oauth2_credentials.cc [5:15] - src/core/lib/security/credentials/oauth2/oauth2_credentials.h [5:15] - src/core/lib/security/credentials/plugin/plugin_credentials.cc [5:15] - src/core/lib/security/credentials/plugin/plugin_credentials.h [5:15] - src/core/lib/security/credentials/ssl/ssl_credentials.cc [5:15] - src/core/lib/security/credentials/ssl/ssl_credentials.h [5:15] - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc [5:15] - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h [5:15] - src/core/lib/security/credentials/tls/tls_credentials.cc [5:15] - src/core/lib/security/credentials/tls/tls_credentials.h [5:15] - src/core/lib/security/security_connector/alts/alts_security_connector.cc [5:15] - src/core/lib/security/security_connector/alts/alts_security_connector.h [5:15] - src/core/lib/security/security_connector/fake/fake_security_connector.cc [5:15] - src/core/lib/security/security_connector/fake/fake_security_connector.h [5:15] - src/core/lib/security/security_connector/load_system_roots.h [5:15] - src/core/lib/security/security_connector/load_system_roots_fallback.cc [5:15] - src/core/lib/security/security_connector/load_system_roots_linux.cc [5:15] - src/core/lib/security/security_connector/load_system_roots_linux.h [5:15] - src/core/lib/security/security_connector/local/local_security_connector.cc [5:15] - src/core/lib/security/security_connector/local/local_security_connector.h [5:15] - src/core/lib/security/security_connector/security_connector.cc [5:15] - src/core/lib/security/security_connector/security_connector.h [5:15] - src/core/lib/security/security_connector/ssl/ssl_security_connector.cc [5:15] - src/core/lib/security/security_connector/ssl/ssl_security_connector.h [5:15] - src/core/lib/security/security_connector/ssl_utils.cc [5:15] - src/core/lib/security/security_connector/ssl_utils.h [5:15] - src/core/lib/security/security_connector/ssl_utils_config.cc [5:15] - src/core/lib/security/security_connector/ssl_utils_config.h [5:15] - src/core/lib/security/security_connector/tls/tls_security_connector.cc [5:15] - src/core/lib/security/security_connector/tls/tls_security_connector.h [5:15] - src/core/lib/security/transport/auth_filters.h [5:15] - src/core/lib/security/transport/client_auth_filter.cc [5:15] - src/core/lib/security/transport/secure_endpoint.cc [5:15] - src/core/lib/security/transport/secure_endpoint.h [5:15] - src/core/lib/security/transport/security_handshaker.cc [5:15] - src/core/lib/security/transport/security_handshaker.h [5:15] - src/core/lib/security/transport/server_auth_filter.cc [5:15] - src/core/lib/security/transport/tsi_error.cc [5:15] - src/core/lib/security/transport/tsi_error.h [5:15] - src/core/lib/security/util/json_util.cc [5:15] - src/core/lib/security/util/json_util.h [5:15] - src/core/lib/slice/b64.cc [5:15] - src/core/lib/slice/b64.h [5:15] - src/core/lib/slice/percent_encoding.cc [5:15] - src/core/lib/slice/percent_encoding.h [5:15] - src/core/lib/slice/slice.cc [5:15] - src/core/lib/slice/slice_api.cc [5:15] - src/core/lib/slice/slice_buffer.cc [5:15] - src/core/lib/slice/slice_intern.cc [5:15] - src/core/lib/slice/slice_internal.h [5:15] - src/core/lib/slice/slice_split.h [5:15] - src/core/lib/slice/slice_string_helpers.cc [5:15] - src/core/lib/slice/slice_string_helpers.h [5:15] - src/core/lib/slice/slice_utils.h [5:15] - src/core/lib/slice/static_slice.cc [4:14] - src/core/lib/slice/static_slice.h [4:14] - src/core/lib/surface/api_trace.cc [5:15] - src/core/lib/surface/api_trace.h [5:15] - src/core/lib/surface/byte_buffer.cc [5:15] - src/core/lib/surface/byte_buffer_reader.cc [5:15] - src/core/lib/surface/call.cc [5:15] - src/core/lib/surface/call.h [5:15] - src/core/lib/surface/call_details.cc [5:15] - src/core/lib/surface/call_log_batch.cc [5:15] - src/core/lib/surface/call_test_only.h [5:15] - src/core/lib/surface/channel.cc [5:15] - src/core/lib/surface/channel.h [5:15] - src/core/lib/surface/channel_init.cc [5:15] - src/core/lib/surface/channel_init.h [5:15] - src/core/lib/surface/channel_ping.cc [5:15] - src/core/lib/surface/channel_stack_type.cc [5:15] - src/core/lib/surface/channel_stack_type.h [5:15] - src/core/lib/surface/completion_queue.cc [5:15] - src/core/lib/surface/completion_queue.h [5:15] - src/core/lib/surface/completion_queue_factory.cc [5:15] - src/core/lib/surface/completion_queue_factory.h [5:15] - src/core/lib/surface/event_string.cc [5:15] - src/core/lib/surface/event_string.h [5:15] - src/core/lib/surface/init.cc [5:15] - src/core/lib/surface/init.h [5:15] - src/core/lib/surface/init_secure.cc [5:15] - src/core/lib/surface/init_unsecure.cc [5:15] - src/core/lib/surface/lame_client.cc [5:15] - src/core/lib/surface/lame_client.h [5:15] - src/core/lib/surface/metadata_array.cc [5:15] - src/core/lib/surface/validate_metadata.cc [5:15] - src/core/lib/surface/validate_metadata.h [5:15] - src/core/lib/surface/version.cc [5:15] - src/core/lib/transport/bdp_estimator.cc [5:15] - src/core/lib/transport/bdp_estimator.h [5:15] - src/core/lib/transport/byte_stream.cc [5:15] - src/core/lib/transport/byte_stream.h [5:15] - src/core/lib/transport/connectivity_state.cc [5:15] - src/core/lib/transport/connectivity_state.h [5:15] - src/core/lib/transport/error_utils.cc [5:15] - src/core/lib/transport/error_utils.h [5:15] - src/core/lib/transport/http2_errors.h [5:15] - src/core/lib/transport/metadata.cc [5:15] - src/core/lib/transport/metadata.h [5:15] - src/core/lib/transport/metadata_batch.cc [5:15] - src/core/lib/transport/metadata_batch.h [5:15] - src/core/lib/transport/pid_controller.cc [5:15] - src/core/lib/transport/pid_controller.h [5:15] - src/core/lib/transport/static_metadata.cc [4:14] - src/core/lib/transport/static_metadata.h [4:14] - src/core/lib/transport/status_conversion.cc [5:15] - src/core/lib/transport/status_conversion.h [5:15] - src/core/lib/transport/status_metadata.cc [5:15] - src/core/lib/transport/status_metadata.h [5:15] - src/core/lib/transport/timeout_encoding.cc [5:15] - src/core/lib/transport/timeout_encoding.h [5:15] - src/core/lib/transport/transport.cc [5:15] - src/core/lib/transport/transport.h [5:15] - src/core/lib/transport/transport_impl.h [5:15] - src/core/lib/transport/transport_op_string.cc [5:15] - src/core/lib/uri/uri_parser.cc [5:15] - src/core/lib/uri/uri_parser.h [5:15] - src/core/plugin_registry/grpc_plugin_registry.cc [5:15] - src/core/plugin_registry/grpc_unsecure_plugin_registry.cc [5:15] - src/core/tsi/alts/crypt/aes_gcm.cc [5:15] - src/core/tsi/alts/crypt/gsec.cc [5:15] - src/core/tsi/alts/crypt/gsec.h [5:15] - src/core/tsi/alts/frame_protector/alts_counter.cc [5:15] - src/core/tsi/alts/frame_protector/alts_counter.h [5:15] - src/core/tsi/alts/frame_protector/alts_crypter.cc [5:15] - src/core/tsi/alts/frame_protector/alts_crypter.h [5:15] - src/core/tsi/alts/frame_protector/alts_frame_protector.cc [5:15] - src/core/tsi/alts/frame_protector/alts_frame_protector.h [5:15] - src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc [5:15] - src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h [5:15] - src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc [5:15] - src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc [5:15] - src/core/tsi/alts/frame_protector/frame_handler.cc [5:15] - src/core/tsi/alts/frame_protector/frame_handler.h [5:15] - src/core/tsi/alts/handshaker/alts_handshaker_client.cc [5:15] - src/core/tsi/alts/handshaker/alts_handshaker_client.h [5:15] - src/core/tsi/alts/handshaker/alts_shared_resource.cc [5:15] - src/core/tsi/alts/handshaker/alts_shared_resource.h [5:15] - src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc [5:15] - src/core/tsi/alts/handshaker/alts_tsi_handshaker.h [5:15] - src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h [5:15] - src/core/tsi/alts/handshaker/alts_tsi_utils.cc [5:15] - src/core/tsi/alts/handshaker/alts_tsi_utils.h [5:15] - src/core/tsi/alts/handshaker/transport_security_common_api.cc [5:15] - src/core/tsi/alts/handshaker/transport_security_common_api.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc [5:15] - src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h [5:15] - src/core/tsi/fake_transport_security.cc [5:15] - src/core/tsi/fake_transport_security.h [5:15] - src/core/tsi/local_transport_security.cc [5:15] - src/core/tsi/local_transport_security.h [5:15] - src/core/tsi/ssl/session_cache/ssl_session.h [5:15] - src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc [5:15] - src/core/tsi/ssl/session_cache/ssl_session_cache.cc [5:15] - src/core/tsi/ssl/session_cache/ssl_session_cache.h [5:15] - src/core/tsi/ssl/session_cache/ssl_session_openssl.cc [5:15] - src/core/tsi/ssl_transport_security.cc [5:15] - src/core/tsi/ssl_transport_security.h [5:15] - src/core/tsi/ssl_types.h [5:15] - src/core/tsi/transport_security.cc [5:15] - src/core/tsi/transport_security.h [5:15] - src/core/tsi/transport_security_grpc.cc [5:15] - src/core/tsi/transport_security_grpc.h [5:15] - src/core/tsi/transport_security_interface.h [5:15] - src/cpp/client/channel_cc.cc [5:15] - src/cpp/client/client_callback.cc [4:14] - src/cpp/client/client_context.cc [5:15] - src/cpp/client/client_interceptor.cc [5:15] - src/cpp/client/create_channel.cc [5:15] - src/cpp/client/create_channel_internal.cc [5:15] - src/cpp/client/create_channel_internal.h [5:15] - src/cpp/client/create_channel_posix.cc [5:15] - src/cpp/client/credentials_cc.cc [5:15] - src/cpp/client/insecure_credentials.cc [5:15] - src/cpp/client/secure_credentials.cc [5:15] - src/cpp/client/secure_credentials.h [5:15] - src/cpp/codegen/codegen_init.cc [5:15] - src/cpp/common/alarm.cc [4:14] - src/cpp/common/alts_context.cc [5:15] - src/cpp/common/alts_util.cc [5:15] - src/cpp/common/auth_property_iterator.cc [5:15] - src/cpp/common/channel_arguments.cc [5:15] - src/cpp/common/channel_filter.cc [5:15] - src/cpp/common/channel_filter.h [5:15] - src/cpp/common/completion_queue_cc.cc [4:14] - src/cpp/common/core_codegen.cc [5:15] - src/cpp/common/insecure_create_auth_context.cc [5:15] - src/cpp/common/resource_quota_cc.cc [5:15] - src/cpp/common/rpc_method.cc [5:15] - src/cpp/common/secure_auth_context.cc [5:15] - src/cpp/common/secure_auth_context.h [5:15] - src/cpp/common/secure_channel_arguments.cc [5:15] - src/cpp/common/secure_create_auth_context.cc [5:15] - src/cpp/common/tls_credentials_options.cc [5:15] - src/cpp/common/validate_service_config.cc [5:15] - src/cpp/common/version_cc.cc [5:15] - src/cpp/ext/proto_server_reflection.cc [5:15] - src/cpp/ext/proto_server_reflection.h [5:15] - src/cpp/ext/proto_server_reflection_plugin.cc [5:15] - src/cpp/server/async_generic_service.cc [5:15] - src/cpp/server/channel_argument_option.cc [5:15] - src/cpp/server/channelz/channelz_service.cc [5:15] - src/cpp/server/channelz/channelz_service.h [5:15] - src/cpp/server/channelz/channelz_service_plugin.cc [5:15] - src/cpp/server/create_default_thread_pool.cc [5:15] - src/cpp/server/dynamic_thread_pool.cc [5:15] - src/cpp/server/dynamic_thread_pool.h [5:15] - src/cpp/server/external_connection_acceptor_impl.cc [5:15] - src/cpp/server/external_connection_acceptor_impl.h [5:15] - src/cpp/server/health/default_health_check_service.cc [5:15] - src/cpp/server/health/default_health_check_service.h [5:15] - src/cpp/server/health/health_check_service.cc [5:15] - src/cpp/server/health/health_check_service_server_builder_option.cc [5:15] - src/cpp/server/insecure_server_credentials.cc [5:15] - src/cpp/server/load_reporter/constants.h [5:15] - src/cpp/server/load_reporter/get_cpu_stats.h [5:15] - src/cpp/server/load_reporter/get_cpu_stats_linux.cc [5:15] - src/cpp/server/load_reporter/get_cpu_stats_macos.cc [5:15] - src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc [5:15] - src/cpp/server/load_reporter/get_cpu_stats_windows.cc [5:15] - src/cpp/server/load_reporter/load_data_store.cc [5:15] - src/cpp/server/load_reporter/load_data_store.h [5:15] - src/cpp/server/load_reporter/util.cc [5:15] - src/cpp/server/secure_server_credentials.cc [5:15] - src/cpp/server/secure_server_credentials.h [5:15] - src/cpp/server/server_builder.cc [5:15] - src/cpp/server/server_callback.cc [4:14] - src/cpp/server/server_cc.cc [4:14] - src/cpp/server/server_context.cc [5:15] - src/cpp/server/server_credentials.cc [5:15] - src/cpp/server/server_posix.cc [5:15] - src/cpp/server/thread_pool_interface.h [5:15] - src/cpp/thread_manager/thread_manager.cc [5:15] - src/cpp/thread_manager/thread_manager.h [5:15] - src/cpp/util/byte_buffer_cc.cc [5:15] - src/cpp/util/error_details.cc [5:15] - src/cpp/util/status.cc [5:15] - src/cpp/util/string_ref.cc [5:15] - src/cpp/util/time_cc.cc [5:15] - test/core/util/cmdline.cc [5:15] - test/core/util/cmdline.h [5:15] - test/core/util/cmdline_test.cc [5:15] - test/core/util/fuzzer_corpus_test.cc [5:15] - test/core/util/fuzzer_util.cc [5:15] - test/core/util/fuzzer_util.h [5:15] - test/core/util/grpc_profiler.cc [5:15] - test/core/util/grpc_profiler.h [5:15] - test/core/util/histogram.cc [5:15] - test/core/util/histogram.h [5:15] - test/core/util/histogram_test.cc [5:15] - test/core/util/memory_counters.cc [5:15] - test/core/util/memory_counters.h [5:15] - test/core/util/mock_endpoint.cc [5:15] - test/core/util/mock_endpoint.h [5:15] - test/core/util/one_corpus_entry_fuzzer.cc [5:15] - test/core/util/parse_hexstring.cc [5:15] - test/core/util/parse_hexstring.h [5:15] - test/core/util/passthru_endpoint.cc [5:15] - test/core/util/passthru_endpoint.h [5:15] - test/core/util/port.cc [5:15] - test/core/util/port.h [5:15] - test/core/util/port_isolated_runtime_environment.cc [5:15] - test/core/util/port_server_client.cc [5:15] - test/core/util/port_server_client.h [5:15] - test/core/util/reconnect_server.cc [5:15] - test/core/util/reconnect_server.h [5:15] - test/core/util/slice_splitter.cc [5:15] - test/core/util/slice_splitter.h [5:15] - test/core/util/stack_tracer.cc [5:15] - test/core/util/stack_tracer.h [5:15] - test/core/util/stack_tracer_test.cc [5:15] - test/core/util/subprocess.h [5:15] - test/core/util/subprocess_posix.cc [5:15] - test/core/util/subprocess_windows.cc [5:15] - test/core/util/test_config.cc [5:15] - test/core/util/test_config.h [5:15] - test/core/util/test_tcp_server.cc [5:15] - test/core/util/test_tcp_server.h [5:15] - test/core/util/tracer_util.cc [5:15] - test/core/util/tracer_util.h [5:15] - test/cpp/end2end/async_end2end_test.cc [5:15] - test/cpp/end2end/cfstream_test.cc [5:15] - test/cpp/end2end/channelz_service_test.cc [5:15] - test/cpp/end2end/client_callback_end2end_test.cc [5:15] - test/cpp/end2end/client_crash_test.cc [5:15] - test/cpp/end2end/client_crash_test_server.cc [5:15] - test/cpp/end2end/client_interceptors_end2end_test.cc [5:15] - test/cpp/end2end/client_lb_end2end_test.cc [5:15] - test/cpp/end2end/context_allocator_end2end_test.cc [5:15] - test/cpp/end2end/delegating_channel_test.cc [5:15] - test/cpp/end2end/end2end_test.cc [5:15] - test/cpp/end2end/exception_test.cc [5:15] - test/cpp/end2end/filter_end2end_test.cc [5:15] - test/cpp/end2end/flaky_network_test.cc [5:15] - test/cpp/end2end/generic_end2end_test.cc [5:15] - test/cpp/end2end/health_service_end2end_test.cc [5:15] - test/cpp/end2end/hybrid_end2end_test.cc [5:15] - test/cpp/end2end/interceptors_util.cc [5:15] - test/cpp/end2end/interceptors_util.h [5:15] - test/cpp/end2end/message_allocator_end2end_test.cc [5:15] - test/cpp/end2end/mock_test.cc [5:15] - test/cpp/end2end/nonblocking_test.cc [5:15] - test/cpp/end2end/port_sharing_end2end_test.cc [5:15] - test/cpp/end2end/proto_server_reflection_test.cc [5:15] - test/cpp/end2end/raw_end2end_test.cc [5:15] - test/cpp/end2end/server_builder_plugin_test.cc [5:15] - test/cpp/end2end/server_crash_test.cc [5:15] - test/cpp/end2end/server_crash_test_client.cc [5:15] - test/cpp/end2end/server_early_return_test.cc [5:15] - test/cpp/end2end/server_interceptors_end2end_test.cc [5:15] - test/cpp/end2end/server_load_reporting_end2end_test.cc [5:15] - test/cpp/end2end/service_config_end2end_test.cc [5:15] - test/cpp/end2end/shutdown_test.cc [5:15] - test/cpp/end2end/streaming_throughput_test.cc [5:15] - test/cpp/end2end/test_health_check_service_impl.cc [5:15] - test/cpp/end2end/test_health_check_service_impl.h [5:15] - test/cpp/end2end/test_service_impl.cc [5:15] - test/cpp/end2end/test_service_impl.h [5:15] - test/cpp/end2end/thread_stress_test.cc [5:15] - test/cpp/end2end/time_change_test.cc [5:15] - test/cpp/util/byte_buffer_proto_helper.cc [5:15] - test/cpp/util/byte_buffer_proto_helper.h [5:15] - test/cpp/util/byte_buffer_test.cc [5:15] - test/cpp/util/channel_trace_proto_helper.cc [5:15] - test/cpp/util/channel_trace_proto_helper.h [5:15] - test/cpp/util/channelz_sampler.cc [5:15] - test/cpp/util/channelz_sampler_test.cc [5:15] - test/cpp/util/cli_call.cc [5:15] - test/cpp/util/cli_call.h [5:15] - test/cpp/util/cli_call_test.cc [5:15] - test/cpp/util/cli_credentials.cc [5:15] - test/cpp/util/cli_credentials.h [5:15] - test/cpp/util/config_grpc_cli.h [5:15] - test/cpp/util/create_test_channel.cc [5:15] - test/cpp/util/create_test_channel.h [5:15] - test/cpp/util/error_details_test.cc [5:15] - test/cpp/util/grpc_cli.cc [5:15] - test/cpp/util/grpc_tool.cc [5:15] - test/cpp/util/grpc_tool.h [5:15] - test/cpp/util/grpc_tool_test.cc [5:15] - test/cpp/util/metrics_server.cc [5:15] - test/cpp/util/metrics_server.h [5:15] - test/cpp/util/proto_file_parser.cc [5:15] - test/cpp/util/proto_file_parser.h [5:15] - test/cpp/util/proto_reflection_descriptor_database.cc [5:15] - test/cpp/util/proto_reflection_descriptor_database.h [5:15] - test/cpp/util/service_describer.cc [5:15] - test/cpp/util/service_describer.h [5:15] - test/cpp/util/slice_test.cc [5:15] - test/cpp/util/string_ref_helper.cc [5:15] - test/cpp/util/string_ref_helper.h [5:15] - test/cpp/util/string_ref_test.cc [5:15] - test/cpp/util/subprocess.cc [5:15] - test/cpp/util/subprocess.h [5:15] - test/cpp/util/test_config.h [5:15] - test/cpp/util/test_config_cc.cc [5:15] - test/cpp/util/test_credentials_provider.cc [6:16] - test/cpp/util/test_credentials_provider.h [5:15] - test/cpp/util/time_test.cc [5:15] - tools/codegen/core/gen_hpack_tables.cc [5:15] - -KEEP Apache-2.0 4248d6c827c367ff9f1b5e59ca41408e -BELONGS src/core/lib/ya.make src/cpp/common/ya.make src/proto/grpc/channelz/ya.make src/proto/grpc/core/ya.make src/proto/grpc/health/v1/ya.make src/proto/grpc/reflection/v1alpha/ya.make src/proto/grpc/status/ya.make src/proto/grpc/testing/duplicate/ya.make src/proto/grpc/testing/xds/ya.make src/proto/grpc/testing/ya.make test/core/util/ya.make test/cpp/end2end/ya.make test/cpp/util/ya.make ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - include/grpc/event_engine/endpoint_config.h [3:13] - include/grpc/event_engine/event_engine.h [3:13] - include/grpc/event_engine/internal/memory_allocator_impl.h [3:13] - include/grpc/event_engine/memory_allocator.h [3:13] - include/grpc/event_engine/memory_request.h [3:13] - include/grpc/event_engine/port.h [3:13] - include/grpcpp/create_channel_binder.h [3:13] - include/grpcpp/ext/admin_services.h [5:15] - include/grpcpp/security/authorization_policy_provider.h [3:13] - include/grpcpp/security/binder_credentials.h [3:13] - include/grpcpp/security/binder_security_policy.h [3:13] - include/grpcpp/security/tls_certificate_provider.h [4:14] - include/grpcpp/security/tls_certificate_verifier.h [4:14] - include/grpcpp/xds_server_builder.h [5:15] - src/core/ext/filters/client_channel/backend_metric.cc [4:14] - src/core/ext/filters/client_channel/backend_metric.h [4:14] - src/core/ext/filters/client_channel/channel_connectivity.cc [4:14] - src/core/ext/filters/client_channel/client_channel.cc [4:14] - src/core/ext/filters/client_channel/client_channel.h [4:14] - src/core/ext/filters/client_channel/client_channel_factory.h [4:14] - src/core/ext/filters/client_channel/config_selector.cc [4:14] - src/core/ext/filters/client_channel/config_selector.h [4:14] - src/core/ext/filters/client_channel/connector.h [4:14] - src/core/ext/filters/client_channel/dynamic_filters.cc [4:14] - src/core/ext/filters/client_channel/dynamic_filters.h [4:14] - src/core/ext/filters/client_channel/global_subchannel_pool.cc [5:15] - src/core/ext/filters/client_channel/lb_policy.h [4:14] - src/core/ext/filters/client_channel/lb_policy/address_filtering.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/address_filtering.h [4:14] - src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h [4:14] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h [4:14] - src/core/ext/filters/client_channel/lb_policy/priority/priority.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h [4:14] - src/core/ext/filters/client_channel/lb_policy/rls/rls.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/cds.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/xds.h [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc [4:14] - src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc [4:14] - src/core/ext/filters/client_channel/local_subchannel_pool.cc [5:15] - src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc [3:13] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc [3:13] - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc [3:13] - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc [4:14] - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc [4:14] - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h [4:14] - src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc [4:14] - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h [4:14] - src/core/ext/filters/client_channel/resolver_result_parsing.cc [4:14] - src/core/ext/filters/client_channel/resolver_result_parsing.h [4:14] - src/core/ext/filters/client_channel/retry_filter.cc [4:14] - src/core/ext/filters/client_channel/retry_filter.h [4:14] - src/core/ext/filters/client_channel/retry_service_config.cc [4:14] - src/core/ext/filters/client_channel/retry_service_config.h [4:14] - src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc [4:14] - src/core/ext/filters/client_channel/subchannel.cc [4:14] - src/core/ext/filters/client_channel/subchannel.h [4:14] - src/core/ext/filters/client_channel/subchannel_pool_interface.cc [5:15] - src/core/ext/filters/client_idle/idle_filter_state.cc [3:13] - src/core/ext/filters/client_idle/idle_filter_state.h [3:13] - src/core/ext/filters/deadline/deadline_filter.cc [4:14] - src/core/ext/filters/deadline/deadline_filter.h [4:14] - src/core/ext/filters/fault_injection/fault_injection_filter.cc [4:14] - src/core/ext/filters/fault_injection/fault_injection_filter.h [4:14] - src/core/ext/filters/fault_injection/service_config_parser.cc [4:14] - src/core/ext/filters/fault_injection/service_config_parser.h [4:14] - src/core/ext/filters/http/message_compress/message_decompress_filter.cc [5:15] - src/core/ext/filters/http/message_compress/message_decompress_filter.h [5:15] - src/core/ext/filters/max_age/max_age_filter.h [4:14] - src/core/ext/filters/message_size/message_size_filter.cc [4:14] - src/core/ext/filters/message_size/message_size_filter.h [4:14] - src/core/ext/filters/server_config_selector/server_config_selector.cc [4:14] - src/core/ext/filters/server_config_selector/server_config_selector.h [4:14] - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc [5:15] - src/core/ext/filters/server_config_selector/server_config_selector_filter.h [5:15] - src/core/ext/service_config/service_config.cc [4:14] - src/core/ext/service_config/service_config.h [4:14] - src/core/ext/service_config/service_config_call_data.h [4:14] - src/core/ext/service_config/service_config_parser.cc [4:14] - src/core/ext/service_config/service_config_parser.h [4:14] - src/core/ext/transport/binder/client/binder_connector.cc [3:13] - src/core/ext/transport/binder/client/binder_connector.h [3:13] - src/core/ext/transport/binder/client/channel_create.cc [3:13] - src/core/ext/transport/binder/client/channel_create_impl.cc [3:13] - src/core/ext/transport/binder/client/channel_create_impl.h [3:13] - src/core/ext/transport/binder/client/connection_id_generator.cc [3:13] - src/core/ext/transport/binder/client/connection_id_generator.h [3:13] - src/core/ext/transport/binder/client/endpoint_binder_pool.cc [3:13] - src/core/ext/transport/binder/client/endpoint_binder_pool.h [3:13] - src/core/ext/transport/binder/client/jni_utils.cc [3:13] - src/core/ext/transport/binder/client/jni_utils.h [3:13] - src/core/ext/transport/binder/client/security_policy_setting.cc [3:13] - src/core/ext/transport/binder/client/security_policy_setting.h [3:13] - src/core/ext/transport/binder/security_policy/binder_security_policy.cc [3:13] - src/core/ext/transport/binder/server/binder_server.cc [3:13] - src/core/ext/transport/binder/server/binder_server.h [3:13] - src/core/ext/transport/binder/server/binder_server_credentials.cc [3:13] - src/core/ext/transport/binder/transport/binder_stream.h [3:13] - src/core/ext/transport/binder/transport/binder_transport.cc [3:13] - src/core/ext/transport/binder/transport/binder_transport.h [3:13] - src/core/ext/transport/binder/utils/ndk_binder.cc [3:13] - src/core/ext/transport/binder/utils/ndk_binder.h [3:13] - src/core/ext/transport/binder/utils/transport_stream_receiver.h [3:13] - src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc [3:13] - src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h [3:13] - src/core/ext/transport/binder/wire_format/binder.h [3:13] - src/core/ext/transport/binder/wire_format/binder_android.cc [3:13] - src/core/ext/transport/binder/wire_format/binder_android.h [3:13] - src/core/ext/transport/binder/wire_format/binder_constants.cc [3:13] - src/core/ext/transport/binder/wire_format/binder_constants.h [3:13] - src/core/ext/transport/binder/wire_format/transaction.cc [3:13] - src/core/ext/transport/binder/wire_format/transaction.h [3:13] - src/core/ext/transport/binder/wire_format/wire_reader.h [3:13] - src/core/ext/transport/binder/wire_format/wire_reader_impl.cc [3:13] - src/core/ext/transport/binder/wire_format/wire_reader_impl.h [3:13] - src/core/ext/transport/binder/wire_format/wire_writer.cc [3:13] - src/core/ext/transport/binder/wire_format/wire_writer.h [3:13] - src/core/ext/transport/chttp2/client/insecure/channel_create.cc [4:14] - src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc [4:14] - src/core/ext/transport/chttp2/transport/chttp2_transport.cc [4:14] - src/core/ext/transport/chttp2/transport/hpack_constants.h [3:13] - src/core/ext/transport/chttp2/transport/hpack_encoder_index.h [3:13] - src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc [3:13] - src/core/ext/transport/chttp2/transport/hpack_encoder_table.h [3:13] - src/core/ext/transport/chttp2/transport/hpack_utils.cc [3:13] - src/core/ext/transport/chttp2/transport/hpack_utils.h [3:13] - src/core/ext/transport/chttp2/transport/popularity_count.h [3:13] - src/core/ext/xds/certificate_provider_factory.h [5:15] - src/core/ext/xds/certificate_provider_registry.cc [5:15] - src/core/ext/xds/certificate_provider_registry.h [5:15] - src/core/ext/xds/certificate_provider_store.cc [5:15] - src/core/ext/xds/certificate_provider_store.h [5:15] - src/core/ext/xds/file_watcher_certificate_provider_factory.cc [5:15] - src/core/ext/xds/file_watcher_certificate_provider_factory.h [5:15] - src/core/ext/xds/xds_api.cc [4:14] - src/core/ext/xds/xds_bootstrap.cc [4:14] - src/core/ext/xds/xds_bootstrap.h [4:14] - src/core/ext/xds/xds_certificate_provider.cc [5:15] - src/core/ext/xds/xds_certificate_provider.h [5:15] - src/core/ext/xds/xds_channel_args.h [4:14] - src/core/ext/xds/xds_channel_stack_modifier.cc [5:15] - src/core/ext/xds/xds_channel_stack_modifier.h [5:15] - src/core/ext/xds/xds_client.cc [4:14] - src/core/ext/xds/xds_client.h [4:14] - src/core/ext/xds/xds_http_fault_filter.cc [4:14] - src/core/ext/xds/xds_http_fault_filter.h [4:14] - src/core/ext/xds/xds_http_filters.cc [4:14] - src/core/ext/xds/xds_http_filters.h [4:14] - src/core/ext/xds/xds_routing.cc [5:15] - src/core/ext/xds/xds_routing.h [5:15] - src/core/ext/xds/xds_server_config_fetcher.cc [5:15] - src/core/lib/avl/avl.h [3:13] - src/core/lib/channel/call_tracer.h [5:15] - src/core/lib/channel/channel_args_preconditioning.cc [3:13] - src/core/lib/channel/channel_args_preconditioning.h [3:13] - src/core/lib/config/core_configuration.cc [3:13] - src/core/lib/config/core_configuration.h [3:13] - src/core/lib/event_engine/channel_args_endpoint_config.cc [3:13] - src/core/lib/event_engine/channel_args_endpoint_config.h [3:13] - src/core/lib/event_engine/event_engine.cc [3:13] - src/core/lib/event_engine/event_engine_factory.cc [3:13] - src/core/lib/event_engine/event_engine_factory.h [3:13] - src/core/lib/event_engine/memory_allocator.cc [3:13] - src/core/lib/event_engine/sockaddr.cc [3:13] - src/core/lib/event_engine/sockaddr.h [3:13] - src/core/lib/gprpp/bitset.h [3:13] - src/core/lib/gprpp/capture.h [3:13] - src/core/lib/gprpp/chunked_vector.h [3:13] - src/core/lib/gprpp/construct_destruct.h [3:13] - src/core/lib/gprpp/cpp_impl_of.h [3:13] - src/core/lib/gprpp/dual_ref_counted.h [4:14] - src/core/lib/gprpp/match.h [3:13] - src/core/lib/gprpp/overload.h [3:13] - src/core/lib/gprpp/stat.h [4:14] - src/core/lib/gprpp/stat_posix.cc [4:14] - src/core/lib/gprpp/stat_windows.cc [4:14] - src/core/lib/gprpp/status_helper.cc [5:15] - src/core/lib/gprpp/status_helper.h [5:15] - src/core/lib/gprpp/table.h [3:13] - src/core/lib/gprpp/time_util.cc [4:14] - src/core/lib/gprpp/time_util.h [4:14] - src/core/lib/iomgr/endpoint_pair_event_engine.cc [3:13] - src/core/lib/iomgr/event_engine/closure.cc [3:13] - src/core/lib/iomgr/event_engine/closure.h [3:13] - src/core/lib/iomgr/event_engine/endpoint.cc [3:13] - src/core/lib/iomgr/event_engine/endpoint.h [3:13] - src/core/lib/iomgr/event_engine/iomgr.cc [3:13] - src/core/lib/iomgr/event_engine/pollset.cc [3:13] - src/core/lib/iomgr/event_engine/pollset.h [3:13] - src/core/lib/iomgr/event_engine/promise.h [3:13] - src/core/lib/iomgr/event_engine/resolved_address_internal.cc [3:13] - src/core/lib/iomgr/event_engine/resolved_address_internal.h [3:13] - src/core/lib/iomgr/event_engine/resolver.cc [3:13] - src/core/lib/iomgr/event_engine/tcp.cc [3:13] - src/core/lib/iomgr/event_engine/timer.cc [3:13] - src/core/lib/json/json_util.cc [5:15] - src/core/lib/json/json_util.h [5:15] - src/core/lib/matchers/matchers.cc [3:13] - src/core/lib/matchers/matchers.h [3:13] - src/core/lib/promise/activity.cc [3:13] - src/core/lib/promise/activity.h [3:13] - src/core/lib/promise/arena_promise.h [3:13] - src/core/lib/promise/context.h [3:13] - src/core/lib/promise/detail/basic_join.h [3:13] - src/core/lib/promise/detail/basic_seq.h [3:13] - src/core/lib/promise/detail/promise_factory.h [3:13] - src/core/lib/promise/detail/promise_like.h [3:13] - src/core/lib/promise/detail/status.h [3:13] - src/core/lib/promise/exec_ctx_wakeup_scheduler.h [3:13] - src/core/lib/promise/for_each.h [3:13] - src/core/lib/promise/if.h [3:13] - src/core/lib/promise/intra_activity_waiter.h [3:13] - src/core/lib/promise/join.h [3:13] - src/core/lib/promise/latch.h [3:13] - src/core/lib/promise/loop.h [3:13] - src/core/lib/promise/map.h [3:13] - src/core/lib/promise/observable.h [3:13] - src/core/lib/promise/pipe.h [3:13] - src/core/lib/promise/poll.h [3:13] - src/core/lib/promise/promise.h [3:13] - src/core/lib/promise/race.h [3:13] - src/core/lib/promise/seq.h [3:13] - src/core/lib/promise/try_join.h [3:13] - src/core/lib/promise/try_seq.h [3:13] - src/core/lib/promise/wait_set.h [3:13] - src/core/lib/resource_quota/api.cc [3:13] - src/core/lib/resource_quota/api.h [3:13] - src/core/lib/resource_quota/memory_quota.cc [3:13] - src/core/lib/resource_quota/memory_quota.h [3:13] - src/core/lib/resource_quota/resource_quota.cc [3:13] - src/core/lib/resource_quota/resource_quota.h [3:13] - src/core/lib/resource_quota/thread_quota.cc [3:13] - src/core/lib/resource_quota/thread_quota.h [3:13] - src/core/lib/resource_quota/trace.cc [3:13] - src/core/lib/resource_quota/trace.h [3:13] - src/core/lib/security/authorization/authorization_engine.h [3:13] - src/core/lib/security/authorization/authorization_policy_provider.h [3:13] - src/core/lib/security/authorization/authorization_policy_provider_null_vtable.cc [3:13] - src/core/lib/security/authorization/authorization_policy_provider_vtable.cc [3:13] - src/core/lib/security/authorization/cel_authorization_engine.h [4:14] - src/core/lib/security/authorization/evaluate_args.cc [3:13] - src/core/lib/security/authorization/evaluate_args.h [3:13] - src/core/lib/security/authorization/grpc_authorization_engine.h [3:13] - src/core/lib/security/authorization/grpc_authorization_policy_provider.h [3:13] - src/core/lib/security/authorization/matchers.h [3:13] - src/core/lib/security/authorization/mock_cel/activation.h [3:13] - src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h [3:13] - src/core/lib/security/authorization/mock_cel/cel_expression.h [3:13] - src/core/lib/security/authorization/mock_cel/cel_value.h [3:13] - src/core/lib/security/authorization/mock_cel/evaluator_core.h [3:13] - src/core/lib/security/authorization/mock_cel/flat_expr_builder.h [3:13] - src/core/lib/security/authorization/rbac_policy.h [3:13] - src/core/lib/security/authorization/rbac_translator.h [3:13] - src/core/lib/security/authorization/sdk_server_authz_filter.cc [3:13] - src/core/lib/security/authorization/sdk_server_authz_filter.h [3:13] - src/core/lib/security/credentials/external/aws_external_account_credentials.cc [4:14] - src/core/lib/security/credentials/external/aws_external_account_credentials.h [4:14] - src/core/lib/security/credentials/external/aws_request_signer.cc [4:14] - src/core/lib/security/credentials/external/aws_request_signer.h [4:14] - src/core/lib/security/credentials/external/external_account_credentials.cc [4:14] - src/core/lib/security/credentials/external/external_account_credentials.h [4:14] - src/core/lib/security/credentials/external/file_external_account_credentials.cc [4:14] - src/core/lib/security/credentials/external/file_external_account_credentials.h [4:14] - src/core/lib/security/credentials/external/url_external_account_credentials.cc [4:14] - src/core/lib/security/credentials/external/url_external_account_credentials.h [4:14] - src/core/lib/security/credentials/insecure/insecure_credentials.cc [5:15] - src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc [4:14] - src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h [4:14] - src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc [4:14] - src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h [4:14] - src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc [4:14] - src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h [4:14] - src/core/lib/security/credentials/tls/tls_utils.cc [5:15] - src/core/lib/security/credentials/tls/tls_utils.h [5:15] - src/core/lib/security/credentials/xds/xds_credentials.cc [5:15] - src/core/lib/security/credentials/xds/xds_credentials.h [5:15] - src/core/lib/security/security_connector/insecure/insecure_security_connector.cc [5:15] - src/core/lib/security/security_connector/insecure/insecure_security_connector.h [5:15] - src/core/lib/slice/slice.h [3:13] - src/core/lib/slice/slice_refcount.cc [3:13] - src/core/lib/slice/slice_refcount.h [3:13] - src/core/lib/slice/slice_refcount_base.h [3:13] - src/core/lib/slice/slice_split.cc [3:13] - src/core/lib/surface/builtins.cc [3:13] - src/core/lib/surface/builtins.h [3:13] - src/core/lib/surface/server.cc [4:14] - src/core/lib/surface/server.h [4:14] - src/core/lib/transport/parsed_metadata.cc [3:13] - src/core/lib/transport/parsed_metadata.h [3:13] - src/core/tsi/alts/handshaker/proto/altscontext.proto [3:13] - src/core/tsi/alts/handshaker/proto/handshaker.proto [3:13] - src/core/tsi/alts/handshaker/proto/transport_security_common.proto [3:13] - src/cpp/client/xds_credentials.cc [5:15] - src/cpp/common/tls_certificate_provider.cc [4:14] - src/cpp/common/tls_certificate_verifier.cc [4:14] - src/cpp/server/xds_server_credentials.cc [5:15] - src/proto/grpc/channelz/channelz.proto [3:13] - src/proto/grpc/core/stats.proto [3:13] - src/proto/grpc/gcp/altscontext.proto [3:13] - src/proto/grpc/gcp/handshaker.proto [3:13] - src/proto/grpc/gcp/transport_security_common.proto [3:13] - src/proto/grpc/health/v1/health.proto [3:13] - src/proto/grpc/lb/v1/load_balancer.proto [3:13] - src/proto/grpc/lb/v1/load_reporter.proto [3:13] - src/proto/grpc/lookup/v1/rls.proto [3:13] - src/proto/grpc/lookup/v1/rls_config.proto [3:13] - src/proto/grpc/reflection/v1/reflection.proto [3:13] - src/proto/grpc/reflection/v1alpha/reflection.proto [3:13] - src/proto/grpc/status/status.proto [3:13] - src/proto/grpc/testing/benchmark_service.proto [3:13] - src/proto/grpc/testing/compiler_test.proto [3:13] - src/proto/grpc/testing/control.proto [3:13] - src/proto/grpc/testing/duplicate/echo_duplicate.proto [4:14] - src/proto/grpc/testing/echo.proto [4:14] - src/proto/grpc/testing/echo_messages.proto [4:14] - src/proto/grpc/testing/empty.proto [4:14] - src/proto/grpc/testing/empty_service.proto [4:14] - src/proto/grpc/testing/messages.proto [4:14] - src/proto/grpc/testing/metrics.proto [3:13] - src/proto/grpc/testing/payloads.proto [3:13] - src/proto/grpc/testing/proto2/empty2.proto [4:14] - src/proto/grpc/testing/proto2/empty2_extensions.proto [3:13] - src/proto/grpc/testing/proxy-service.proto [3:13] - src/proto/grpc/testing/report_qps_scenario_service.proto [3:13] - src/proto/grpc/testing/simple_messages.proto [4:14] - src/proto/grpc/testing/stats.proto [3:13] - src/proto/grpc/testing/test.proto [4:14] - src/proto/grpc/testing/worker_service.proto [3:13] - src/proto/grpc/testing/xds/ads_for_test.proto [3:13] - src/proto/grpc/testing/xds/cds_for_test.proto [3:13] - src/proto/grpc/testing/xds/eds_for_test.proto [3:13] - src/proto/grpc/testing/xds/lds_rds_for_test.proto [3:13] - src/proto/grpc/testing/xds/lrs_for_test.proto [3:13] - src/proto/grpc/testing/xds/v3/address.proto [3:13] - src/proto/grpc/testing/xds/v3/ads.proto [3:13] - src/proto/grpc/testing/xds/v3/aggregate_cluster.proto [3:13] - src/proto/grpc/testing/xds/v3/base.proto [3:13] - src/proto/grpc/testing/xds/v3/cluster.proto [3:13] - src/proto/grpc/testing/xds/v3/config_dump.proto [3:13] - src/proto/grpc/testing/xds/v3/config_source.proto [3:13] - src/proto/grpc/testing/xds/v3/csds.proto [3:13] - src/proto/grpc/testing/xds/v3/discovery.proto [3:13] - src/proto/grpc/testing/xds/v3/endpoint.proto [3:13] - src/proto/grpc/testing/xds/v3/extension.proto [3:13] - src/proto/grpc/testing/xds/v3/fault.proto [3:13] - src/proto/grpc/testing/xds/v3/fault_common.proto [3:13] - src/proto/grpc/testing/xds/v3/http_connection_manager.proto [3:13] - src/proto/grpc/testing/xds/v3/listener.proto [3:13] - src/proto/grpc/testing/xds/v3/load_report.proto [3:13] - src/proto/grpc/testing/xds/v3/lrs.proto [3:13] - src/proto/grpc/testing/xds/v3/orca_load_report.proto [3:13] - src/proto/grpc/testing/xds/v3/percent.proto [3:13] - src/proto/grpc/testing/xds/v3/protocol.proto [3:13] - src/proto/grpc/testing/xds/v3/range.proto [3:13] - src/proto/grpc/testing/xds/v3/regex.proto [3:13] - src/proto/grpc/testing/xds/v3/route.proto [3:13] - src/proto/grpc/testing/xds/v3/router.proto [3:13] - src/proto/grpc/testing/xds/v3/string.proto [3:13] - src/proto/grpc/testing/xds/v3/tls.proto [3:13] - src/proto/math/math.proto [4:14] - test/core/util/build.cc [3:13] - test/core/util/build.h [3:13] - test/core/util/evaluate_args_test_util.h [3:13] - test/core/util/mock_authorization_endpoint.h [3:13] - test/core/util/resolve_localhost_ip46.cc [5:15] - test/core/util/resolve_localhost_ip46.h [5:15] - test/core/util/test_lb_policies.cc [4:14] - test/core/util/test_lb_policies.h [4:14] - test/core/util/tls_utils.cc [4:14] - test/core/util/tls_utils.h [4:14] - test/cpp/end2end/admin_services_end2end_test.cc [5:15] - test/cpp/end2end/counted_service.h [4:14] - test/cpp/end2end/grpclb_end2end_test.cc [4:14] - test/cpp/end2end/rls_end2end_test.cc [4:14] - test/cpp/end2end/sdk_authz_end2end_test.cc [3:13] - test/cpp/util/tls_test_utils.cc [4:14] - test/cpp/util/tls_test_utils.h [4:14] - -SKIP LicenseRef-scancode-warranty-disclaimer 44b7fb52fd3cfdfe8a017148dd5f2443 -BELONGS ya.make - # not a license - License text: - // attached to the channel creds, but there should also be a "use at - // your own risk" option to get the channel creds without stripping - Scancode info: - Original SPDX id: LicenseRef-scancode-warranty-disclaimer - Score : 100.00 - Match type : TEXT - Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/warranty-disclaimer.LICENSE - Files with this license: - src/core/ext/filters/client_channel/lb_policy.h [284:285] - -SKIP Python-2.0 5749a3f68d211a0dbd91f414c9769695 -BELONGS src/python/grpcio/ya.make - License text: - \# limitations under the License. - """gRPC's Python gEvent APIs.""" - Scancode info: - Original SPDX id: Python-2.0 - Score : 66.67 - Match type : TAG - Links : http://docs.python.org/license.html, http://spdx.org/licenses/Python-2.0, https://spdx.org/licenses/Python-2.0 - Files with this license: - src/python/grpcio/grpc/experimental/gevent.py [13:14] - -SKIP LicenseRef-scancode-generic-cla 5d780ffa423067f23c6a123ae33e7c18 -BELONGS third_party/upb/ya.make - License text: - \## Contributor License Agreement - Scancode info: - Original SPDX id: LicenseRef-scancode-generic-cla - Score : 16.00 - Match type : NOTICE - Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE - Files with this license: - third_party/upb/CONTRIBUTING.md [15:15] - -SKIP LicenseRef-scancode-generic-cla 60c79976a6f1daa58457b943cb911512 -BELONGS ya.make - License text: - [Contributor License - Agreement](https://identity.linuxfoundation.org/projects/cncf). - Scancode info: - Original SPDX id: LicenseRef-scancode-generic-cla - Score : 16.00 - Match type : NOTICE - Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE - Files with this license: - CONTRIBUTING.md [16:17] - -KEEP MPL-2.0 6a24ea705a1b0d1e288b7a36cbfec9ea -BELONGS ya.make - License text: - Mozilla Public License, v. 2.0 - Scancode info: - Original SPDX id: MPL-2.0 - Score : 100.00 - Match type : REFERENCE - Links : http://mpl.mozilla.org/2012/01/03/announcing-mpl-2-0/, http://www.mozilla.com/MPL/2.0/, https://spdx.org/licenses/MPL-2.0 - Files with this license: - LICENSE [238:238] - -KEEP Apache-2.0 86a0725dcd00b87b9929258039db566c -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - NOTICE.txt [3:13] - -SKIP LicenseRef-scancode-generic-cla 89e69d763852b3ffc049faa969710a83 -BELONGS ya.make - License text: - individual CLA, or your company, for corporate CLAs) in the same PR as your - Scancode info: - Original SPDX id: LicenseRef-scancode-generic-cla - Score : 100.00 - Match type : REFERENCE - Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE - Files with this license: - CONTRIBUTING.md [91:91] - -KEEP MPL-2.0 8cf713b6953fdd90a1c0b2dda10bcc6d -BELONGS ya.make - License text: - This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. - Scancode info: - Original SPDX id: MPL-2.0 - Score : 100.00 - Match type : NOTICE - Links : http://mpl.mozilla.org/2012/01/03/announcing-mpl-2-0/, http://www.mozilla.com/MPL/2.0/, https://spdx.org/licenses/MPL-2.0 - Files with this license: - LICENSE [240:242] - -KEEP Apache-2.0 920b2f581700b4aa528093ed0d2f5a5b -BELONGS src/python/grpcio/ya.make src/python/grpcio_channelz/ya.make src/python/grpcio_health_checking/ya.make src/python/grpcio_reflection/ya.make src/python/grpcio_status/ya.make src/python/grpcio_tests/ya.make test/core/util/ya.make ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : NOTICE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - src/core/tsi/test_creds/BUILD [3:13] - src/python/grpcio/_parallel_compile_patch.py [3:13] - src/python/grpcio/_spawn_patch.py [3:13] - src/python/grpcio/commands.py [3:13] - src/python/grpcio/grpc/__init__.py [3:13] - src/python/grpcio/grpc/_auth.py [3:13] - src/python/grpcio/grpc/_channel.py [3:13] - src/python/grpcio/grpc/_common.py [3:13] - src/python/grpcio/grpc/_compression.py [3:13] - src/python/grpcio/grpc/_cython/__init__.py [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/__init__.py [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/_hooks.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/_hooks.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/common.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/rpc_status.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/rpc_status.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/channelz.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/csds.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/fork_posix.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/fork_windows.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/propagation_bits.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/propagation_bits.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/thread.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/vtable.pxd.pxi [3:13] - src/python/grpcio/grpc/_cython/_cygrpc/vtable.pyx.pxi [3:13] - src/python/grpcio/grpc/_cython/cygrpc.pxd [3:13] - src/python/grpcio/grpc/_cython/cygrpc.pyx [3:13] - src/python/grpcio/grpc/_grpcio_metadata.py [3:13] - src/python/grpcio/grpc/_interceptor.py [3:13] - src/python/grpcio/grpc/_plugin_wrapping.py [3:13] - src/python/grpcio/grpc/_runtime_protos.py [3:13] - src/python/grpcio/grpc/_server.py [3:13] - src/python/grpcio/grpc/_simple_stubs.py [3:13] - src/python/grpcio/grpc/_utilities.py [3:13] - src/python/grpcio/grpc/aio/__init__.py [3:13] - src/python/grpcio/grpc/aio/_base_call.py [3:13] - src/python/grpcio/grpc/aio/_base_channel.py [3:13] - src/python/grpcio/grpc/aio/_base_server.py [3:13] - src/python/grpcio/grpc/aio/_call.py [3:13] - src/python/grpcio/grpc/aio/_channel.py [3:13] - src/python/grpcio/grpc/aio/_interceptor.py [3:13] - src/python/grpcio/grpc/aio/_metadata.py [3:13] - src/python/grpcio/grpc/aio/_server.py [3:13] - src/python/grpcio/grpc/aio/_typing.py [3:13] - src/python/grpcio/grpc/aio/_utils.py [3:13] - src/python/grpcio/grpc/beta/__init__.py [3:13] - src/python/grpcio/grpc/beta/_client_adaptations.py [3:13] - src/python/grpcio/grpc/beta/_metadata.py [3:13] - src/python/grpcio/grpc/beta/_server_adaptations.py [3:13] - src/python/grpcio/grpc/beta/implementations.py [3:13] - src/python/grpcio/grpc/beta/interfaces.py [3:13] - src/python/grpcio/grpc/beta/utilities.py [3:13] - src/python/grpcio/grpc/experimental/__init__.py [3:13] - src/python/grpcio/grpc/experimental/aio/__init__.py [3:13] - src/python/grpcio/grpc/experimental/gevent.py [3:13] - src/python/grpcio/grpc/experimental/session_cache.py [3:13] - src/python/grpcio/grpc/framework/__init__.py [3:13] - src/python/grpcio/grpc/framework/common/__init__.py [3:13] - src/python/grpcio/grpc/framework/common/cardinality.py [3:13] - src/python/grpcio/grpc/framework/common/style.py [3:13] - src/python/grpcio/grpc/framework/foundation/__init__.py [3:13] - src/python/grpcio/grpc/framework/foundation/abandonment.py [3:13] - src/python/grpcio/grpc/framework/foundation/callable_util.py [3:13] - src/python/grpcio/grpc/framework/foundation/future.py [3:13] - src/python/grpcio/grpc/framework/foundation/logging_pool.py [3:13] - src/python/grpcio/grpc/framework/foundation/stream.py [3:13] - src/python/grpcio/grpc/framework/foundation/stream_util.py [3:13] - src/python/grpcio/grpc/framework/interfaces/__init__.py [3:13] - src/python/grpcio/grpc/framework/interfaces/base/__init__.py [3:13] - src/python/grpcio/grpc/framework/interfaces/base/base.py [3:13] - src/python/grpcio/grpc/framework/interfaces/base/utilities.py [3:13] - src/python/grpcio/grpc/framework/interfaces/face/__init__.py [3:13] - src/python/grpcio/grpc/framework/interfaces/face/face.py [3:13] - src/python/grpcio/grpc/framework/interfaces/face/utilities.py [3:13] - src/python/grpcio/grpc_core_dependencies.py [3:13] - src/python/grpcio/grpc_version.py [3:13] - src/python/grpcio/support.py [3:13] - src/python/grpcio_admin/grpc_admin/__init__.py [3:13] - src/python/grpcio_admin/grpc_version.py [3:13] - src/python/grpcio_admin/setup.py [3:13] - src/python/grpcio_channelz/channelz_commands.py [3:13] - src/python/grpcio_channelz/grpc_channelz/__init__.py [3:13] - src/python/grpcio_channelz/grpc_channelz/v1/__init__.py [3:13] - src/python/grpcio_channelz/grpc_channelz/v1/_async.py [3:13] - src/python/grpcio_channelz/grpc_channelz/v1/_servicer.py [3:13] - src/python/grpcio_channelz/grpc_channelz/v1/channelz.py [3:13] - src/python/grpcio_channelz/grpc_version.py [3:13] - src/python/grpcio_channelz/setup.py [3:13] - src/python/grpcio_csds/grpc_csds/__init__.py [3:13] - src/python/grpcio_csds/grpc_version.py [3:13] - src/python/grpcio_csds/setup.py [3:13] - src/python/grpcio_health_checking/grpc_health/__init__.py [3:13] - src/python/grpcio_health_checking/grpc_health/v1/__init__.py [3:13] - src/python/grpcio_health_checking/grpc_health/v1/_async.py [3:13] - src/python/grpcio_health_checking/grpc_health/v1/health.py [3:13] - src/python/grpcio_health_checking/grpc_version.py [3:13] - src/python/grpcio_health_checking/health_commands.py [3:13] - src/python/grpcio_health_checking/setup.py [3:13] - src/python/grpcio_reflection/grpc_reflection/__init__.py [3:13] - src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py [3:13] - src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py [3:13] - src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py [3:13] - src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py [3:13] - src/python/grpcio_reflection/grpc_version.py [3:13] - src/python/grpcio_reflection/reflection_commands.py [3:13] - src/python/grpcio_reflection/setup.py [3:13] - src/python/grpcio_status/grpc_status/__init__.py [3:13] - src/python/grpcio_status/grpc_status/_async.py [3:13] - src/python/grpcio_status/grpc_status/_common.py [3:13] - src/python/grpcio_status/grpc_status/rpc_status.py [3:13] - src/python/grpcio_status/grpc_version.py [3:13] - src/python/grpcio_status/setup.py [3:13] - src/python/grpcio_status/status_commands.py [3:13] - src/python/grpcio_testing/grpc_testing/__init__.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/__init__.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_channel.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_invocation.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py [3:13] - src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py [3:13] - src/python/grpcio_testing/grpc_testing/_common.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/__init__.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_handler.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_rpc.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_server.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_server_rpc.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_service.py [3:13] - src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py [3:13] - src/python/grpcio_testing/grpc_testing/_time.py [3:13] - src/python/grpcio_testing/grpc_version.py [3:13] - src/python/grpcio_testing/setup.py [3:13] - src/python/grpcio_testing/testing_commands.py [3:13] - src/python/grpcio_tests/commands.py [3:13] - src/python/grpcio_tests/grpc_version.py [3:13] - src/python/grpcio_tests/setup.py [3:13] - src/python/grpcio_tests/tests/__init__.py [3:13] - src/python/grpcio_tests/tests/_loader.py [3:13] - src/python/grpcio_tests/tests/_result.py [3:13] - src/python/grpcio_tests/tests/_runner.py [3:13] - src/python/grpcio_tests/tests/_sanity/__init__.py [3:13] - src/python/grpcio_tests/tests/_sanity/_sanity_test.py [3:13] - src/python/grpcio_tests/tests/admin/test_admin.py [3:13] - src/python/grpcio_tests/tests/bazel_namespace_package_hack.py [3:13] - src/python/grpcio_tests/tests/channelz/__init__.py [3:13] - src/python/grpcio_tests/tests/channelz/_channelz_servicer_test.py [3:13] - src/python/grpcio_tests/tests/csds/test_csds.py [3:13] - src/python/grpcio_tests/tests/fork/__init__.py [3:13] - src/python/grpcio_tests/tests/fork/_fork_interop_test.py [3:13] - src/python/grpcio_tests/tests/fork/client.py [3:13] - src/python/grpcio_tests/tests/fork/methods.py [3:13] - src/python/grpcio_tests/tests/health_check/__init__.py [3:13] - src/python/grpcio_tests/tests/health_check/_health_servicer_test.py [3:13] - src/python/grpcio_tests/tests/http2/negative_http2_client.py [3:13] - src/python/grpcio_tests/tests/interop/__init__.py [3:13] - src/python/grpcio_tests/tests/interop/_insecure_intraop_test.py [3:13] - src/python/grpcio_tests/tests/interop/_intraop_test_case.py [3:13] - src/python/grpcio_tests/tests/interop/_secure_intraop_test.py [3:13] - src/python/grpcio_tests/tests/interop/client.py [3:13] - src/python/grpcio_tests/tests/interop/methods.py [3:13] - src/python/grpcio_tests/tests/interop/resources.py [3:13] - src/python/grpcio_tests/tests/interop/server.py [3:13] - src/python/grpcio_tests/tests/interop/service.py [3:13] - src/python/grpcio_tests/tests/qps/__init__.py [3:13] - src/python/grpcio_tests/tests/qps/benchmark_client.py [3:13] - src/python/grpcio_tests/tests/qps/benchmark_server.py [3:13] - src/python/grpcio_tests/tests/qps/client_runner.py [3:13] - src/python/grpcio_tests/tests/qps/histogram.py [3:13] - src/python/grpcio_tests/tests/qps/qps_worker.py [3:13] - src/python/grpcio_tests/tests/qps/worker_server.py [3:13] - src/python/grpcio_tests/tests/reflection/__init__.py [3:13] - src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py [3:13] - src/python/grpcio_tests/tests/status/__init__.py [3:13] - src/python/grpcio_tests/tests/status/_grpc_status_test.py [3:13] - src/python/grpcio_tests/tests/stress/__init__.py [3:13] - src/python/grpcio_tests/tests/stress/client.py [3:13] - src/python/grpcio_tests/tests/stress/metrics_server.py [3:13] - src/python/grpcio_tests/tests/stress/test_runner.py [3:13] - src/python/grpcio_tests/tests/stress/unary_stream_benchmark.py [3:13] - src/python/grpcio_tests/tests/testing/__init__.py [3:13] - src/python/grpcio_tests/tests/testing/_application_common.py [3:13] - src/python/grpcio_tests/tests/testing/_application_testing_common.py [3:13] - src/python/grpcio_tests/tests/testing/_client_application.py [3:13] - src/python/grpcio_tests/tests/testing/_client_test.py [3:13] - src/python/grpcio_tests/tests/testing/_server_application.py [3:13] - src/python/grpcio_tests/tests/testing/_server_test.py [3:13] - src/python/grpcio_tests/tests/testing/_time_test.py [3:13] - src/python/grpcio_tests/tests/testing/proto/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/_abort_test.py [3:13] - src/python/grpcio_tests/tests/unit/_api_test.py [3:13] - src/python/grpcio_tests/tests/unit/_auth_context_test.py [3:13] - src/python/grpcio_tests/tests/unit/_auth_test.py [3:13] - src/python/grpcio_tests/tests/unit/_channel_args_test.py [3:13] - src/python/grpcio_tests/tests/unit/_channel_close_test.py [3:13] - src/python/grpcio_tests/tests/unit/_channel_connectivity_test.py [3:13] - src/python/grpcio_tests/tests/unit/_channel_ready_future_test.py [3:13] - src/python/grpcio_tests/tests/unit/_compression_test.py [3:13] - src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py [3:13] - src/python/grpcio_tests/tests/unit/_credentials_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_cancel_many_calls_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_channel_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_common.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_fork_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_no_messages_server_completion_queue_per_call_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_no_messages_single_server_completion_queue_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_read_some_but_not_all_responses_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/_server_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py [3:13] - src/python/grpcio_tests/tests/unit/_cython/test_utilities.py [3:13] - src/python/grpcio_tests/tests/unit/_dns_resolver_test.py [3:13] - src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py [3:13] - src/python/grpcio_tests/tests/unit/_empty_message_test.py [3:13] - src/python/grpcio_tests/tests/unit/_error_message_encoding_test.py [3:13] - src/python/grpcio_tests/tests/unit/_exit_scenarios.py [3:13] - src/python/grpcio_tests/tests/unit/_exit_test.py [3:13] - src/python/grpcio_tests/tests/unit/_from_grpc_import_star.py [3:13] - src/python/grpcio_tests/tests/unit/_grpc_shutdown_test.py [3:13] - src/python/grpcio_tests/tests/unit/_interceptor_test.py [3:13] - src/python/grpcio_tests/tests/unit/_invalid_metadata_test.py [3:13] - src/python/grpcio_tests/tests/unit/_invocation_defects_test.py [3:13] - src/python/grpcio_tests/tests/unit/_local_credentials_test.py [3:13] - src/python/grpcio_tests/tests/unit/_logging_test.py [3:13] - src/python/grpcio_tests/tests/unit/_metadata_code_details_test.py [3:13] - src/python/grpcio_tests/tests/unit/_metadata_flags_test.py [3:13] - src/python/grpcio_tests/tests/unit/_metadata_test.py [3:13] - src/python/grpcio_tests/tests/unit/_reconnect_test.py [3:13] - src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py [3:13] - src/python/grpcio_tests/tests/unit/_rpc_part_1_test.py [3:13] - src/python/grpcio_tests/tests/unit/_rpc_part_2_test.py [3:13] - src/python/grpcio_tests/tests/unit/_rpc_test_helpers.py [3:13] - src/python/grpcio_tests/tests/unit/_server_shutdown_scenarios.py [3:13] - src/python/grpcio_tests/tests/unit/_server_shutdown_test.py [3:13] - src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py [3:13] - src/python/grpcio_tests/tests/unit/_server_test.py [3:13] - src/python/grpcio_tests/tests/unit/_server_wait_for_termination_test.py [3:13] - src/python/grpcio_tests/tests/unit/_session_cache_test.py [3:13] - src/python/grpcio_tests/tests/unit/_signal_client.py [3:13] - src/python/grpcio_tests/tests/unit/_signal_handling_test.py [3:13] - src/python/grpcio_tests/tests/unit/_tcp_proxy.py [3:13] - src/python/grpcio_tests/tests/unit/_version_test.py [3:13] - src/python/grpcio_tests/tests/unit/_xds_credentials_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/beta/_beta_features_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/_connectivity_channel_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/_implementations_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/_not_found_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/_utilities_test.py [3:13] - src/python/grpcio_tests/tests/unit/beta/test_utilities.py [3:13] - src/python/grpcio_tests/tests/unit/framework/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/framework/common/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/framework/common/test_constants.py [3:13] - src/python/grpcio_tests/tests/unit/framework/common/test_control.py [3:13] - src/python/grpcio_tests/tests/unit/framework/common/test_coverage.py [3:13] - src/python/grpcio_tests/tests/unit/framework/foundation/__init__.py [3:13] - src/python/grpcio_tests/tests/unit/framework/foundation/_logging_pool_test.py [3:13] - src/python/grpcio_tests/tests/unit/framework/foundation/stream_testing.py [3:13] - src/python/grpcio_tests/tests/unit/resources.py [3:13] - src/python/grpcio_tests/tests/unit/test_common.py [3:13] - src/python/grpcio_tests/tests/unit/thread_pool.py [3:13] - src/python/grpcio_tests/tests_aio/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/_sanity/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/_sanity/_sanity_test.py [3:13] - src/python/grpcio_tests/tests_aio/benchmark/benchmark_client.py [3:13] - src/python/grpcio_tests/tests_aio/benchmark/benchmark_servicer.py [3:13] - src/python/grpcio_tests/tests_aio/benchmark/server.py [3:13] - src/python/grpcio_tests/tests_aio/benchmark/worker.py [3:13] - src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py [3:13] - src/python/grpcio_tests/tests_aio/channelz/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/channelz/channelz_servicer_test.py [3:13] - src/python/grpcio_tests/tests_aio/health_check/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py [3:13] - src/python/grpcio_tests/tests_aio/interop/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/interop/client.py [3:13] - src/python/grpcio_tests/tests_aio/interop/local_interop_test.py [3:13] - src/python/grpcio_tests/tests_aio/interop/methods.py [3:13] - src/python/grpcio_tests/tests_aio/interop/server.py [3:13] - src/python/grpcio_tests/tests_aio/reflection/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/reflection/reflection_servicer_test.py [3:13] - src/python/grpcio_tests/tests_aio/status/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/status/grpc_status_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/__init__.py [3:13] - src/python/grpcio_tests/tests_aio/unit/_common.py [3:13] - src/python/grpcio_tests/tests_aio/unit/_constants.py [3:13] - src/python/grpcio_tests/tests_aio/unit/_metadata_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/_test_base.py [3:13] - src/python/grpcio_tests/tests_aio/unit/_test_server.py [3:13] - src/python/grpcio_tests/tests_aio/unit/abort_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/aio_rpc_error_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/auth_context_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/call_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/channel_argument_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/channel_ready_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/channel_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/client_stream_stream_interceptor_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/client_stream_unary_interceptor_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/client_unary_stream_interceptor_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/client_unary_unary_interceptor_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/close_channel_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/compatibility_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/compression_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/connectivity_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/context_peer_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/done_callback_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/init_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/metadata_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/outside_init_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/secure_call_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/server_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/server_time_remaining_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/timeout_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/wait_for_connection_test.py [3:13] - src/python/grpcio_tests/tests_aio/unit/wait_for_ready_test.py [3:13] - src/python/grpcio_tests/tests_gevent/__init__.py [3:13] - src/python/grpcio_tests/tests_gevent/unit/__init__.py [3:13] - src/python/grpcio_tests/tests_gevent/unit/_test_server.py [3:13] - src/python/grpcio_tests/tests_gevent/unit/close_channel_test.py [3:13] - src/python/grpcio_tests/tests_py3_only/__init__.py [3:13] - src/python/grpcio_tests/tests_py3_only/interop/xds_interop_client.py [3:13] - src/python/grpcio_tests/tests_py3_only/interop/xds_interop_server.py [3:13] - src/python/grpcio_tests/tests_py3_only/unit/__init__.py [3:13] - src/python/grpcio_tests/tests_py3_only/unit/_leak_test.py [3:13] - src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py [3:13] - test/core/util/fuzzer_one_entry_runner.sh [7:17] - test/core/util/grpc_fuzzer.bzl [3:13] - test/core/util/run_with_poller.sh [4:14] - -SKIP LicenseRef-scancode-generic-cla 979d7de2e3ff119ee2c22c7efbec766d -BELONGS third_party/upb/ya.make - License text: - Contributions to this project must be accompanied by a Contributor License - Agreement. You (or your employer) retain the copyright to your contribution; - Scancode info: - Original SPDX id: LicenseRef-scancode-generic-cla - Score : 16.00 - Match type : NOTICE - Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/generic-cla.LICENSE - Files with this license: - third_party/upb/CONTRIBUTING.md [17:18] - -KEEP BSD-3-Clause 9f9f74951499b982d601e33ab0c03bed -BELONGS third_party/address_sorting/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 100.00 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/address_sorting/address_sorting.c [7:29] - third_party/address_sorting/address_sorting_internal.h [7:29] - third_party/address_sorting/address_sorting_posix.c [7:29] - third_party/address_sorting/address_sorting_windows.c [7:29] - third_party/address_sorting/include/address_sorting/address_sorting.h [7:29] - -SKIP Apache-2.0 a43fad4c0dc18af39e265ae52fbddc81 -BELONGS src/python/grpcio_channelz/ya.make - License text: - license='Apache License 2.0', - Scancode info: - Original SPDX id: Apache-2.0 - Score : 100.00 - Match type : REFERENCE - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - src/python/grpcio_channelz/setup.py [92:92] - -KEEP Apache-2.0 ac31f6a0b836e647d840630a3723a387 -BELONGS src/python/grpcio_channelz/ya.make src/python/grpcio_health_checking/ya.make src/python/grpcio_reflection/ya.make src/python/grpcio_status/ya.make ya.make - License text: - 'License :: OSI Approved :: Apache Software License', - Scancode info: - Original SPDX id: Apache-2.0 - Score : 95.00 - Match type : TAG - Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 - Files with this license: - src/python/grpcio_admin/setup.py [34:34] - src/python/grpcio_channelz/setup.py [58:58] - src/python/grpcio_csds/setup.py [34:34] - src/python/grpcio_health_checking/setup.py [57:57] - src/python/grpcio_reflection/setup.py [58:58] - src/python/grpcio_status/setup.py [57:57] - -KEEP BSD-3-Clause add163b149a20e4f3cd8c4cc3e9d0ccd -BELONGS third_party/upb/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 97.64 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/upb/upb/def.hpp [4:24] - third_party/upb/upb/upb.hpp [4:24] - -KEEP BSD-3-Clause bf460a928b270e23d6623d4db9286950 -BELONGS ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 100.00 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - LICENSE [210:234] - -KEEP Python-2.0 e9022919a04d4f5ef8123bee0fe8df07 -BELONGS ya.make - License text: - \# limitations under the License. - """gRPC Python's Admin interface.""" - Scancode info: - Original SPDX id: Python-2.0 - Score : 66.67 - Match type : TAG - Links : http://docs.python.org/license.html, http://spdx.org/licenses/Python-2.0, https://spdx.org/licenses/Python-2.0 - Files with this license: - src/python/grpcio_admin/grpc_admin/__init__.py [13:14] - -KEEP BSD-3-Clause ecc97a1dce30b0ce4682e454b0ca278f -BELONGS third_party/upb/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 96.55 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/upb/LICENSE [5:26] - -KEEP BSD-3-Clause efdacd288befe1a76f28537587b3936a -BELONGS ya.make - License text: - limitations under the License. - ----------------------------------------------------------- - BSD 3-Clause License - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 100.00 - Match type : TAG - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - LICENSE [202:206] - -KEEP BSD-3-Clause AND BSD-3-Clause fde36bbb770be6f9bbc06c49635a8e3a -BELONGS third_party/upb/ya.make - Note: matched license text is too long. Read it in the source files. - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 97.64 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/upb/upb/decode.c [5:25] - third_party/upb/upb/decode.h [5:25] - third_party/upb/upb/decode_internal.h [5:25] - third_party/upb/upb/def.c [5:25] - third_party/upb/upb/def.h [5:25] - third_party/upb/upb/encode.c [5:25] - third_party/upb/upb/encode.h [5:25] - third_party/upb/upb/msg.c [5:25] - third_party/upb/upb/msg.h [5:25] - third_party/upb/upb/port_def.inc [5:25] - third_party/upb/upb/port_undef.inc [5:25] - third_party/upb/upb/reflection.c [5:25] - third_party/upb/upb/reflection.h [5:25] - third_party/upb/upb/table.c [5:25] - third_party/upb/upb/table_internal.h [5:25] - third_party/upb/upb/text_encode.c [5:25] - third_party/upb/upb/text_encode.h [5:25] - third_party/upb/upb/upb.c [5:25] - third_party/upb/upb/upb.h [5:25] - third_party/upb/upb/upb_internal.h [5:25] - Scancode info: - Original SPDX id: BSD-3-Clause - Score : 98.09 - Match type : TEXT - Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause - Files with this license: - third_party/upb/upb/decode_fast.c [5:25] - third_party/upb/upb/decode_fast.h [5:25] diff --git a/contrib/libs/grpc/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/.yandex_meta/licenses.list.txt deleted file mode 100644 index 5fdb008b50..0000000000 --- a/contrib/libs/grpc/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,375 +0,0 @@ -====================Apache-2.0==================== - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. - - -====================Apache-2.0==================== - license='Apache License 2.0', - - -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -# 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. - - -====================Apache-2.0==================== -// 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. - - -====================Apache-2.0==================== -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. - -====================BSD-3-Clause==================== - limitations under the License. - ------------------------------------------------------------ - -BSD 3-Clause License - - -====================BSD-3-Clause==================== -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from this -software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2019 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2015 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2016 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2018 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. - - -====================COPYRIGHT==================== -Copyright 2014 gRPC authors. - - -====================COPYRIGHT==================== -Copyright 2016, Google Inc. - - -====================MPL-2.0==================== -Mozilla Public License, v. 2.0 - - -====================MPL-2.0==================== -This Source Code Form is subject to the terms of the Mozilla Public License, -v. 2.0. If a copy of the MPL was not distributed with this file, You can -obtain one at https://mozilla.org/MPL/2.0/. - -====================Python-2.0==================== -# limitations under the License. -"""gRPC Python's Admin interface.""" diff --git a/contrib/libs/grpc/include/grpc++/channel.h b/contrib/libs/grpc/include/grpc++/channel.h deleted file mode 100644 index b1154cefb3..0000000000 --- a/contrib/libs/grpc/include/grpc++/channel.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_CHANNEL_H -#define GRPCXX_CHANNEL_H - -#include <grpcpp/channel.h> - -#endif // GRPCXX_CHANNEL_H diff --git a/contrib/libs/grpc/include/grpc++/completion_queue.h b/contrib/libs/grpc/include/grpc++/completion_queue.h deleted file mode 100644 index 98ef18f0f6..0000000000 --- a/contrib/libs/grpc/include/grpc++/completion_queue.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_COMPLETION_QUEUE_H -#define GRPCXX_COMPLETION_QUEUE_H - -#include <grpcpp/completion_queue.h> - -#endif // GRPCXX_COMPLETION_QUEUE_H diff --git a/contrib/libs/grpc/include/grpc++/create_channel_posix.h b/contrib/libs/grpc/include/grpc++/create_channel_posix.h deleted file mode 100644 index 8c8983ba60..0000000000 --- a/contrib/libs/grpc/include/grpc++/create_channel_posix.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_CREATE_CHANNEL_POSIX_H -#define GRPCXX_CREATE_CHANNEL_POSIX_H - -#include <grpcpp/create_channel_posix.h> - -#endif // GRPCXX_CREATE_CHANNEL_POSIX_H diff --git a/contrib/libs/grpc/include/grpc++/ext/health_check_service_server_builder_option.h b/contrib/libs/grpc/include/grpc++/ext/health_check_service_server_builder_option.h deleted file mode 100644 index cb82fc03b6..0000000000 --- a/contrib/libs/grpc/include/grpc++/ext/health_check_service_server_builder_option.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H -#define GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H - -#include <grpcpp/ext/health_check_service_server_builder_option.h> - -#endif // GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H diff --git a/contrib/libs/grpc/include/grpc++/ext/proto_server_reflection_plugin.h b/contrib/libs/grpc/include/grpc++/ext/proto_server_reflection_plugin.h deleted file mode 100644 index 02e21b9219..0000000000 --- a/contrib/libs/grpc/include/grpc++/ext/proto_server_reflection_plugin.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H -#define GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H - -#include <grpcpp/ext/proto_server_reflection_plugin.h> - -#endif // GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H diff --git a/contrib/libs/grpc/include/grpc++/generic/async_generic_service.h b/contrib/libs/grpc/include/grpc++/generic/async_generic_service.h deleted file mode 100644 index d3283fac6f..0000000000 --- a/contrib/libs/grpc/include/grpc++/generic/async_generic_service.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H -#define GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H - -#include <grpcpp/generic/async_generic_service.h> - -#endif // GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H diff --git a/contrib/libs/grpc/include/grpc++/generic/generic_stub.h b/contrib/libs/grpc/include/grpc++/generic/generic_stub.h deleted file mode 100644 index 502953b5de..0000000000 --- a/contrib/libs/grpc/include/grpc++/generic/generic_stub.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_GENERIC_GENERIC_STUB_H -#define GRPCXX_GENERIC_GENERIC_STUB_H - -#include <grpcpp/generic/generic_stub.h> - -#endif // GRPCXX_GENERIC_GENERIC_STUB_H diff --git a/contrib/libs/grpc/include/grpc++/health_check_service_interface.h b/contrib/libs/grpc/include/grpc++/health_check_service_interface.h deleted file mode 100644 index 0cb0668e48..0000000000 --- a/contrib/libs/grpc/include/grpc++/health_check_service_interface.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H -#define GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H - -#include <grpcpp/health_check_service_interface.h> - -#endif // GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H diff --git a/contrib/libs/grpc/include/grpc++/impl/call.h b/contrib/libs/grpc/include/grpc++/impl/call.h deleted file mode 100644 index b1da2b6358..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/call.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CALL_H -#define GRPCXX_IMPL_CALL_H - -#include <grpcpp/impl/call.h> - -#endif // GRPCXX_IMPL_CALL_H diff --git a/contrib/libs/grpc/include/grpc++/impl/channel_argument_option.h b/contrib/libs/grpc/include/grpc++/impl/channel_argument_option.h deleted file mode 100644 index 3468378de6..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/channel_argument_option.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H -#define GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H - -#include <grpcpp/impl/channel_argument_option.h> - -#endif // GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H diff --git a/contrib/libs/grpc/include/grpc++/impl/client_unary_call.h b/contrib/libs/grpc/include/grpc++/impl/client_unary_call.h deleted file mode 100644 index 75e656071f..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/client_unary_call.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H -#define GRPCXX_IMPL_CLIENT_UNARY_CALL_H - -#include <grpcpp/impl/client_unary_call.h> - -#endif // GRPCXX_IMPL_CLIENT_UNARY_CALL_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/call.h b/contrib/libs/grpc/include/grpc++/impl/codegen/call.h deleted file mode 100644 index dadab5454a..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/call.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CALL_H -#define GRPCXX_IMPL_CODEGEN_CALL_H - -#include <grpcpp/impl/codegen/call.h> - -#endif // GRPCXX_IMPL_CODEGEN_CALL_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/call_hook.h b/contrib/libs/grpc/include/grpc++/impl/codegen/call_hook.h deleted file mode 100644 index cf5ed571b2..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/call_hook.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CALL_HOOK_H -#define GRPCXX_IMPL_CODEGEN_CALL_HOOK_H - -#include <grpcpp/impl/codegen/call_hook.h> - -#endif // GRPCXX_IMPL_CODEGEN_CALL_HOOK_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/client_context.h b/contrib/libs/grpc/include/grpc++/impl/codegen/client_context.h deleted file mode 100644 index 107532cb6b..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/client_context.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H -#define GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H - -#include <grpcpp/impl/codegen/client_context.h> - -#endif // GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue.h b/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue.h deleted file mode 100644 index 107549550b..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H -#define GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H - -#include <grpcpp/impl/codegen/completion_queue.h> - -#endif // GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue_tag.h b/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue_tag.h deleted file mode 100644 index 994fa2a904..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/completion_queue_tag.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H -#define GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H - -#include <grpcpp/impl/codegen/completion_queue_tag.h> - -#endif // GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/config.h b/contrib/libs/grpc/include/grpc++/impl/codegen/config.h deleted file mode 100644 index 237bf38d3e..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_H -#define GRPCXX_IMPL_CODEGEN_CONFIG_H - -#include <grpcpp/impl/codegen/config.h> - -#endif // GRPCXX_IMPL_CODEGEN_CONFIG_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/config_protobuf.h b/contrib/libs/grpc/include/grpc++/impl/codegen/config_protobuf.h deleted file mode 100644 index debd74aae7..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/config_protobuf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H -#define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H - -#include <grpcpp/impl/codegen/config_protobuf.h> - -#endif // GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen.h b/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen.h deleted file mode 100644 index ee600a9d12..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H -#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H - -#include <grpcpp/impl/codegen/core_codegen.h> - -#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen_interface.h b/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen_interface.h deleted file mode 100644 index 03b3f675e1..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/core_codegen_interface.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H -#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H - -#include <grpcpp/impl/codegen/core_codegen_interface.h> - -#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/create_auth_context.h b/contrib/libs/grpc/include/grpc++/impl/codegen/create_auth_context.h deleted file mode 100644 index ef89229f4d..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/create_auth_context.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H -#define GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H - -#include <grpcpp/impl/codegen/create_auth_context.h> - -#endif // GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/grpc_library.h b/contrib/libs/grpc/include/grpc++/impl/codegen/grpc_library.h deleted file mode 100644 index 33c3e2546c..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/grpc_library.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H -#define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H - -#include <grpcpp/impl/codegen/grpc_library.h> - -#endif // GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/metadata_map.h b/contrib/libs/grpc/include/grpc++/impl/codegen/metadata_map.h deleted file mode 100644 index 41c5ad375e..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/metadata_map.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_METADATA_MAP_H -#define GRPCXX_IMPL_CODEGEN_METADATA_MAP_H - -#include <grpcpp/impl/codegen/metadata_map.h> - -#endif // GRPCXX_IMPL_CODEGEN_METADATA_MAP_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/security/auth_context.h b/contrib/libs/grpc/include/grpc++/impl/codegen/security/auth_context.h deleted file mode 100644 index b4663739a6..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/security/auth_context.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H -#define GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H - -#include <grpcpp/impl/codegen/security/auth_context.h> - -#endif // GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/serialization_traits.h b/contrib/libs/grpc/include/grpc++/impl/codegen/serialization_traits.h deleted file mode 100644 index 480575d109..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/serialization_traits.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H -#define GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H - -#include <grpcpp/impl/codegen/serialization_traits.h> - -#endif // GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/server_context.h b/contrib/libs/grpc/include/grpc++/impl/codegen/server_context.h deleted file mode 100644 index 1c3342d5d4..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/server_context.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H -#define GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H - -#include <grpcpp/impl/codegen/server_context.h> - -#endif // GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/server_interface.h b/contrib/libs/grpc/include/grpc++/impl/codegen/server_interface.h deleted file mode 100644 index ceea44c50c..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/server_interface.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H -#define GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H - -#include <grpcpp/impl/codegen/server_interface.h> - -#endif // GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/slice.h b/contrib/libs/grpc/include/grpc++/impl/codegen/slice.h deleted file mode 100644 index 6714badc37..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/slice.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_SLICE_H -#define GRPCXX_IMPL_CODEGEN_SLICE_H - -#include <grpcpp/impl/codegen/slice.h> - -#endif // GRPCXX_IMPL_CODEGEN_SLICE_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/status_code_enum.h b/contrib/libs/grpc/include/grpc++/impl/codegen/status_code_enum.h deleted file mode 100644 index 7503eaeeca..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/status_code_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H -#define GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H - -#include <grpcpp/impl/codegen/status_code_enum.h> - -#endif // GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/string_ref.h b/contrib/libs/grpc/include/grpc++/impl/codegen/string_ref.h deleted file mode 100644 index 66e250efdd..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/string_ref.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_STRING_REF_H -#define GRPCXX_IMPL_CODEGEN_STRING_REF_H - -#include <grpcpp/impl/codegen/string_ref.h> - -#endif // GRPCXX_IMPL_CODEGEN_STRING_REF_H diff --git a/contrib/libs/grpc/include/grpc++/impl/codegen/time.h b/contrib/libs/grpc/include/grpc++/impl/codegen/time.h deleted file mode 100644 index f9b70f8313..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/codegen/time.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_CODEGEN_TIME_H -#define GRPCXX_IMPL_CODEGEN_TIME_H - -#include <grpcpp/impl/codegen/time.h> - -#endif // GRPCXX_IMPL_CODEGEN_TIME_H diff --git a/contrib/libs/grpc/include/grpc++/impl/method_handler_impl.h b/contrib/libs/grpc/include/grpc++/impl/method_handler_impl.h deleted file mode 100644 index 3840f48742..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/method_handler_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_METHOD_HANDLER_IMPL_H -#define GRPCXX_IMPL_METHOD_HANDLER_IMPL_H - -#include <grpcpp/impl/method_handler_impl.h> - -#endif // GRPCXX_IMPL_METHOD_HANDLER_IMPL_H diff --git a/contrib/libs/grpc/include/grpc++/impl/rpc_method.h b/contrib/libs/grpc/include/grpc++/impl/rpc_method.h deleted file mode 100644 index 7cba7c40c4..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/rpc_method.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_RPC_METHOD_H -#define GRPCXX_IMPL_RPC_METHOD_H - -#include <grpcpp/impl/rpc_method.h> - -#endif // GRPCXX_IMPL_RPC_METHOD_H diff --git a/contrib/libs/grpc/include/grpc++/impl/rpc_service_method.h b/contrib/libs/grpc/include/grpc++/impl/rpc_service_method.h deleted file mode 100644 index 2c75087b7c..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/rpc_service_method.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_RPC_SERVICE_METHOD_H -#define GRPCXX_IMPL_RPC_SERVICE_METHOD_H - -#include <grpcpp/impl/rpc_service_method.h> - -#endif // GRPCXX_IMPL_RPC_SERVICE_METHOD_H diff --git a/contrib/libs/grpc/include/grpc++/impl/serialization_traits.h b/contrib/libs/grpc/include/grpc++/impl/serialization_traits.h deleted file mode 100644 index 33b3a0bb31..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/serialization_traits.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_SERIALIZATION_TRAITS_H -#define GRPCXX_IMPL_SERIALIZATION_TRAITS_H - -#include <grpcpp/impl/serialization_traits.h> - -#endif // GRPCXX_IMPL_SERIALIZATION_TRAITS_H diff --git a/contrib/libs/grpc/include/grpc++/impl/server_builder_option.h b/contrib/libs/grpc/include/grpc++/impl/server_builder_option.h deleted file mode 100644 index 833f8db772..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/server_builder_option.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_SERVER_BUILDER_OPTION_H -#define GRPCXX_IMPL_SERVER_BUILDER_OPTION_H - -#include <grpcpp/impl/server_builder_option.h> - -#endif // GRPCXX_IMPL_SERVER_BUILDER_OPTION_H diff --git a/contrib/libs/grpc/include/grpc++/impl/server_builder_plugin.h b/contrib/libs/grpc/include/grpc++/impl/server_builder_plugin.h deleted file mode 100644 index 844d32c55f..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/server_builder_plugin.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H -#define GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H - -#include <grpcpp/impl/server_builder_plugin.h> - -#endif // GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H diff --git a/contrib/libs/grpc/include/grpc++/impl/server_initializer.h b/contrib/libs/grpc/include/grpc++/impl/server_initializer.h deleted file mode 100644 index 6a1669ccf5..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/server_initializer.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_SERVER_INITIALIZER_H -#define GRPCXX_IMPL_SERVER_INITIALIZER_H - -#include <grpcpp/impl/server_initializer.h> - -#endif // GRPCXX_IMPL_SERVER_INITIALIZER_H diff --git a/contrib/libs/grpc/include/grpc++/impl/service_type.h b/contrib/libs/grpc/include/grpc++/impl/service_type.h deleted file mode 100644 index 86422160d4..0000000000 --- a/contrib/libs/grpc/include/grpc++/impl/service_type.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_IMPL_SERVICE_TYPE_H -#define GRPCXX_IMPL_SERVICE_TYPE_H - -#include <grpcpp/impl/service_type.h> - -#endif // GRPCXX_IMPL_SERVICE_TYPE_H diff --git a/contrib/libs/grpc/include/grpc++/security/auth_context.h b/contrib/libs/grpc/include/grpc++/security/auth_context.h deleted file mode 100644 index 9fe59d448e..0000000000 --- a/contrib/libs/grpc/include/grpc++/security/auth_context.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SECURITY_AUTH_CONTEXT_H -#define GRPCXX_SECURITY_AUTH_CONTEXT_H - -#include <grpcpp/security/auth_context.h> - -#endif // GRPCXX_SECURITY_AUTH_CONTEXT_H diff --git a/contrib/libs/grpc/include/grpc++/security/auth_metadata_processor.h b/contrib/libs/grpc/include/grpc++/security/auth_metadata_processor.h deleted file mode 100644 index d045313965..0000000000 --- a/contrib/libs/grpc/include/grpc++/security/auth_metadata_processor.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H -#define GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H - -#include <grpcpp/security/auth_metadata_processor.h> - -#endif // GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H diff --git a/contrib/libs/grpc/include/grpc++/security/credentials.h b/contrib/libs/grpc/include/grpc++/security/credentials.h deleted file mode 100644 index 940441827d..0000000000 --- a/contrib/libs/grpc/include/grpc++/security/credentials.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SECURITY_CREDENTIALS_H -#define GRPCXX_SECURITY_CREDENTIALS_H - -#include <grpcpp/security/credentials.h> - -#endif // GRPCXX_SECURITY_CREDENTIALS_H diff --git a/contrib/libs/grpc/include/grpc++/server_posix.h b/contrib/libs/grpc/include/grpc++/server_posix.h deleted file mode 100644 index d2866d9640..0000000000 --- a/contrib/libs/grpc/include/grpc++/server_posix.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SERVER_POSIX_H -#define GRPCXX_SERVER_POSIX_H - -#include <grpcpp/server_posix.h> - -#endif // GRPCXX_SERVER_POSIX_H diff --git a/contrib/libs/grpc/include/grpc++/support/channel_arguments.h b/contrib/libs/grpc/include/grpc++/support/channel_arguments.h deleted file mode 100644 index 6d5300ccb7..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/channel_arguments.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H -#define GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H - -#include <grpcpp/support/channel_arguments.h> - -#endif // GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H diff --git a/contrib/libs/grpc/include/grpc++/support/config.h b/contrib/libs/grpc/include/grpc++/support/config.h deleted file mode 100644 index f8eee5075a..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_CONFIG_H -#define GRPCXX_SUPPORT_CONFIG_H - -#include <grpcpp/support/config.h> - -#endif // GRPCXX_SUPPORT_CONFIG_H diff --git a/contrib/libs/grpc/include/grpc++/support/error_details.h b/contrib/libs/grpc/include/grpc++/support/error_details.h deleted file mode 100644 index 7ace308e52..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/error_details.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_ERROR_DETAILS_H -#define GRPCXX_SUPPORT_ERROR_DETAILS_H - -#include <grpcpp/support/error_details.h> - -#endif // GRPCXX_SUPPORT_ERROR_DETAILS_H diff --git a/contrib/libs/grpc/include/grpc++/support/status.h b/contrib/libs/grpc/include/grpc++/support/status.h deleted file mode 100644 index e58a18bdf9..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/status.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_STATUS_H -#define GRPCXX_SUPPORT_STATUS_H - -#include <grpcpp/support/status.h> - -#endif // GRPCXX_SUPPORT_STATUS_H diff --git a/contrib/libs/grpc/include/grpc++/support/status_code_enum.h b/contrib/libs/grpc/include/grpc++/support/status_code_enum.h deleted file mode 100644 index c278add0c6..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/status_code_enum.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_STATUS_CODE_ENUM_H -#define GRPCXX_SUPPORT_STATUS_CODE_ENUM_H - -#include <grpcpp/support/status_code_enum.h> - -#endif // GRPCXX_SUPPORT_STATUS_CODE_ENUM_H diff --git a/contrib/libs/grpc/include/grpc++/support/string_ref.h b/contrib/libs/grpc/include/grpc++/support/string_ref.h deleted file mode 100644 index 49de6dafce..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/string_ref.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_STRING_REF_H -#define GRPCXX_SUPPORT_STRING_REF_H - -#include <grpcpp/support/string_ref.h> - -#endif // GRPCXX_SUPPORT_STRING_REF_H diff --git a/contrib/libs/grpc/include/grpc++/support/stub_options.h b/contrib/libs/grpc/include/grpc++/support/stub_options.h deleted file mode 100644 index a712ce8716..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/stub_options.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_STUB_OPTIONS_H -#define GRPCXX_SUPPORT_STUB_OPTIONS_H - -#include <grpcpp/support/stub_options.h> - -#endif // GRPCXX_SUPPORT_STUB_OPTIONS_H diff --git a/contrib/libs/grpc/include/grpc++/support/sync_stream.h b/contrib/libs/grpc/include/grpc++/support/sync_stream.h deleted file mode 100644 index c118df9f7b..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/sync_stream.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_SYNC_STREAM_H -#define GRPCXX_SUPPORT_SYNC_STREAM_H - -#include <grpcpp/support/sync_stream.h> - -#endif // GRPCXX_SUPPORT_SYNC_STREAM_H diff --git a/contrib/libs/grpc/include/grpc++/support/time.h b/contrib/libs/grpc/include/grpc++/support/time.h deleted file mode 100644 index d356b91001..0000000000 --- a/contrib/libs/grpc/include/grpc++/support/time.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_SUPPORT_TIME_H -#define GRPCXX_SUPPORT_TIME_H - -#include <grpcpp/support/time.h> - -#endif // GRPCXX_SUPPORT_TIME_H diff --git a/contrib/libs/grpc/include/grpc++/test/mock_stream.h b/contrib/libs/grpc/include/grpc++/test/mock_stream.h deleted file mode 100644 index a29345b061..0000000000 --- a/contrib/libs/grpc/include/grpc++/test/mock_stream.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_TEST_MOCK_STREAM_H -#define GRPCXX_TEST_MOCK_STREAM_H - -#include <grpcpp/test/mock_stream.h> - -#endif // GRPCXX_TEST_MOCK_STREAM_H diff --git a/contrib/libs/grpc/include/grpc++/test/server_context_test_spouse.h b/contrib/libs/grpc/include/grpc++/test/server_context_test_spouse.h deleted file mode 100644 index 48a4838c2d..0000000000 --- a/contrib/libs/grpc/include/grpc++/test/server_context_test_spouse.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the -// headers in include/grpcpp instead. This header exists only for backwards -// compatibility. - -#ifndef GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H -#define GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H - -#include <grpcpp/test/server_context_test_spouse.h> - -#endif // GRPCXX_TEST_SERVER_CONTEXT_TEST_SPOUSE_H diff --git a/contrib/libs/grpc/include/grpc/grpc_cronet.h b/contrib/libs/grpc/include/grpc/grpc_cronet.h deleted file mode 100644 index 289cfcda67..0000000000 --- a/contrib/libs/grpc/include/grpc/grpc_cronet.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Copyright 2016 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_GRPC_CRONET_H -#define GRPC_GRPC_CRONET_H - -#include <grpc/support/port_platform.h> - -#include <grpc/grpc.h> - -#ifdef __cplusplus -extern "C" { -#endif - -GRPCAPI grpc_channel* grpc_cronet_secure_channel_create( - void* engine, const char* target, const grpc_channel_args* args, - void* reserved); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_GRPC_CRONET_H */ diff --git a/contrib/libs/grpc/include/grpc/module.modulemap b/contrib/libs/grpc/include/grpc/module.modulemap deleted file mode 100644 index 40606e5601..0000000000 --- a/contrib/libs/grpc/include/grpc/module.modulemap +++ /dev/null @@ -1,64 +0,0 @@ - -framework module grpc { - umbrella header "grpc.h" - -header "byte_buffer.h" - header "byte_buffer_reader.h" - header "census.h" - header "compression.h" - header "fork.h" - header "grpc.h" - header "grpc_posix.h" - header "grpc_security.h" - header "grpc_security_constants.h" - header "impl/codegen/atm.h" - header "impl/codegen/byte_buffer.h" - header "impl/codegen/byte_buffer_reader.h" - header "impl/codegen/compression_types.h" - header "impl/codegen/connectivity_state.h" - header "impl/codegen/fork.h" - header "impl/codegen/gpr_slice.h" - header "impl/codegen/gpr_types.h" - header "impl/codegen/grpc_types.h" - header "impl/codegen/log.h" - header "impl/codegen/port_platform.h" - header "impl/codegen/propagation_bits.h" - header "impl/codegen/slice.h" - header "impl/codegen/status.h" - header "impl/codegen/sync.h" - header "impl/codegen/sync_abseil.h" - header "impl/codegen/sync_generic.h" - header "load_reporting.h" - header "slice.h" - header "slice_buffer.h" - header "status.h" - header "support/alloc.h" - header "support/atm.h" - header "support/cpu.h" - header "support/log.h" - header "support/log_windows.h" - header "support/port_platform.h" - header "support/string_util.h" - header "support/sync.h" - header "support/sync_abseil.h" - header "support/sync_generic.h" - header "support/thd_id.h" - header "support/time.h" - header "support/workaround_list.h" - -textual header "impl/codegen/atm_gcc_atomic.h" - textual header "impl/codegen/atm_gcc_sync.h" - textual header "impl/codegen/atm_windows.h" - textual header "impl/codegen/sync_custom.h" - textual header "impl/codegen/sync_posix.h" - textual header "impl/codegen/sync_windows.h" - textual header "support/atm_gcc_atomic.h" - textual header "support/atm_gcc_sync.h" - textual header "support/atm_windows.h" - textual header "support/sync_custom.h" - textual header "support/sync_posix.h" - textual header "support/sync_windows.h" - - export * - module * { export * } -} diff --git a/contrib/libs/grpc/include/grpc/support/atm_gcc_atomic.h b/contrib/libs/grpc/include/grpc/support/atm_gcc_atomic.h deleted file mode 100644 index 8226349f25..0000000000 --- a/contrib/libs/grpc/include/grpc/support/atm_gcc_atomic.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_ATM_GCC_ATOMIC_H -#define GRPC_SUPPORT_ATM_GCC_ATOMIC_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/atm_gcc_atomic.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_ATM_GCC_ATOMIC_H */ diff --git a/contrib/libs/grpc/include/grpc/support/atm_gcc_sync.h b/contrib/libs/grpc/include/grpc/support/atm_gcc_sync.h deleted file mode 100644 index 500a9f14d5..0000000000 --- a/contrib/libs/grpc/include/grpc/support/atm_gcc_sync.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_ATM_GCC_SYNC_H -#define GRPC_SUPPORT_ATM_GCC_SYNC_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/atm_gcc_sync.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_ATM_GCC_SYNC_H */ diff --git a/contrib/libs/grpc/include/grpc/support/atm_windows.h b/contrib/libs/grpc/include/grpc/support/atm_windows.h deleted file mode 100644 index b85d7f747d..0000000000 --- a/contrib/libs/grpc/include/grpc/support/atm_windows.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_ATM_WINDOWS_H -#define GRPC_SUPPORT_ATM_WINDOWS_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/atm_windows.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_ATM_WINDOWS_H */ diff --git a/contrib/libs/grpc/include/grpc/support/sync_abseil.h b/contrib/libs/grpc/include/grpc/support/sync_abseil.h deleted file mode 100644 index d6ad969273..0000000000 --- a/contrib/libs/grpc/include/grpc/support/sync_abseil.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2020 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_SUPPORT_SYNC_ABSEIL_H -#define GRPC_SUPPORT_SYNC_ABSEIL_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/sync_abseil.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_SYNC_ABSEIL_H */ diff --git a/contrib/libs/grpc/include/grpc/support/sync_custom.h b/contrib/libs/grpc/include/grpc/support/sync_custom.h deleted file mode 100644 index de7e2200d6..0000000000 --- a/contrib/libs/grpc/include/grpc/support/sync_custom.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2017 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_SUPPORT_SYNC_CUSTOM_H -#define GRPC_SUPPORT_SYNC_CUSTOM_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/sync_custom.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_SYNC_CUSTOM_H */ diff --git a/contrib/libs/grpc/include/grpc/support/sync_generic.h b/contrib/libs/grpc/include/grpc/support/sync_generic.h deleted file mode 100644 index d1d9fd7e54..0000000000 --- a/contrib/libs/grpc/include/grpc/support/sync_generic.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_SYNC_GENERIC_H -#define GRPC_SUPPORT_SYNC_GENERIC_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/sync_generic.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */ diff --git a/contrib/libs/grpc/include/grpc/support/sync_posix.h b/contrib/libs/grpc/include/grpc/support/sync_posix.h deleted file mode 100644 index b971cd10f4..0000000000 --- a/contrib/libs/grpc/include/grpc/support/sync_posix.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_SYNC_POSIX_H -#define GRPC_SUPPORT_SYNC_POSIX_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/sync_posix.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_SYNC_POSIX_H */ diff --git a/contrib/libs/grpc/include/grpc/support/sync_windows.h b/contrib/libs/grpc/include/grpc/support/sync_windows.h deleted file mode 100644 index 3ee4a6ffa1..0000000000 --- a/contrib/libs/grpc/include/grpc/support/sync_windows.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_SYNC_WINDOWS_H -#define GRPC_SUPPORT_SYNC_WINDOWS_H - -#include <grpc/support/port_platform.h> - -#include <grpc/impl/codegen/sync_windows.h> // IWYU pragma: export - -#endif /* GRPC_SUPPORT_SYNC_WINDOWS_H */ diff --git a/contrib/libs/grpc/include/grpcpp/ext/admin_services.h b/contrib/libs/grpc/include/grpcpp/ext/admin_services.h deleted file mode 100644 index 898a87e5f0..0000000000 --- a/contrib/libs/grpc/include/grpcpp/ext/admin_services.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// -// 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. -// -// - -#ifndef GRPCPP_EXT_ADMIN_SERVICES_H -#define GRPCPP_EXT_ADMIN_SERVICES_H - -#include <grpcpp/server_builder.h> - -namespace grpc { - -// Registers admin services to the given ServerBuilder. This function will add -// admin services based on build time dependencies, for example, it only adds -// CSDS service if xDS is enabled in this binary. -void AddAdminServices(grpc::ServerBuilder* builder); - -} // namespace grpc - -#endif // GRPCPP_EXT_ADMIN_SERVICES_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/client_unary_call.h b/contrib/libs/grpc/include/grpcpp/impl/client_unary_call.h deleted file mode 100644 index 7ecf3548f2..0000000000 --- a/contrib/libs/grpc/include/grpcpp/impl/client_unary_call.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CLIENT_UNARY_CALL_H -#define GRPCPP_IMPL_CLIENT_UNARY_CALL_H - -#include <grpcpp/impl/codegen/client_unary_call.h> // IWYU pragma: export - -#endif // GRPCPP_IMPL_CLIENT_UNARY_CALL_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h deleted file mode 100644 index f4f6794b42..0000000000 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * Copyright 2019 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_IMPL_CODEGEN_DELEGATING_CHANNEL_H -#define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H - -// IWYU pragma: private - -#include <memory> - -#include <grpcpp/impl/codegen/channel_interface.h> - -namespace grpc { -namespace experimental { - -class DelegatingChannel : public ::grpc::ChannelInterface { - public: - ~DelegatingChannel() override {} - - explicit DelegatingChannel( - std::shared_ptr<::grpc::ChannelInterface> delegate_channel) - : delegate_channel_(delegate_channel) {} - - grpc_connectivity_state GetState(bool try_to_connect) override { - return delegate_channel()->GetState(try_to_connect); - } - - std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { - return delegate_channel_; - } - - private: - internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, - ::grpc::CompletionQueue* cq) final { - return delegate_channel()->CreateCall(method, context, cq); - } - - void PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) final { - delegate_channel()->PerformOpsOnCall(ops, call); - } - - void* RegisterMethod(const char* method) final { - return delegate_channel()->RegisterMethod(method); - } - - void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, - ::grpc::CompletionQueue* cq, - void* tag) override { - delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq, - tag); - } - - bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) override { - return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline); - } - - internal::Call CreateCallInternal(const internal::RpcMethod& method, - ClientContext* context, - ::grpc::CompletionQueue* cq, - size_t interceptor_pos) final { - return delegate_channel()->CreateCallInternal(method, context, cq, - interceptor_pos); - } - - ::grpc::CompletionQueue* CallbackCQ() final { - return delegate_channel()->CallbackCQ(); - } - - std::shared_ptr<::grpc::ChannelInterface> delegate_channel_; -}; - -} // namespace experimental -} // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler_impl.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler_impl.h deleted file mode 100644 index 3f1d573ba5..0000000000 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler_impl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H -#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H - -// IWYU pragma: private - -#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/method_handler_impl.h b/contrib/libs/grpc/include/grpcpp/impl/method_handler_impl.h deleted file mode 100644 index 5eceb5ff91..0000000000 --- a/contrib/libs/grpc/include/grpcpp/impl/method_handler_impl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_METHOD_HANDLER_IMPL_H -#define GRPCPP_IMPL_METHOD_HANDLER_IMPL_H - -#include <grpcpp/impl/codegen/method_handler.h> - -#endif // GRPCPP_IMPL_METHOD_HANDLER_IMPL_H diff --git a/contrib/libs/grpc/include/grpcpp/opencensus.h b/contrib/libs/grpc/include/grpcpp/opencensus.h deleted file mode 100644 index 0da949ab73..0000000000 --- a/contrib/libs/grpc/include/grpcpp/opencensus.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2019 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_OPENCENSUS_H -#define GRPCPP_OPENCENSUS_H - -#include "opencensus/trace/span.h" - -namespace grpc { -class ServerContext; -// These symbols in this file will not be included in the binary unless -// grpc_opencensus_plugin build target was added as a dependency. At the moment -// it is only setup to be built with Bazel. - -// Registers the OpenCensus plugin with gRPC, so that it will be used for future -// RPCs. This must be called before any views are created. -void RegisterOpenCensusPlugin(); - -// RPC stats definitions, defined by -// https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/gRPC.md - -// Registers the cumulative gRPC views so that they will be exported by any -// registered stats exporter. For on-task stats, construct a View using the -// ViewDescriptors below. -void RegisterOpenCensusViewsForExport(); - -// Returns the tracing Span for the current RPC. -::opencensus::trace::Span GetSpanFromServerContext(ServerContext* context); - -} // namespace grpc - -#endif // GRPCPP_OPENCENSUS_H diff --git a/contrib/libs/grpc/include/grpcpp/security/binder_credentials.h b/contrib/libs/grpc/include/grpcpp/security/binder_credentials.h deleted file mode 100644 index f511837ef2..0000000000 --- a/contrib/libs/grpc/include/grpcpp/security/binder_credentials.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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. - -#ifndef GRPCPP_SECURITY_BINDER_CREDENTIALS_H -#define GRPCPP_SECURITY_BINDER_CREDENTIALS_H - -#include <memory> - -#include <grpcpp/security/binder_security_policy.h> -#include <grpcpp/security/server_credentials.h> - -namespace grpc { - -class ChannelCredentials; - -namespace experimental { - -/// EXPERIMENTAL Builds Binder ServerCredentials. -/// -/// This should be used along with `binder:` URI scheme. The path in the URI can -/// later be used to access the server's endpoint binder. -/// Note that calling \a ServerBuilder::AddListeningPort() with Binder -/// ServerCredentials in a non-supported environment will make the subsequent -/// call to \a ServerBuilder::BuildAndStart() return a null pointer. -std::shared_ptr<grpc::ServerCredentials> BinderServerCredentials( - std::shared_ptr<grpc::experimental::binder::SecurityPolicy> - security_policy); - -} // namespace experimental -} // namespace grpc - -#endif // GRPCPP_SECURITY_BINDER_CREDENTIALS_H diff --git a/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h b/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h deleted file mode 100644 index 7874debae8..0000000000 --- a/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SECURITY_CRONET_CREDENTIALS_H -#define GRPCPP_SECURITY_CRONET_CREDENTIALS_H - -#include <memory> - -namespace grpc { - -class ChannelCredentials; - -/// Credentials for a channel using Cronet. -std::shared_ptr<ChannelCredentials> CronetChannelCredentials(void* engine); - -} // namespace grpc - -#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_H diff --git a/contrib/libs/grpc/include/grpcpp/support/client_interceptor.h b/contrib/libs/grpc/include/grpcpp/support/client_interceptor.h deleted file mode 100644 index 552cab4c70..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/client_interceptor.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H -#define GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H - -#include <grpcpp/impl/codegen/client_interceptor.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H diff --git a/contrib/libs/grpc/include/grpcpp/support/interceptor.h b/contrib/libs/grpc/include/grpcpp/support/interceptor.h deleted file mode 100644 index d4f2ea180e..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/interceptor.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_INTERCEPTOR_H -#define GRPCPP_SUPPORT_INTERCEPTOR_H - -#include <grpcpp/impl/codegen/interceptor.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_INTERCEPTOR_H diff --git a/contrib/libs/grpc/include/grpcpp/support/message_allocator.h b/contrib/libs/grpc/include/grpcpp/support/message_allocator.h deleted file mode 100644 index 22a963f3af..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/message_allocator.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2019 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_SUPPORT_MESSAGE_ALLOCATOR_H -#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H - -#include <grpcpp/impl/codegen/message_allocator.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H diff --git a/contrib/libs/grpc/include/grpcpp/support/method_handler.h b/contrib/libs/grpc/include/grpcpp/support/method_handler.h deleted file mode 100644 index 0b97a7af03..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/method_handler.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H -#define GRPCPP_SUPPORT_METHOD_HANDLER_H - -#include <grpcpp/impl/codegen/method_handler.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H diff --git a/contrib/libs/grpc/include/grpcpp/support/proto_buffer_reader.h b/contrib/libs/grpc/include/grpcpp/support/proto_buffer_reader.h deleted file mode 100644 index 07e523ed74..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/proto_buffer_reader.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_READER_H -#define GRPCPP_SUPPORT_PROTO_BUFFER_READER_H - -#include <grpcpp/impl/codegen/proto_buffer_reader.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_PROTO_BUFFER_READER_H diff --git a/contrib/libs/grpc/include/grpcpp/support/proto_buffer_writer.h b/contrib/libs/grpc/include/grpcpp/support/proto_buffer_writer.h deleted file mode 100644 index 589deb82e3..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/proto_buffer_writer.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H -#define GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H - -#include <grpcpp/impl/codegen/proto_buffer_writer.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H diff --git a/contrib/libs/grpc/include/grpcpp/support/status_code_enum.h b/contrib/libs/grpc/include/grpcpp/support/status_code_enum.h deleted file mode 100644 index eac697f45a..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/status_code_enum.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_STATUS_CODE_ENUM_H -#define GRPCPP_SUPPORT_STATUS_CODE_ENUM_H - -#include <grpcpp/impl/codegen/status_code_enum.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_STATUS_CODE_ENUM_H diff --git a/contrib/libs/grpc/include/grpcpp/support/stub_options.h b/contrib/libs/grpc/include/grpcpp/support/stub_options.h deleted file mode 100644 index ffe1ad77ea..0000000000 --- a/contrib/libs/grpc/include/grpcpp/support/stub_options.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_STUB_OPTIONS_H -#define GRPCPP_SUPPORT_STUB_OPTIONS_H - -#include <grpcpp/impl/codegen/stub_options.h> // IWYU pragma: export - -#endif // GRPCPP_SUPPORT_STUB_OPTIONS_H diff --git a/contrib/libs/grpc/include/grpcpp/test/channel_test_peer.h b/contrib/libs/grpc/include/grpcpp/test/channel_test_peer.h deleted file mode 100644 index e41bbfa460..0000000000 --- a/contrib/libs/grpc/include/grpcpp/test/channel_test_peer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright 2020 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_TEST_CHANNEL_TEST_PEER_H -#define GRPCPP_TEST_CHANNEL_TEST_PEER_H - -#include <grpcpp/channel.h> - -namespace grpc { -namespace testing { - -/// A test-only class to access private members of Channel. -class ChannelTestPeer { - public: - explicit ChannelTestPeer(Channel* channel) : channel_(channel) {} - - /// Provide the gRPC Core channel - grpc_channel* channel() const { return channel_->c_channel_; } - int registered_calls() const; - int registration_attempts() const; - - private: - Channel* channel_; // not owned -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_CHANNEL_TEST_PEER_H diff --git a/contrib/libs/grpc/include/grpcpp/test/client_context_test_peer.h b/contrib/libs/grpc/include/grpcpp/test/client_context_test_peer.h deleted file mode 100644 index 0afc32c0e8..0000000000 --- a/contrib/libs/grpc/include/grpcpp/test/client_context_test_peer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * 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. - * - */ - -#ifndef GRPCPP_TEST_CLIENT_CONTEXT_TEST_PEER_H -#define GRPCPP_TEST_CLIENT_CONTEXT_TEST_PEER_H - -#include <map> - -#include <grpcpp/client_context.h> - -namespace grpc { -namespace testing { - -/// A test-only class to access private members and methods of ClientContext. -class ClientContextTestPeer { - public: - explicit ClientContextTestPeer(ClientContext* const ctx) : ctx_(ctx) {} - - /// Inject metadata to the ClientContext for the test. The test peer - /// must be alive when a ClientContext::GetServerInitialMetadata is called. - void AddServerInitialMetadata(const TString& key, - const TString& value) { - server_initial_metadata_storage_.insert( - std::pair<TString, TString>(key, value)); - ctx_->initial_metadata_received_ = true; - ctx_->recv_initial_metadata_.map()->clear(); - for (const auto& item : server_initial_metadata_storage_) { - ctx_->recv_initial_metadata_.map()->insert( - std::pair<grpc::string_ref, grpc::string_ref>( - item.first.c_str(), - grpc::string_ref(item.second.data(), item.second.size()))); - } - } - - std::multimap<TString, TString> GetSendInitialMetadata() const { - return ctx_->send_initial_metadata_; - } - - private: - ClientContext* const ctx_; // not owned - std::multimap<TString, TString> server_initial_metadata_storage_; -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_CLIENT_CONTEXT_TEST_PEER_H diff --git a/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h b/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h deleted file mode 100644 index 4d4ae5c39d..0000000000 --- a/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright 2019 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_TEST_DEFAULT_REACTOR_TEST_PEER_H -#define GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H - -#include <grpcpp/server_context.h> -#include <grpcpp/support/server_callback.h> - -namespace grpc { -namespace testing { - -/// A test-only class to monitor the behavior of the ServerContext's -/// DefaultReactor. It is intended for allow unit-testing of a callback API -/// service via direct invocation of the service methods rather than through -/// RPCs. It is only applicable for unary RPC methods that use the -/// DefaultReactor rather than any user-defined reactor. If it is used, it must -/// be created before the RPC is invoked so that it can bind the reactor into a -/// test mode rather than letting it follow the normal paths. -class DefaultReactorTestPeer { - public: - explicit DefaultReactorTestPeer(CallbackServerContext* ctx) - : DefaultReactorTestPeer(ctx, [](Status) {}) {} - DefaultReactorTestPeer(CallbackServerContext* ctx, - std::function<void(Status)> finish_func) - : ctx_(ctx) { - ctx->SetupTestDefaultReactor(std::move(finish_func)); - } - ServerUnaryReactor* reactor() const { - return reinterpret_cast<ServerUnaryReactor*>(&ctx_->default_reactor_); - } - bool test_status_set() const { return ctx_->test_status_set(); } - Status test_status() const { return ctx_->test_status(); } - - private: - CallbackServerContext* const ctx_; // not owned -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H diff --git a/contrib/libs/grpc/include/grpcpp/test/mock_stream.h b/contrib/libs/grpc/include/grpcpp/test/mock_stream.h deleted file mode 100644 index f210b41ac6..0000000000 --- a/contrib/libs/grpc/include/grpcpp/test/mock_stream.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * - * Copyright 2017 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_TEST_MOCK_STREAM_H -#define GRPCPP_TEST_MOCK_STREAM_H - -#include <stdint.h> - -#include <gmock/gmock.h> - -#include <grpcpp/impl/codegen/call.h> -#include <grpcpp/support/async_stream.h> -#include <grpcpp/support/async_unary_call.h> -#include <grpcpp/support/sync_stream.h> - -namespace grpc { -namespace testing { - -template <class R> -class MockClientReader : public ::grpc::ClientReaderInterface<R> { - public: - MockClientReader() = default; - - /// ClientStreamingInterface - MOCK_METHOD0_T(Finish, Status()); - - /// ReaderInterface - MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*)); - MOCK_METHOD1_T(Read, bool(R*)); - - /// ClientReaderInterface - MOCK_METHOD0_T(WaitForInitialMetadata, void()); -}; - -template <class W> -class MockClientWriter : public ::grpc::ClientWriterInterface<W> { - public: - MockClientWriter() = default; - - /// ClientStreamingInterface - MOCK_METHOD0_T(Finish, Status()); - - /// WriterInterface - MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions)); - - /// ClientWriterInterface - MOCK_METHOD0_T(WritesDone, bool()); -}; - -template <class W, class R> -class MockClientReaderWriter - : public ::grpc::ClientReaderWriterInterface<W, R> { - public: - MockClientReaderWriter() = default; - - /// ClientStreamingInterface - MOCK_METHOD0_T(Finish, Status()); - - /// ReaderInterface - MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*)); - MOCK_METHOD1_T(Read, bool(R*)); - - /// WriterInterface - MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions)); - - /// ClientReaderWriterInterface - MOCK_METHOD0_T(WaitForInitialMetadata, void()); - MOCK_METHOD0_T(WritesDone, bool()); -}; - -/// TODO: We do not support mocking an async RPC for now. - -template <class R> -class MockClientAsyncResponseReader - : public ::grpc::ClientAsyncResponseReaderInterface<R> { - public: - MockClientAsyncResponseReader() = default; - - /// ClientAsyncResponseReaderInterface - MOCK_METHOD0_T(StartCall, void()); - MOCK_METHOD1_T(ReadInitialMetadata, void(void*)); - MOCK_METHOD3_T(Finish, void(R*, Status*, void*)); -}; - -template <class R> -class MockClientAsyncReader : public ClientAsyncReaderInterface<R> { - public: - MockClientAsyncReader() = default; - - /// ClientAsyncStreamingInterface - MOCK_METHOD1_T(StartCall, void(void*)); - MOCK_METHOD1_T(ReadInitialMetadata, void(void*)); - MOCK_METHOD2_T(Finish, void(Status*, void*)); - - /// AsyncReaderInterface - MOCK_METHOD2_T(Read, void(R*, void*)); -}; - -template <class W> -class MockClientAsyncWriter : public ::grpc::ClientAsyncWriterInterface<W> { - public: - MockClientAsyncWriter() = default; - - /// ClientAsyncStreamingInterface - MOCK_METHOD1_T(StartCall, void(void*)); - MOCK_METHOD1_T(ReadInitialMetadata, void(void*)); - MOCK_METHOD2_T(Finish, void(Status*, void*)); - - /// AsyncWriterInterface - MOCK_METHOD2_T(Write, void(const W&, void*)); - MOCK_METHOD3_T(Write, void(const W&, ::grpc::WriteOptions, void*)); - - /// ClientAsyncWriterInterface - MOCK_METHOD1_T(WritesDone, void(void*)); -}; - -template <class W, class R> -class MockClientAsyncReaderWriter - : public ClientAsyncReaderWriterInterface<W, R> { - public: - MockClientAsyncReaderWriter() = default; - - /// ClientAsyncStreamingInterface - MOCK_METHOD1_T(StartCall, void(void*)); - MOCK_METHOD1_T(ReadInitialMetadata, void(void*)); - MOCK_METHOD2_T(Finish, void(Status*, void*)); - - /// AsyncWriterInterface - MOCK_METHOD2_T(Write, void(const W&, void*)); - MOCK_METHOD3_T(Write, void(const W&, ::grpc::WriteOptions, void*)); - - /// AsyncReaderInterface - MOCK_METHOD2_T(Read, void(R*, void*)); - - /// ClientAsyncReaderWriterInterface - MOCK_METHOD1_T(WritesDone, void(void*)); -}; - -template <class R> -class MockServerReader : public ::grpc::ServerReaderInterface<R> { - public: - MockServerReader() = default; - - /// ServerStreamingInterface - MOCK_METHOD0_T(SendInitialMetadata, void()); - - /// ReaderInterface - MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*)); - MOCK_METHOD1_T(Read, bool(R*)); -}; - -template <class W> -class MockServerWriter : public ::grpc::ServerWriterInterface<W> { - public: - MockServerWriter() = default; - - /// ServerStreamingInterface - MOCK_METHOD0_T(SendInitialMetadata, void()); - - /// WriterInterface - MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions)); -}; - -template <class W, class R> -class MockServerReaderWriter : public grpc::ServerReaderWriterInterface<W, R> { - public: - MockServerReaderWriter() = default; - - /// ServerStreamingInterface - MOCK_METHOD0_T(SendInitialMetadata, void()); - - /// ReaderInterface - MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*)); - MOCK_METHOD1_T(Read, bool(R*)); - - /// WriterInterface - MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions)); -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_MOCK_STREAM_H diff --git a/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h b/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h deleted file mode 100644 index 00c19dc4b8..0000000000 --- a/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2016 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_TEST_SERVER_CONTEXT_TEST_SPOUSE_H -#define GRPCPP_TEST_SERVER_CONTEXT_TEST_SPOUSE_H - -#include <map> - -#include <grpcpp/server_context.h> - -namespace grpc { -namespace testing { - -/// A test-only class to access private members and methods of ServerContext. -class ServerContextTestSpouse { - public: - explicit ServerContextTestSpouse(ServerContext* ctx) : ctx_(ctx) {} - - /// Inject client metadata to the ServerContext for the test. The test spouse - /// must be alive when \a ServerContext::client_metadata is called. - void AddClientMetadata(const TString& key, const TString& value) { - client_metadata_storage_.insert( - std::pair<TString, TString>(key, value)); - ctx_->client_metadata_.map()->clear(); - for (const auto& item : client_metadata_storage_) { - ctx_->client_metadata_.map()->insert( - std::pair<grpc::string_ref, grpc::string_ref>( - item.first.c_str(), - grpc::string_ref(item.second.data(), item.second.size()))); - } - } - - std::multimap<TString, TString> GetInitialMetadata() const { - return ctx_->initial_metadata_; - } - - std::multimap<TString, TString> GetTrailingMetadata() const { - return ctx_->trailing_metadata_; - } - - private: - ServerContext* ctx_; // not owned - std::multimap<TString, TString> client_metadata_storage_; -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_SERVER_CONTEXT_TEST_SPOUSE_H diff --git a/contrib/libs/grpc/include/grpcpp/xds_server_builder.h b/contrib/libs/grpc/include/grpcpp/xds_server_builder.h deleted file mode 100644 index 82bc087754..0000000000 --- a/contrib/libs/grpc/include/grpcpp/xds_server_builder.h +++ /dev/null @@ -1,95 +0,0 @@ -// -// -// Copyright 2020 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_XDS_SERVER_BUILDER_H -#define GRPCPP_XDS_SERVER_BUILDER_H - -#include <grpc/impl/codegen/port_platform.h> - -#include <grpcpp/server_builder.h> - -namespace grpc { - -class XdsServerServingStatusNotifierInterface { - public: - struct ServingStatusUpdate { - ::grpc::Status status; - }; - - virtual ~XdsServerServingStatusNotifierInterface() = default; - - // \a uri contains the listening target associated with the notification. Note - // that a single target provided to XdsServerBuilder can get resolved to - // multiple listening addresses. - // The callback is invoked each time there is an update to the serving status. - // The API does not provide any guarantees around duplicate updates. - // Status::OK signifies that the server is serving, while a non-OK status - // signifies that the server is not serving. - virtual void OnServingStatusUpdate(TString uri, - ServingStatusUpdate update) = 0; -}; - -class XdsServerBuilder : public ::grpc::ServerBuilder { - public: - // It is the responsibility of the application to make sure that \a notifier - // outlasts the life of the server. Notifications will start being made - // asynchronously once `BuildAndStart()` has been called. Note that it is - // possible for notifications to be made before `BuildAndStart()` returns. - void set_status_notifier(XdsServerServingStatusNotifierInterface* notifier) { - notifier_ = notifier; - } - - private: - // Called at the beginning of BuildAndStart(). - ChannelArguments BuildChannelArgs() override { - ChannelArguments args = ServerBuilder::BuildChannelArgs(); - grpc_channel_args c_channel_args = args.c_channel_args(); - grpc_server_config_fetcher* fetcher = grpc_server_config_fetcher_xds_create( - {OnServingStatusUpdate, notifier_}, &c_channel_args); - if (fetcher != nullptr) set_fetcher(fetcher); - return args; - } - - static void OnServingStatusUpdate(void* user_data, const char* uri, - grpc_serving_status_update update) { - if (user_data == nullptr) return; - XdsServerServingStatusNotifierInterface* notifier = - static_cast<XdsServerServingStatusNotifierInterface*>(user_data); - notifier->OnServingStatusUpdate( - uri, {grpc::Status(static_cast<StatusCode>(update.code), - update.error_message)}); - } - - XdsServerServingStatusNotifierInterface* notifier_ = nullptr; -}; - -namespace experimental { -// TODO(yashykt): Delete this after the 1.42 release. -GRPC_DEPRECATED( - "Use grpc::XdsServerServingStatusNotifierInterface instead. The " - "experimental version will be deleted after the 1.42 release.") -typedef grpc::XdsServerServingStatusNotifierInterface - XdsServerServingStatusNotifierInterface; -GRPC_DEPRECATED( - "Use grpc::XdsServerBuilder instead. The experimental version will be " - "deleted after the 1.42 release.") -typedef grpc::XdsServerBuilder XdsServerBuilder; -} // namespace experimental -} // namespace grpc - -#endif /* GRPCPP_XDS_SERVER_BUILDER_H */ diff --git a/contrib/libs/grpc/src/compiler/csharp_generator.cc b/contrib/libs/grpc/src/compiler/csharp_generator.cc deleted file mode 100644 index 15d5361a20..0000000000 --- a/contrib/libs/grpc/src/compiler/csharp_generator.cc +++ /dev/null @@ -1,829 +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. - * - */ - -#include "src/compiler/csharp_generator.h" - -#include <cctype> -#include <map> -#include <sstream> -#include <vector> - -#include "src/compiler/config.h" -#include "src/compiler/csharp_generator_helpers.h" - -using grpc::protobuf::Descriptor; -using grpc::protobuf::FileDescriptor; -using grpc::protobuf::MethodDescriptor; -using grpc::protobuf::ServiceDescriptor; -using grpc::protobuf::io::Printer; -using grpc::protobuf::io::StringOutputStream; -using grpc_generator::StringReplace; -using std::vector; - -namespace grpc_csharp_generator { -namespace { - -// This function is a massaged version of -// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc -// Currently, we cannot easily reuse the functionality as -// google/protobuf/compiler/csharp/csharp_doc_comment.h is not a public header. -// TODO(jtattermusch): reuse the functionality from google/protobuf. -bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer, - grpc::protobuf::SourceLocation location) { - TString comments = location.leading_comments.empty() - ? location.trailing_comments - : location.leading_comments; - if (comments.empty()) { - return false; - } - // XML escaping... no need for apostrophes etc as the whole text is going to - // be a child - // node of a summary element, not part of an attribute. - comments = grpc_generator::StringReplace(comments, "&", "&", true); - comments = grpc_generator::StringReplace(comments, "<", "<", true); - - std::vector<TString> lines; - grpc_generator::Split(comments, '\n', &lines); - // TODO: We really should work out which part to put in the summary and which - // to put in the remarks... - // but that needs to be part of a bigger effort to understand the markdown - // better anyway. - printer->Print("/// <summary>\n"); - bool last_was_empty = false; - // We squash multiple blank lines down to one, and remove any trailing blank - // lines. We need - // to preserve the blank lines themselves, as this is relevant in the - // markdown. - // Note that we can't remove leading or trailing whitespace as *that's* - // relevant in markdown too. - // (We don't skip "just whitespace" lines, either.) - for (std::vector<TString>::iterator it = lines.begin(); it != lines.end(); - ++it) { - TString line = *it; - if (line.empty()) { - last_was_empty = true; - } else { - if (last_was_empty) { - printer->Print("///\n"); - } - last_was_empty = false; - printer->Print("///$line$\n", "line", *it); - } - } - printer->Print("/// </summary>\n"); - return true; -} - -void GenerateGeneratedCodeAttribute(grpc::protobuf::io::Printer* printer) { - // Mark the code as generated using the [GeneratedCode] attribute. - // We don't provide plugin version info in attribute the because: - // * the version information is not readily available from the plugin's code. - // * it would cause a lot of churn in the pre-generated code - // in this repository every time the version is updated. - printer->Print( - "[global::System.CodeDom.Compiler.GeneratedCode(\"grpc_csharp_plugin\", " - "null)]\n"); -} - -template <typename DescriptorType> -bool GenerateDocCommentBody(grpc::protobuf::io::Printer* printer, - const DescriptorType* descriptor) { - grpc::protobuf::SourceLocation location; - if (!descriptor->GetSourceLocation(&location)) { - return false; - } - return GenerateDocCommentBodyImpl(printer, location); -} - -void GenerateDocCommentServerMethod(grpc::protobuf::io::Printer* printer, - const MethodDescriptor* method) { - if (GenerateDocCommentBody(printer, method)) { - if (method->client_streaming()) { - printer->Print( - "/// <param name=\"requestStream\">Used for reading requests from " - "the client.</param>\n"); - } else { - printer->Print( - "/// <param name=\"request\">The request received from the " - "client.</param>\n"); - } - if (method->server_streaming()) { - printer->Print( - "/// <param name=\"responseStream\">Used for sending responses back " - "to the client.</param>\n"); - } - printer->Print( - "/// <param name=\"context\">The context of the server-side call " - "handler being invoked.</param>\n"); - if (method->server_streaming()) { - printer->Print( - "/// <returns>A task indicating completion of the " - "handler.</returns>\n"); - } else { - printer->Print( - "/// <returns>The response to send back to the client (wrapped by a " - "task).</returns>\n"); - } - } -} - -void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer* printer, - const MethodDescriptor* method, - bool is_sync, bool use_call_options) { - if (GenerateDocCommentBody(printer, method)) { - if (!method->client_streaming()) { - printer->Print( - "/// <param name=\"request\">The request to send to the " - "server.</param>\n"); - } - if (!use_call_options) { - printer->Print( - "/// <param name=\"headers\">The initial metadata to send with the " - "call. This parameter is optional.</param>\n"); - printer->Print( - "/// <param name=\"deadline\">An optional deadline for the call. The " - "call will be cancelled if deadline is hit.</param>\n"); - printer->Print( - "/// <param name=\"cancellationToken\">An optional token for " - "canceling the call.</param>\n"); - } else { - printer->Print( - "/// <param name=\"options\">The options for the call.</param>\n"); - } - if (is_sync) { - printer->Print( - "/// <returns>The response received from the server.</returns>\n"); - } else { - printer->Print("/// <returns>The call object.</returns>\n"); - } - } -} - -TString GetServiceClassName(const ServiceDescriptor* service) { - return service->name(); -} - -TString GetClientClassName(const ServiceDescriptor* service) { - return service->name() + "Client"; -} - -TString GetServerClassName(const ServiceDescriptor* service) { - return service->name() + "Base"; -} - -TString GetCSharpMethodType(const MethodDescriptor* method) { - if (method->client_streaming()) { - if (method->server_streaming()) { - return "grpc::MethodType.DuplexStreaming"; - } else { - return "grpc::MethodType.ClientStreaming"; - } - } else { - if (method->server_streaming()) { - return "grpc::MethodType.ServerStreaming"; - } else { - return "grpc::MethodType.Unary"; - } - } -} - -TString GetCSharpServerMethodType(const MethodDescriptor* method) { - if (method->client_streaming()) { - if (method->server_streaming()) { - return "grpc::DuplexStreamingServerMethod"; - } else { - return "grpc::ClientStreamingServerMethod"; - } - } else { - if (method->server_streaming()) { - return "grpc::ServerStreamingServerMethod"; - } else { - return "grpc::UnaryServerMethod"; - } - } -} - -TString GetServiceNameFieldName() { return "__ServiceName"; } - -TString GetMarshallerFieldName(const Descriptor* message) { - return "__Marshaller_" + - grpc_generator::StringReplace(message->full_name(), ".", "_", true); -} - -TString GetMethodFieldName(const MethodDescriptor* method) { - return "__Method_" + method->name(); -} - -TString GetMethodRequestParamMaybe(const MethodDescriptor* method, - bool invocation_param = false) { - if (method->client_streaming()) { - return ""; - } - if (invocation_param) { - return "request, "; - } - return GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()) + " request, "; -} - -TString GetAccessLevel(bool internal_access) { - return internal_access ? "internal" : "public"; -} - -TString GetMethodReturnTypeClient(const MethodDescriptor* method) { - if (method->client_streaming()) { - if (method->server_streaming()) { - return "grpc::AsyncDuplexStreamingCall<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()) + ", " + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + ">"; - } else { - return "grpc::AsyncClientStreamingCall<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()) + ", " + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + ">"; - } - } else { - if (method->server_streaming()) { - return "grpc::AsyncServerStreamingCall<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + ">"; - } else { - return "grpc::AsyncUnaryCall<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + ">"; - } - } -} - -TString GetMethodRequestParamServer(const MethodDescriptor* method) { - if (method->client_streaming()) { - return "grpc::IAsyncStreamReader<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()) + - "> requestStream"; - } - return GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()) + " request"; -} - -TString GetMethodReturnTypeServer(const MethodDescriptor* method) { - if (method->server_streaming()) { - return "global::System.Threading.Tasks.Task"; - } - return "global::System.Threading.Tasks.Task<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + ">"; -} - -TString GetMethodResponseStreamMaybe(const MethodDescriptor* method) { - if (method->server_streaming()) { - return ", grpc::IServerStreamWriter<" + - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()) + - "> responseStream"; - } - return ""; -} - -// Gets vector of all messages used as input or output types. -std::vector<const Descriptor*> GetUsedMessages( - const ServiceDescriptor* service) { - std::set<const Descriptor*> descriptor_set; - std::vector<const Descriptor*> - result; // vector is to maintain stable ordering - for (int i = 0; i < service->method_count(); i++) { - const MethodDescriptor* method = service->method(i); - if (descriptor_set.find(method->input_type()) == descriptor_set.end()) { - descriptor_set.insert(method->input_type()); - result.push_back(method->input_type()); - } - if (descriptor_set.find(method->output_type()) == descriptor_set.end()) { - descriptor_set.insert(method->output_type()); - result.push_back(method->output_type()); - } - } - return result; -} - -void GenerateMarshallerFields(Printer* out, const ServiceDescriptor* service) { - std::vector<const Descriptor*> used_messages = GetUsedMessages(service); - if (used_messages.size() != 0) { - // Generate static helper methods for serialization/deserialization - GenerateGeneratedCodeAttribute(out); - out->Print( - "static void __Helper_SerializeMessage(" - "global::Google.Protobuf.IMessage message, " - "grpc::SerializationContext context)\n" - "{\n"); - out->Indent(); - out->Print( - "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" - "if (message is global::Google.Protobuf.IBufferMessage)\n" - "{\n"); - out->Indent(); - out->Print( - "context.SetPayloadLength(message.CalculateSize());\n" - "global::Google.Protobuf.MessageExtensions.WriteTo(message, " - "context.GetBufferWriter());\n" - "context.Complete();\n" - "return;\n"); - out->Outdent(); - out->Print( - "}\n" - "#endif\n"); - out->Print( - "context.Complete(" - "global::Google.Protobuf.MessageExtensions.ToByteArray(message));\n"); - out->Outdent(); - out->Print("}\n\n"); - - GenerateGeneratedCodeAttribute(out); - out->Print( - "static class __Helper_MessageCache<T>\n" - "{\n"); - out->Indent(); - out->Print( - "public static readonly bool IsBufferMessage = " - "global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(" - "global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T));" - "\n"); - out->Outdent(); - out->Print("}\n\n"); - - GenerateGeneratedCodeAttribute(out); - out->Print( - "static T __Helper_DeserializeMessage<T>(" - "grpc::DeserializationContext context, " - "global::Google.Protobuf.MessageParser<T> parser) " - "where T : global::Google.Protobuf.IMessage<T>\n" - "{\n"); - out->Indent(); - out->Print( - "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" - "if (__Helper_MessageCache<T>.IsBufferMessage)\n" - "{\n"); - out->Indent(); - out->Print( - "return parser.ParseFrom(context.PayloadAsReadOnlySequence());\n"); - out->Outdent(); - out->Print( - "}\n" - "#endif\n"); - out->Print("return parser.ParseFrom(context.PayloadAsNewBuffer());\n"); - out->Outdent(); - out->Print("}\n\n"); - } - - for (size_t i = 0; i < used_messages.size(); i++) { - const Descriptor* message = used_messages[i]; - GenerateGeneratedCodeAttribute(out); - out->Print( - "static readonly grpc::Marshaller<$type$> $fieldname$ = " - "grpc::Marshallers.Create(__Helper_SerializeMessage, " - "context => __Helper_DeserializeMessage(context, $type$.Parser));\n", - "fieldname", GetMarshallerFieldName(message), "type", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(message)); - } - out->Print("\n"); -} - -void GenerateStaticMethodField(Printer* out, const MethodDescriptor* method) { - GenerateGeneratedCodeAttribute(out); - out->Print( - "static readonly grpc::Method<$request$, $response$> $fieldname$ = new " - "grpc::Method<$request$, $response$>(\n", - "fieldname", GetMethodFieldName(method), "request", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()), "response", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type())); - out->Indent(); - out->Indent(); - out->Print("$methodtype$,\n", "methodtype", GetCSharpMethodType(method)); - out->Print("$servicenamefield$,\n", "servicenamefield", - GetServiceNameFieldName()); - out->Print("\"$methodname$\",\n", "methodname", method->name()); - out->Print("$requestmarshaller$,\n", "requestmarshaller", - GetMarshallerFieldName(method->input_type())); - out->Print("$responsemarshaller$);\n", "responsemarshaller", - GetMarshallerFieldName(method->output_type())); - out->Print("\n"); - out->Outdent(); - out->Outdent(); -} - -void GenerateServiceDescriptorProperty(Printer* out, - const ServiceDescriptor* service) { - std::ostringstream index; - index << service->index(); - out->Print("/// <summary>Service descriptor</summary>\n"); - out->Print( - "public static global::Google.Protobuf.Reflection.ServiceDescriptor " - "Descriptor\n"); - out->Print("{\n"); - out->Print(" get { return $umbrella$.Descriptor.Services[$index$]; }\n", - "umbrella", - GRPC_CUSTOM_CSHARP_GETREFLECTIONCLASSNAME(service->file()), - "index", index.str()); - out->Print("}\n"); - out->Print("\n"); -} - -void GenerateServerClass(Printer* out, const ServiceDescriptor* service) { - out->Print( - "/// <summary>Base class for server-side implementations of " - "$servicename$</summary>\n", - "servicename", GetServiceClassName(service)); - out->Print( - "[grpc::BindServiceMethod(typeof($classname$), " - "\"BindService\")]\n", - "classname", GetServiceClassName(service)); - out->Print("public abstract partial class $name$\n", "name", - GetServerClassName(service)); - out->Print("{\n"); - out->Indent(); - for (int i = 0; i < service->method_count(); i++) { - const MethodDescriptor* method = service->method(i); - GenerateDocCommentServerMethod(out, method); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public virtual $returntype$ " - "$methodname$($request$$response_stream_maybe$, " - "grpc::ServerCallContext context)\n", - "methodname", method->name(), "returntype", - GetMethodReturnTypeServer(method), "request", - GetMethodRequestParamServer(method), "response_stream_maybe", - GetMethodResponseStreamMaybe(method)); - out->Print("{\n"); - out->Indent(); - out->Print( - "throw new grpc::RpcException(" - "new grpc::Status(grpc::StatusCode.Unimplemented, \"\"));\n"); - out->Outdent(); - out->Print("}\n\n"); - } - out->Outdent(); - out->Print("}\n"); - out->Print("\n"); -} - -void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { - out->Print("/// <summary>Client for $servicename$</summary>\n", "servicename", - GetServiceClassName(service)); - out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name", - GetClientClassName(service)); - out->Print("{\n"); - out->Indent(); - - // constructors - out->Print( - "/// <summary>Creates a new client for $servicename$</summary>\n" - "/// <param name=\"channel\">The channel to use to make remote " - "calls.</param>\n", - "servicename", GetServiceClassName(service)); - GenerateGeneratedCodeAttribute(out); - out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n"); - out->Print( - "/// <summary>Creates a new client for $servicename$ that uses a custom " - "<c>CallInvoker</c>.</summary>\n" - "/// <param name=\"callInvoker\">The callInvoker to use to make remote " - "calls.</param>\n", - "servicename", GetServiceClassName(service)); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n"); - out->Print( - "/// <summary>Protected parameterless constructor to allow creation" - " of test doubles.</summary>\n"); - GenerateGeneratedCodeAttribute(out); - out->Print("protected $name$() : base()\n", "name", - GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n"); - out->Print( - "/// <summary>Protected constructor to allow creation of configured " - "clients.</summary>\n" - "/// <param name=\"configuration\">The client configuration.</param>\n"); - GenerateGeneratedCodeAttribute(out); - out->Print( - "protected $name$(ClientBaseConfiguration configuration)" - " : base(configuration)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Print("}\n\n"); - - for (int i = 0; i < service->method_count(); i++) { - const MethodDescriptor* method = service->method(i); - if (!method->client_streaming() && !method->server_streaming()) { - // unary calls have an extra synchronous stub method - GenerateDocCommentClientMethod(out, method, true, false); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public virtual $response$ $methodname$($request$ request, " - "grpc::Metadata " - "headers = null, global::System.DateTime? deadline = null, " - "global::System.Threading.CancellationToken " - "cancellationToken = " - "default(global::System.Threading.CancellationToken))\n", - "methodname", method->name(), "request", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()), "response", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type())); - out->Print("{\n"); - out->Indent(); - out->Print( - "return $methodname$(request, new grpc::CallOptions(headers, " - "deadline, " - "cancellationToken));\n", - "methodname", method->name()); - out->Outdent(); - out->Print("}\n"); - - // overload taking CallOptions as a param - GenerateDocCommentClientMethod(out, method, true, true); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public virtual $response$ $methodname$($request$ request, " - "grpc::CallOptions options)\n", - "methodname", method->name(), "request", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()), "response", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type())); - out->Print("{\n"); - out->Indent(); - out->Print( - "return CallInvoker.BlockingUnaryCall($methodfield$, null, options, " - "request);\n", - "methodfield", GetMethodFieldName(method)); - out->Outdent(); - out->Print("}\n"); - } - - TString method_name = method->name(); - if (!method->client_streaming() && !method->server_streaming()) { - method_name += "Async"; // prevent name clash with synchronous method. - } - GenerateDocCommentClientMethod(out, method, false, false); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public virtual $returntype$ " - "$methodname$($request_maybe$grpc::Metadata " - "headers = null, global::System.DateTime? deadline = null, " - "global::System.Threading.CancellationToken " - "cancellationToken = " - "default(global::System.Threading.CancellationToken))\n", - "methodname", method_name, "request_maybe", - GetMethodRequestParamMaybe(method), "returntype", - GetMethodReturnTypeClient(method)); - out->Print("{\n"); - out->Indent(); - - out->Print( - "return $methodname$($request_maybe$new grpc::CallOptions(headers, " - "deadline, " - "cancellationToken));\n", - "methodname", method_name, "request_maybe", - GetMethodRequestParamMaybe(method, true)); - out->Outdent(); - out->Print("}\n"); - - // overload taking CallOptions as a param - GenerateDocCommentClientMethod(out, method, false, true); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public virtual $returntype$ " - "$methodname$($request_maybe$grpc::CallOptions " - "options)\n", - "methodname", method_name, "request_maybe", - GetMethodRequestParamMaybe(method), "returntype", - GetMethodReturnTypeClient(method)); - out->Print("{\n"); - out->Indent(); - if (!method->client_streaming() && !method->server_streaming()) { - // Non-Streaming - out->Print( - "return CallInvoker.AsyncUnaryCall($methodfield$, null, options, " - "request);\n", - "methodfield", GetMethodFieldName(method)); - } else if (method->client_streaming() && !method->server_streaming()) { - // Client Streaming Only - out->Print( - "return CallInvoker.AsyncClientStreamingCall($methodfield$, null, " - "options);\n", - "methodfield", GetMethodFieldName(method)); - } else if (!method->client_streaming() && method->server_streaming()) { - // Server Streaming Only - out->Print( - "return CallInvoker.AsyncServerStreamingCall($methodfield$, null, " - "options, request);\n", - "methodfield", GetMethodFieldName(method)); - } else { - // Bi-Directional Streaming - out->Print( - "return CallInvoker.AsyncDuplexStreamingCall($methodfield$, null, " - "options);\n", - "methodfield", GetMethodFieldName(method)); - } - out->Outdent(); - out->Print("}\n"); - } - - // override NewInstance method - out->Print( - "/// <summary>Creates a new instance of client from given " - "<c>ClientBaseConfiguration</c>.</summary>\n"); - GenerateGeneratedCodeAttribute(out); - out->Print( - "protected override $name$ NewInstance(ClientBaseConfiguration " - "configuration)\n", - "name", GetClientClassName(service)); - out->Print("{\n"); - out->Indent(); - out->Print("return new $name$(configuration);\n", "name", - GetClientClassName(service)); - out->Outdent(); - out->Print("}\n"); - - out->Outdent(); - out->Print("}\n"); - out->Print("\n"); -} - -void GenerateBindServiceMethod(Printer* out, const ServiceDescriptor* service) { - out->Print( - "/// <summary>Creates service definition that can be registered with a " - "server</summary>\n"); - out->Print( - "/// <param name=\"serviceImpl\">An object implementing the server-side" - " handling logic.</param>\n"); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public static grpc::ServerServiceDefinition BindService($implclass$ " - "serviceImpl)\n", - "implclass", GetServerClassName(service)); - out->Print("{\n"); - out->Indent(); - - out->Print("return grpc::ServerServiceDefinition.CreateBuilder()"); - out->Indent(); - out->Indent(); - for (int i = 0; i < service->method_count(); i++) { - const MethodDescriptor* method = service->method(i); - out->Print("\n.AddMethod($methodfield$, serviceImpl.$methodname$)", - "methodfield", GetMethodFieldName(method), "methodname", - method->name()); - } - out->Print(".Build();\n"); - out->Outdent(); - out->Outdent(); - - out->Outdent(); - out->Print("}\n"); - out->Print("\n"); -} - -void GenerateBindServiceWithBinderMethod(Printer* out, - const ServiceDescriptor* service) { - out->Print( - "/// <summary>Register service method with a service " - "binder with or without implementation. Useful when customizing the " - "service binding logic.\n" - "/// Note: this method is part of an experimental API that can change or " - "be " - "removed without any prior notice.</summary>\n"); - out->Print( - "/// <param name=\"serviceBinder\">Service methods will be bound by " - "calling <c>AddMethod</c> on this object." - "</param>\n"); - out->Print( - "/// <param name=\"serviceImpl\">An object implementing the server-side" - " handling logic.</param>\n"); - GenerateGeneratedCodeAttribute(out); - out->Print( - "public static void BindService(grpc::ServiceBinderBase serviceBinder, " - "$implclass$ " - "serviceImpl)\n", - "implclass", GetServerClassName(service)); - out->Print("{\n"); - out->Indent(); - - for (int i = 0; i < service->method_count(); i++) { - const MethodDescriptor* method = service->method(i); - out->Print( - "serviceBinder.AddMethod($methodfield$, serviceImpl == null ? null : " - "new $servermethodtype$<$inputtype$, $outputtype$>(" - "serviceImpl.$methodname$));\n", - "methodfield", GetMethodFieldName(method), "servermethodtype", - GetCSharpServerMethodType(method), "inputtype", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->input_type()), "outputtype", - GRPC_CUSTOM_CSHARP_GETCLASSNAME(method->output_type()), "methodname", - method->name()); - } - - out->Outdent(); - out->Print("}\n"); - out->Print("\n"); -} - -void GenerateService(Printer* out, const ServiceDescriptor* service, - bool generate_client, bool generate_server, - bool internal_access) { - GenerateDocCommentBody(out, service); - - out->Print("$access_level$ static partial class $classname$\n", - "access_level", GetAccessLevel(internal_access), "classname", - GetServiceClassName(service)); - out->Print("{\n"); - out->Indent(); - out->Print("static readonly string $servicenamefield$ = \"$servicename$\";\n", - "servicenamefield", GetServiceNameFieldName(), "servicename", - service->full_name()); - out->Print("\n"); - - GenerateMarshallerFields(out, service); - for (int i = 0; i < service->method_count(); i++) { - GenerateStaticMethodField(out, service->method(i)); - } - GenerateServiceDescriptorProperty(out, service); - - if (generate_server) { - GenerateServerClass(out, service); - } - if (generate_client) { - GenerateClientStub(out, service); - } - if (generate_server) { - GenerateBindServiceMethod(out, service); - GenerateBindServiceWithBinderMethod(out, service); - } - - out->Outdent(); - out->Print("}\n"); -} - -} // anonymous namespace - -TString GetServices(const FileDescriptor* file, bool generate_client, - bool generate_server, bool internal_access) { - TString output; - { - // Scope the output stream so it closes and finalizes output to the string. - - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - - // Don't write out any output if there no services, to avoid empty service - // files being generated for proto files that don't declare any. - if (file->service_count() == 0) { - return output; - } - - // Write out a file header. - out.Print("// <auto-generated>\n"); - out.Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"); - out.Print("// source: $filename$\n", "filename", file->name()); - out.Print("// </auto-generated>\n"); - - // use C++ style as there are no file-level XML comments in .NET - TString leading_comments = GetCsharpComments(file, true); - if (!leading_comments.empty()) { - out.Print("// Original file comments:\n"); - out.PrintRaw(leading_comments.c_str()); - } - - out.Print("#pragma warning disable 0414, 1591\n"); - - out.Print("#region Designer generated code\n"); - out.Print("\n"); - out.Print("using grpc = global::Grpc.Core;\n"); - out.Print("\n"); - - TString file_namespace = GRPC_CUSTOM_CSHARP_GETFILENAMESPACE(file); - if (file_namespace != "") { - out.Print("namespace $namespace$ {\n", "namespace", file_namespace); - out.Indent(); - } - for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i), generate_client, generate_server, - internal_access); - } - if (file_namespace != "") { - out.Outdent(); - out.Print("}\n"); - } - out.Print("#endregion\n"); - } - return output; -} - -} // namespace grpc_csharp_generator diff --git a/contrib/libs/grpc/src/compiler/csharp_generator.h b/contrib/libs/grpc/src/compiler/csharp_generator.h deleted file mode 100644 index 323b90584d..0000000000 --- a/contrib/libs/grpc/src/compiler/csharp_generator.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_H - -#include "src/compiler/config.h" - -namespace grpc_csharp_generator { - -TString GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_server, - bool internal_access); - -} // namespace grpc_csharp_generator - -#endif // GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_H diff --git a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h b/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h deleted file mode 100644 index d1a5b3a2a0..0000000000 --- a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_HELPERS_H -#define GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_HELPERS_H - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" - -namespace grpc_csharp_generator { - -inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, - const TString& file_suffix, - TString& out_file_name_or_error) { - out_file_name_or_error = - grpc_generator::FileNameInUpperCamel(file, false) + file_suffix; - return true; -} - -// Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. -template <typename DescriptorType> -inline TString GetCsharpComments(const DescriptorType* desc, bool leading) { - return grpc_generator::GetPrefixedComments(desc, leading, "//"); -} - -} // namespace grpc_csharp_generator - -#endif // GRPC_INTERNAL_COMPILER_CSHARP_GENERATOR_HELPERS_H diff --git a/contrib/libs/grpc/src/compiler/node_generator.cc b/contrib/libs/grpc/src/compiler/node_generator.cc deleted file mode 100644 index d890320e8a..0000000000 --- a/contrib/libs/grpc/src/compiler/node_generator.cc +++ /dev/null @@ -1,276 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/compiler/node_generator.h" - -#include <map> - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" -#include "src/compiler/node_generator_helpers.h" - -using grpc::protobuf::Descriptor; -using grpc::protobuf::FileDescriptor; -using grpc::protobuf::MethodDescriptor; -using grpc::protobuf::ServiceDescriptor; -using grpc::protobuf::io::Printer; -using grpc::protobuf::io::StringOutputStream; -using std::map; - -namespace grpc_node_generator { -namespace { - -// Returns the alias we assign to the module of the given .proto filename -// when importing. Copied entirely from -// github:google/protobuf/src/google/protobuf/compiler/js/js_generator.cc#L154 -TString ModuleAlias(const TString filename) { - // This scheme could technically cause problems if a file includes any 2 of: - // foo/bar_baz.proto - // foo_bar_baz.proto - // foo_bar/baz.proto - // - // We'll worry about this problem if/when we actually see it. This name isn't - // exposed to users so we can change it later if we need to. - TString basename = grpc_generator::StripProto(filename); - basename = grpc_generator::StringReplace(basename, "-", "$"); - basename = grpc_generator::StringReplace(basename, "/", "_"); - basename = grpc_generator::StringReplace(basename, ".", "_"); - return basename + "_pb"; -} - -// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript -// message file foo/bar/baz.js -TString GetJSMessageFilename(const TString& filename) { - TString name = filename; - return grpc_generator::StripProto(name) + "_pb.js"; -} - -// Given a filename like foo/bar/baz.proto, returns the root directory -// path ../../ -TString GetRootPath(const TString& from_filename, - const TString& to_filename) { - if (to_filename.find("google/protobuf") == 0) { - // Well-known types (.proto files in the google/protobuf directory) are - // assumed to come from the 'google-protobuf' npm package. We may want to - // generalize this exception later by letting others put generated code in - // their own npm packages. - return "google-protobuf/"; - } - size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/'); - if (slashes == 0) { - return "./"; - } - TString result = ""; - for (size_t i = 0; i < slashes; i++) { - result += "../"; - } - return result; -} - -// Return the relative path to load to_file from the directory containing -// from_file, assuming that both paths are relative to the same directory -TString GetRelativePath(const TString& from_file, - const TString& to_file) { - return GetRootPath(from_file, to_file) + to_file; -} - -/* Finds all message types used in all services in the file, and returns them - * as a map of fully qualified message type name to message descriptor */ -map<TString, const Descriptor*> GetAllMessages(const FileDescriptor* file) { - map<TString, const Descriptor*> message_types; - for (int service_num = 0; service_num < file->service_count(); - service_num++) { - const ServiceDescriptor* service = file->service(service_num); - for (int method_num = 0; method_num < service->method_count(); - method_num++) { - const MethodDescriptor* method = service->method(method_num); - const Descriptor* input_type = method->input_type(); - const Descriptor* output_type = method->output_type(); - message_types[input_type->full_name()] = input_type; - message_types[output_type->full_name()] = output_type; - } - } - return message_types; -} - -TString MessageIdentifierName(const TString& name) { - return grpc_generator::StringReplace(name, ".", "_"); -} - -TString NodeObjectPath(const Descriptor* descriptor) { - TString module_alias = ModuleAlias(descriptor->file()->name()); - TString name = descriptor->full_name(); - grpc_generator::StripPrefix(&name, descriptor->file()->package() + "."); - return module_alias + "." + name; -} - -// Prints out the message serializer and deserializer functions -void PrintMessageTransformer(const Descriptor* descriptor, Printer* out, - const Parameters& params) { - map<TString, TString> template_vars; - TString full_name = descriptor->full_name(); - template_vars["identifier_name"] = MessageIdentifierName(full_name); - template_vars["name"] = full_name; - template_vars["node_name"] = NodeObjectPath(descriptor); - // Print the serializer - out->Print(template_vars, "function serialize_$identifier_name$(arg) {\n"); - out->Indent(); - out->Print(template_vars, "if (!(arg instanceof $node_name$)) {\n"); - out->Indent(); - out->Print(template_vars, - "throw new Error('Expected argument of type $name$');\n"); - out->Outdent(); - out->Print("}\n"); - if (params.minimum_node_version > 5) { - // Node version is > 5, we should use Buffer.from - out->Print("return Buffer.from(arg.serializeBinary());\n"); - } else { - out->Print("return new Buffer(arg.serializeBinary());\n"); - } - out->Outdent(); - out->Print("}\n\n"); - - // Print the deserializer - out->Print(template_vars, - "function deserialize_$identifier_name$(buffer_arg) {\n"); - out->Indent(); - out->Print( - template_vars, - "return $node_name$.deserializeBinary(new Uint8Array(buffer_arg));\n"); - out->Outdent(); - out->Print("}\n\n"); -} - -void PrintMethod(const MethodDescriptor* method, Printer* out) { - const Descriptor* input_type = method->input_type(); - const Descriptor* output_type = method->output_type(); - map<TString, TString> vars; - vars["service_name"] = method->service()->full_name(); - vars["name"] = method->name(); - vars["input_type"] = NodeObjectPath(input_type); - vars["input_type_id"] = MessageIdentifierName(input_type->full_name()); - vars["output_type"] = NodeObjectPath(output_type); - vars["output_type_id"] = MessageIdentifierName(output_type->full_name()); - vars["client_stream"] = method->client_streaming() ? "true" : "false"; - vars["server_stream"] = method->server_streaming() ? "true" : "false"; - out->Print("{\n"); - out->Indent(); - out->Print(vars, "path: '/$service_name$/$name$',\n"); - out->Print(vars, "requestStream: $client_stream$,\n"); - out->Print(vars, "responseStream: $server_stream$,\n"); - out->Print(vars, "requestType: $input_type$,\n"); - out->Print(vars, "responseType: $output_type$,\n"); - out->Print(vars, "requestSerialize: serialize_$input_type_id$,\n"); - out->Print(vars, "requestDeserialize: deserialize_$input_type_id$,\n"); - out->Print(vars, "responseSerialize: serialize_$output_type_id$,\n"); - out->Print(vars, "responseDeserialize: deserialize_$output_type_id$,\n"); - out->Outdent(); - out->Print("}"); -} - -// Prints out the service descriptor object -void PrintService(const ServiceDescriptor* service, Printer* out) { - map<TString, TString> template_vars; - out->Print(GetNodeComments(service, true).c_str()); - template_vars["name"] = service->name(); - out->Print(template_vars, "var $name$Service = exports.$name$Service = {\n"); - out->Indent(); - for (int i = 0; i < service->method_count(); i++) { - TString method_name = - grpc_generator::LowercaseFirstLetter(service->method(i)->name()); - out->Print(GetNodeComments(service->method(i), true).c_str()); - out->Print("$method_name$: ", "method_name", method_name); - PrintMethod(service->method(i), out); - out->Print(",\n"); - out->Print(GetNodeComments(service->method(i), false).c_str()); - } - out->Outdent(); - out->Print("};\n\n"); - out->Print(template_vars, - "exports.$name$Client = " - "grpc.makeGenericClientConstructor($name$Service);\n"); - out->Print(GetNodeComments(service, false).c_str()); -} - -void PrintImports(const FileDescriptor* file, Printer* out) { - out->Print("var grpc = require('grpc');\n"); - if (file->message_type_count() > 0) { - TString file_path = - GetRelativePath(file->name(), GetJSMessageFilename(file->name())); - out->Print("var $module_alias$ = require('$file_path$');\n", "module_alias", - ModuleAlias(file->name()), "file_path", file_path); - } - - for (int i = 0; i < file->dependency_count(); i++) { - TString file_path = GetRelativePath( - file->name(), GetJSMessageFilename(file->dependency(i)->name())); - out->Print("var $module_alias$ = require('$file_path$');\n", "module_alias", - ModuleAlias(file->dependency(i)->name()), "file_path", - file_path); - } - out->Print("\n"); -} - -void PrintTransformers(const FileDescriptor* file, Printer* out, - const Parameters& params) { - map<TString, const Descriptor*> messages = GetAllMessages(file); - for (std::map<TString, const Descriptor*>::iterator it = messages.begin(); - it != messages.end(); it++) { - PrintMessageTransformer(it->second, out, params); - } - out->Print("\n"); -} - -void PrintServices(const FileDescriptor* file, Printer* out) { - for (int i = 0; i < file->service_count(); i++) { - PrintService(file->service(i), out); - } -} -} // namespace - -TString GenerateFile(const FileDescriptor* file, const Parameters& params) { - TString output; - { - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - - if (file->service_count() == 0) { - return output; - } - out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); - - TString leading_comments = GetNodeComments(file, true); - if (!leading_comments.empty()) { - out.Print("// Original file comments:\n"); - out.PrintRaw(leading_comments.c_str()); - } - - out.Print("'use strict';\n"); - - PrintImports(file, &out); - - PrintTransformers(file, &out, params); - - PrintServices(file, &out); - - out.Print(GetNodeComments(file, false).c_str()); - } - return output; -} - -} // namespace grpc_node_generator diff --git a/contrib/libs/grpc/src/compiler/node_generator.h b/contrib/libs/grpc/src/compiler/node_generator.h deleted file mode 100644 index 959df436ea..0000000000 --- a/contrib/libs/grpc/src/compiler/node_generator.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Copyright 2016 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_INTERNAL_COMPILER_NODE_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_NODE_GENERATOR_H - -#include "src/compiler/config.h" - -namespace grpc_node_generator { - -// Contains all the parameters that are parsed from the command line. -struct Parameters { - // Sets the earliest version of nodejs that needs to be supported. - int minimum_node_version; -}; - -TString GenerateFile(const grpc::protobuf::FileDescriptor* file, - const Parameters& params); - -} // namespace grpc_node_generator - -#endif // GRPC_INTERNAL_COMPILER_NODE_GENERATOR_H diff --git a/contrib/libs/grpc/src/compiler/node_generator_helpers.h b/contrib/libs/grpc/src/compiler/node_generator_helpers.h deleted file mode 100644 index ccf57ec8a6..0000000000 --- a/contrib/libs/grpc/src/compiler/node_generator_helpers.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright 2016 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_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H -#define GRPC_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H - -#include <algorithm> - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" - -namespace grpc_node_generator { - -inline TString GetJSServiceFilename(const TString& filename) { - return grpc_generator::StripProto(filename) + "_grpc_pb.js"; -} - -// Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. -template <typename DescriptorType> -inline TString GetNodeComments(const DescriptorType* desc, bool leading) { - return grpc_generator::GetPrefixedComments(desc, leading, "//"); -} - -} // namespace grpc_node_generator - -#endif // GRPC_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator.cc b/contrib/libs/grpc/src/compiler/objective_c_generator.cc deleted file mode 100644 index ec7b90f8a7..0000000000 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.cc +++ /dev/null @@ -1,451 +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. - * - */ - -#include "src/compiler/objective_c_generator.h" - -#include <map> -#include <set> -#include <sstream> - -#include <google/protobuf/compiler/objectivec/objectivec_helpers.h> - -#include "src/compiler/config.h" -#include "src/compiler/objective_c_generator_helpers.h" - -using ::google::protobuf::compiler::objectivec::ClassName; -using ::grpc::protobuf::FileDescriptor; -using ::grpc::protobuf::MethodDescriptor; -using ::grpc::protobuf::ServiceDescriptor; -using ::grpc::protobuf::io::Printer; -using ::std::map; -using ::std::set; - -namespace grpc_objective_c_generator { -namespace { - -void PrintProtoRpcDeclarationAsPragma(Printer* printer, - const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - vars["client_stream"] = method->client_streaming() ? "stream " : ""; - vars["server_stream"] = method->server_streaming() ? "stream " : ""; - - printer->Print(vars, - "#pragma mark $method_name$($client_stream$$request_type$)" - " returns ($server_stream$$response_type$)\n\n"); -} - -template <typename DescriptorType> -static void PrintAllComments(const DescriptorType* desc, Printer* printer, - bool deprecated = false) { - std::vector<TString> comments; - grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, - &comments); - grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING, - &comments); - grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_TRAILING, - &comments); - if (comments.empty()) { - return; - } - printer->Print("/**\n"); - for (auto it = comments.begin(); it != comments.end(); ++it) { - printer->Print(" * "); - size_t start_pos = it->find_first_not_of(' '); - if (start_pos != TString::npos) { - printer->PrintRaw(it->c_str() + start_pos); - } - printer->Print("\n"); - } - if (deprecated) { - printer->Print(" *\n"); - printer->Print( - " * This method belongs to a set of APIs that have been deprecated. " - "Using" - " the v2 API is recommended.\n"); - } - printer->Print(" */\n"); -} - -void PrintMethodSignature(Printer* printer, const MethodDescriptor* method, - const map< ::TString, ::TString>& vars) { - // Print comment - PrintAllComments(method, printer, true); - - printer->Print(vars, "- ($return_type$)$method_name$With"); - if (method->client_streaming()) { - printer->Print("RequestsWriter:(GRXWriter *)requestWriter"); - } else { - printer->Print(vars, "Request:($request_class$ *)request"); - } - - // TODO(jcanizales): Put this on a new line and align colons. - if (method->server_streaming()) { - printer->Print(vars, - " eventHandler:(void(^)(BOOL done, " - "$response_class$ *_Nullable response, NSError *_Nullable " - "error))eventHandler"); - } else { - printer->Print(vars, - " handler:(void(^)($response_class$ *_Nullable response, " - "NSError *_Nullable error))handler"); - } -} - -void PrintSimpleSignature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - vars["method_name"] = - grpc_generator::LowercaseFirstLetter(vars["method_name"]); - vars["return_type"] = "void"; - PrintMethodSignature(printer, method, vars); -} - -void PrintAdvancedSignature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - vars["method_name"] = "RPCTo" + vars["method_name"]; - vars["return_type"] = "GRPCProtoCall *"; - PrintMethodSignature(printer, method, vars); -} - -void PrintV2Signature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - if (method->client_streaming()) { - vars["return_type"] = "GRPCStreamingProtoCall *"; - } else { - vars["return_type"] = "GRPCUnaryProtoCall *"; - } - vars["method_name"] = - grpc_generator::LowercaseFirstLetter(vars["method_name"]); - - PrintAllComments(method, printer); - - printer->Print(vars, "- ($return_type$)$method_name$With"); - if (method->client_streaming()) { - printer->Print("ResponseHandler:(id<GRPCProtoResponseHandler>)handler"); - } else { - printer->Print(vars, - "Message:($request_class$ *)message " - "responseHandler:(id<GRPCProtoResponseHandler>)handler"); - } - printer->Print(" callOptions:(GRPCCallOptions *_Nullable)callOptions"); -} - -inline map< ::TString, ::TString> GetMethodVars( - const MethodDescriptor* method) { - map< ::TString, ::TString> res; - res["method_name"] = method->name(); - res["request_type"] = method->input_type()->name(); - res["response_type"] = method->output_type()->name(); - res["request_class"] = ClassName(method->input_type()); - res["response_class"] = ClassName(method->output_type()); - return res; -} - -void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) { - map< ::TString, ::TString> vars = GetMethodVars(method); - - PrintProtoRpcDeclarationAsPragma(printer, method, vars); - - PrintSimpleSignature(printer, method, vars); - printer->Print(";\n\n"); - PrintAdvancedSignature(printer, method, vars); - printer->Print(";\n\n\n"); -} - -void PrintV2MethodDeclarations(Printer* printer, - const MethodDescriptor* method) { - map< ::TString, ::TString> vars = GetMethodVars(method); - - PrintProtoRpcDeclarationAsPragma(printer, method, vars); - - PrintV2Signature(printer, method, vars); - printer->Print(";\n\n"); -} - -void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - printer->Print("{\n"); - printer->Print(vars, " [[self RPCTo$method_name$With"); - if (method->client_streaming()) { - printer->Print("RequestsWriter:requestWriter"); - } else { - printer->Print("Request:request"); - } - if (method->server_streaming()) { - printer->Print(" eventHandler:eventHandler] start];\n"); - } else { - printer->Print(" handler:handler] start];\n"); - } - printer->Print("}\n"); -} - -void PrintAdvancedImplementation(Printer* printer, - const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - printer->Print("{\n"); - printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); - - printer->Print(" requestsWriter:"); - if (method->client_streaming()) { - printer->Print("requestWriter\n"); - } else { - printer->Print("[GRXWriter writerWithValue:request]\n"); - } - - printer->Print(vars, " responseClass:[$response_class$ class]\n"); - - printer->Print(" responsesWriteable:[GRXWriteable "); - if (method->server_streaming()) { - printer->Print("writeableWithEventHandler:eventHandler]];\n"); - } else { - printer->Print("writeableWithSingleHandler:handler]];\n"); - } - - printer->Print("}\n"); -} - -void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { - printer->Print(" {\n"); - if (method->client_streaming()) { - printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); - printer->Print(" responseHandler:handler\n"); - printer->Print(" callOptions:callOptions\n"); - printer->Print( - vars, " responseClass:[$response_class$ class]];\n}\n\n"); - } else { - printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); - printer->Print(" message:message\n"); - printer->Print(" responseHandler:handler\n"); - printer->Print(" callOptions:callOptions\n"); - printer->Print( - vars, " responseClass:[$response_class$ class]];\n}\n\n"); - } -} - -void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method, - const Parameters& generator_params) { - map< ::TString, ::TString> vars = GetMethodVars(method); - - PrintProtoRpcDeclarationAsPragma(printer, method, vars); - - if (!generator_params.no_v1_compatibility) { - // TODO(jcanizales): Print documentation from the method. - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); - - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); - } - - PrintV2Signature(printer, method, vars); - PrintV2Implementation(printer, method, vars); -} - -} // namespace - -::TString GetAllMessageClasses(const FileDescriptor* file) { - ::TString output; - set< ::TString> classes; - for (int i = 0; i < file->service_count(); i++) { - const auto service = file->service(i); - for (int i = 0; i < service->method_count(); i++) { - const auto method = service->method(i); - classes.insert(ClassName(method->input_type())); - classes.insert(ClassName(method->output_type())); - } - } - for (auto one_class : classes) { - output += "@class " + one_class + ";\n"; - } - - return output; -} - -::TString GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; - - if (generator_params.no_v1_compatibility) return output; - - // Scope the output stream so it closes and finalizes output to the string. - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); - - map< ::TString, ::TString> vars = { - {"service_class", ServiceClassName(service)}}; - - printer.Print(vars, - "/**\n" - " * The methods in this protocol belong to a set of old APIs " - "that have been deprecated. They do not\n" - " * recognize call options provided in the initializer. Using " - "the v2 protocol is recommended.\n" - " */\n"); - printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); - for (int i = 0; i < service->method_count(); i++) { - PrintMethodDeclarations(&printer, service->method(i)); - } - printer.Print("@end\n\n"); - - return output; -} - -::TString GetV2Protocol(const ServiceDescriptor* service) { - ::TString output; - - // Scope the output stream so it closes and finalizes output to the string. - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); - - map< ::TString, ::TString> vars = { - {"service_class", ServiceClassName(service) + "2"}}; - - printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); - for (int i = 0; i < service->method_count(); i++) { - PrintV2MethodDeclarations(&printer, service->method(i)); - } - printer.Print("@end\n\n"); - - return output; -} - -::TString GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; - - // Scope the output stream so it closes and finalizes output to the string. - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); - - map< ::TString, ::TString> vars = { - {"service_class", ServiceClassName(service)}}; - - printer.Print(vars, - "/**\n" - " * Basic service implementation, over gRPC, that only does\n" - " * marshalling and parsing.\n" - " */\n"); - printer.Print(vars, - "@interface $service_class$ :" - " GRPCProtoService<$service_class$2"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, ", $service_class$"); - } - printer.Print(">\n"); - printer.Print( - "- (instancetype)initWithHost:(NSString *)host " - "callOptions:(GRPCCallOptions " - "*_Nullable)callOptions" - " NS_DESIGNATED_INITIALIZER;\n"); - printer.Print( - "+ (instancetype)serviceWithHost:(NSString *)host " - "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); - } - printer.Print("@end\n"); - - return output; -} - -::TString GetSource(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; - { - // Scope the output stream so it closes and finalizes output to the string. - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); - - map< ::TString, ::TString> vars = { - {"service_name", service->name()}, - {"service_class", ServiceClassName(service)}, - {"package", service->file()->package()}}; - - printer.Print(vars, - "@implementation $service_class$\n\n" - "#pragma clang diagnostic push\n" - "#pragma clang diagnostic ignored " - "\"-Wobjc-designated-initializers\"\n\n" - "// Designated initializer\n" - "- (instancetype)initWithHost:(NSString *)host " - "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"\n" - " callOptions:callOptions];\n" - "}\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n"); - } - printer.Print("#pragma clang diagnostic pop\n\n"); - - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n"); - } - printer.Print( - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName\n" - " callOptions:(GRPCCallOptions *)callOptions {\n" - " return [self initWithHost:host callOptions:callOptions];\n" - "}\n\n"); - - printer.Print("#pragma mark - Class Methods\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n"); - } - printer.Print( - "+ (instancetype)serviceWithHost:(NSString *)host " - "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" - " return [[self alloc] initWithHost:host callOptions:callOptions];\n" - "}\n\n"); - - printer.Print("#pragma mark - Method Implementations\n\n"); - - for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i), - generator_params); - } - - printer.Print("@end\n"); - } - return output; -} - -} // namespace grpc_objective_c_generator diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator.h b/contrib/libs/grpc/src/compiler/objective_c_generator.h deleted file mode 100644 index 9770f65436..0000000000 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_H - -#include "src/compiler/config.h" - -namespace grpc_objective_c_generator { - -struct Parameters { - // Do not generate V1 interface and implementation - bool no_v1_compatibility; -}; - -using ::grpc::protobuf::FileDescriptor; -using ::grpc::protobuf::ServiceDescriptor; -using ::TString; - -// Returns forward declaration of classes in the generated header file. -string GetAllMessageClasses(const FileDescriptor* file); - -// Returns the content to be included defining the @protocol segment at the -// insertion point of the generated implementation file. This interface is -// legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params); - -// Returns the content to be included defining the @protocol segment at the -// insertion point of the generated implementation file. -string GetV2Protocol(const ServiceDescriptor* service); - -// Returns the content to be included defining the @interface segment at the -// insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params); - -// Returns the content to be included in the "global_scope" insertion point of -// the generated implementation file. -string GetSource(const ServiceDescriptor* service, - const Parameters& generator_params); - -} // namespace grpc_objective_c_generator - -#endif // GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_H diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h deleted file mode 100644 index c8336a3fc9..0000000000 --- a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H -#define GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H - -#include <map> - -#include <google/protobuf/compiler/objectivec/objectivec_helpers.h> - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" - -namespace grpc_objective_c_generator { - -using ::grpc::protobuf::FileDescriptor; -using ::grpc::protobuf::ServiceDescriptor; -using ::TString; - -inline string MessageHeaderName(const FileDescriptor* file) { - return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; -} - -inline string ServiceClassName(const ServiceDescriptor* service) { - const FileDescriptor* file = service->file(); - string prefix = google::protobuf::compiler::objectivec::FileClassPrefix(file); - return prefix + service->name(); -} - -inline ::TString LocalImport(const ::TString& import) { - return ::TString("#import \"" + import + "\"\n"); -} - -inline ::TString FrameworkImport(const ::TString& import, - const ::TString& framework) { - // Flattens the directory structure: grab the file name only - std::size_t pos = import.rfind("/"); - // If pos is npos, pos + 1 is 0, which gives us the entire string, - // so there's no need to check that - ::TString filename = import.substr(pos + 1, import.size() - (pos + 1)); - return ::TString("#import <" + framework + "/" + filename + ">\n"); -} - -inline ::TString SystemImport(const ::TString& import) { - return ::TString("#import <" + import + ">\n"); -} - -inline ::TString PreprocConditional(::TString symbol, bool invert) { - return invert ? "!defined(" + symbol + ") || !" + symbol - : "defined(" + symbol + ") && " + symbol; -} - -inline ::TString PreprocIf(const ::TString& symbol, - const ::TString& if_true) { - return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + - if_true + "#endif\n"); -} - -inline ::TString PreprocIfNot(const ::TString& symbol, - const ::TString& if_true) { - return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + - if_true + "#endif\n"); -} - -inline ::TString PreprocIfElse(const ::TString& symbol, - const ::TString& if_true, - const ::TString& if_false) { - return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + - if_true + "#else\n" + if_false + "#endif\n"); -} - -inline ::TString PreprocIfNotElse(const ::TString& symbol, - const ::TString& if_true, - const ::TString& if_false) { - return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + - if_true + "#else\n" + if_false + "#endif\n"); -} - -} // namespace grpc_objective_c_generator -#endif // GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H diff --git a/contrib/libs/grpc/src/compiler/php_generator.cc b/contrib/libs/grpc/src/compiler/php_generator.cc deleted file mode 100644 index a0c1ef9be1..0000000000 --- a/contrib/libs/grpc/src/compiler/php_generator.cc +++ /dev/null @@ -1,340 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <map> - -#include <google/protobuf/compiler/php/php_generator.h> - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" -#include "src/compiler/php_generator_helpers.h" - -using google::protobuf::compiler::php::GeneratedClassName; -using grpc::protobuf::Descriptor; -using grpc::protobuf::FileDescriptor; -using grpc::protobuf::MethodDescriptor; -using grpc::protobuf::ServiceDescriptor; -using grpc::protobuf::io::Printer; -using grpc::protobuf::io::StringOutputStream; -using std::map; - -namespace grpc_php_generator { -namespace { - -TString ConvertToPhpNamespace(const TString& name) { - std::vector<TString> tokens = grpc_generator::tokenize(name, "."); - std::ostringstream oss; - for (unsigned int i = 0; i < tokens.size(); i++) { - oss << (i == 0 ? "" : "\\") - << grpc_generator::CapitalizeFirstLetter(tokens[i]); - } - return oss.str(); -} - -TString PackageName(const FileDescriptor* file) { - if (file->options().has_php_namespace()) { - return file->options().php_namespace(); - } else { - return ConvertToPhpNamespace(file->package()); - } -} - -TString MessageIdentifierName(const TString& name, - const FileDescriptor* file) { - std::vector<TString> tokens = grpc_generator::tokenize(name, "."); - std::ostringstream oss; - if (PackageName(file) != "") { - oss << PackageName(file) << "\\"; - } - oss << grpc_generator::CapitalizeFirstLetter(tokens[tokens.size() - 1]); - return oss.str(); -} - -void PrintMethod(const MethodDescriptor* method, Printer* out) { - const Descriptor* input_type = method->input_type(); - const Descriptor* output_type = method->output_type(); - map<TString, TString> vars; - vars["service_name"] = method->service()->full_name(); - vars["name"] = method->name(); - vars["input_type_id"] = - MessageIdentifierName(GeneratedClassName(input_type), input_type->file()); - vars["output_type_id"] = MessageIdentifierName( - GeneratedClassName(output_type), output_type->file()); - - out->Print("/**\n"); - out->Print(GetPHPComments(method, " *").c_str()); - if (method->client_streaming()) { - if (method->server_streaming()) { - vars["return_type_id"] = "\\Grpc\\BidiStreamingCall"; - } else { - vars["return_type_id"] = "\\Grpc\\ClientStreamingCall"; - } - out->Print(vars, - " * @param array $$metadata metadata\n" - " * @param array $$options call options\n" - " * @return $return_type_id$\n */\n" - "public function $name$($$metadata = [], " - "$$options = []) {\n"); - out->Indent(); - out->Indent(); - if (method->server_streaming()) { - out->Print("return $$this->_bidiRequest("); - } else { - out->Print("return $$this->_clientStreamRequest("); - } - out->Print(vars, - "'/$service_name$/$name$',\n" - "['\\$output_type_id$','decode'],\n" - "$$metadata, $$options);\n"); - } else { - if (method->server_streaming()) { - vars["return_type_id"] = "\\Grpc\\ServerStreamingCall"; - } else { - vars["return_type_id"] = "\\Grpc\\UnaryCall"; - } - out->Print(vars, - " * @param \\$input_type_id$ $$argument input argument\n" - " * @param array $$metadata metadata\n" - " * @param array $$options call options\n" - " * @return $return_type_id$\n */\n" - "public function $name$(\\$input_type_id$ $$argument,\n" - " $$metadata = [], $$options = []) {\n"); - out->Indent(); - out->Indent(); - if (method->server_streaming()) { - out->Print("return $$this->_serverStreamRequest("); - } else { - out->Print("return $$this->_simpleRequest("); - } - out->Print(vars, - "'/$service_name$/$name$',\n" - "$$argument,\n" - "['\\$output_type_id$', 'decode'],\n" - "$$metadata, $$options);\n"); - } - out->Outdent(); - out->Outdent(); - out->Print("}\n\n"); -} - -void PrintServerMethod(const MethodDescriptor* method, Printer* out) { - map<TString, TString> vars; - const Descriptor* input_type = method->input_type(); - const Descriptor* output_type = method->output_type(); - vars["service_name"] = method->service()->full_name(); - vars["method_name"] = method->name(); - vars["input_type_id"] = - MessageIdentifierName(GeneratedClassName(input_type), input_type->file()); - vars["output_type_id"] = MessageIdentifierName( - GeneratedClassName(output_type), output_type->file()); - - out->Print("/**\n"); - out->Print(GetPHPComments(method, " *").c_str()); - - const char* method_template; - if (method->client_streaming() && method->server_streaming()) { - method_template = - " * @param \\Grpc\\ServerCallReader $$reader read client request data " - "of \\$input_type_id$\n" - " * @param \\Grpc\\ServerCallWriter $$writer write response data of " - "\\$output_type_id$\n" - " * @param \\Grpc\\ServerContext $$context server request context\n" - " * @return void\n" - " */\n" - "public function $method_name$(\n" - " \\Grpc\\ServerCallReader $$reader,\n" - " \\Grpc\\ServerCallWriter $$writer,\n" - " \\Grpc\\ServerContext $$context\n" - "): void {\n" - " $$context->setStatus(\\Grpc\\Status::unimplemented());\n" - " $$writer->finish();\n" - "}\n\n"; - } else if (method->client_streaming()) { - method_template = - " * @param \\Grpc\\ServerCallReader $$reader read client request data " - "of \\$input_type_id$\n" - " * @param \\Grpc\\ServerContext $$context server request context\n" - " * @return \\$output_type_id$ for response data, null if if error " - "occured\n" - " * initial metadata (if any) and status (if not ok) should be set " - "to $$context\n" - " */\n" - "public function $method_name$(\n" - " \\Grpc\\ServerCallReader $$reader,\n" - " \\Grpc\\ServerContext $$context\n" - "): ?\\$output_type_id$ {\n" - " $$context->setStatus(\\Grpc\\Status::unimplemented());\n" - " return null;\n" - "}\n\n"; - } else if (method->server_streaming()) { - method_template = - " * @param \\$input_type_id$ $$request client request\n" - " * @param \\Grpc\\ServerCallWriter $$writer write response data of " - "\\$output_type_id$\n" - " * @param \\Grpc\\ServerContext $$context server request context\n" - " * @return void\n" - " */\n" - "public function $method_name$(\n" - " \\$input_type_id$ $$request,\n" - " \\Grpc\\ServerCallWriter $$writer,\n" - " \\Grpc\\ServerContext $$context\n" - "): void {\n" - " $$context->setStatus(\\Grpc\\Status::unimplemented());\n" - " $$writer->finish();\n" - "}\n\n"; - } else { - method_template = - " * @param \\$input_type_id$ $$request client request\n" - " * @param \\Grpc\\ServerContext $$context server request context\n" - " * @return \\$output_type_id$ for response data, null if if error " - "occured\n" - " * initial metadata (if any) and status (if not ok) should be set " - "to $$context\n" - " */\n" - "public function $method_name$(\n" - " \\$input_type_id$ $$request,\n" - " \\Grpc\\ServerContext $$context\n" - "): ?\\$output_type_id$ {\n" - " $$context->setStatus(\\Grpc\\Status::unimplemented());\n" - " return null;\n" - "}\n\n"; - } - out->Print(vars, method_template); -} - -void PrintServerMethodDescriptors(const ServiceDescriptor* service, - Printer* out) { - map<TString, TString> vars; - vars["service_name"] = service->full_name(); - - out->Print( - "/**\n" - " * Get the method descriptors of the service for server registration\n" - " *\n" - " * @return array of \\Grpc\\MethodDescriptor for the service methods\n" - " */\n" - "public final function getMethodDescriptors(): array\n{\n"); - out->Indent(); - out->Indent(); - out->Print("return [\n"); - out->Indent(); - out->Indent(); - for (int i = 0; i < service->method_count(); i++) { - auto method = service->method(i); - auto input_type = method->input_type(); - vars["method_name"] = method->name(); - vars["input_type_id"] = MessageIdentifierName( - GeneratedClassName(input_type), input_type->file()); - if (method->client_streaming() && method->server_streaming()) { - vars["call_type"] = "BIDI_STREAMING_CALL"; - } else if (method->client_streaming()) { - vars["call_type"] = "CLIENT_STREAMING_CALL"; - } else if (method->server_streaming()) { - vars["call_type"] = "SERVER_STREAMING_CALL"; - } else { - vars["call_type"] = "UNARY_CALL"; - } - out->Print( - vars, - "'/$service_name$/$method_name$' => new \\Grpc\\MethodDescriptor(\n" - " $$this,\n" - " '$method_name$',\n" - " '\\$input_type_id$',\n" - " \\Grpc\\MethodDescriptor::$call_type$\n" - "),\n"); - } - out->Outdent(); - out->Outdent(); - out->Print("];\n"); - out->Outdent(); - out->Outdent(); - out->Print("}\n\n"); -} - -// Prints out the service descriptor object -void PrintService(const ServiceDescriptor* service, - const TString& class_suffix, bool is_server, - Printer* out) { - map<TString, TString> vars; - out->Print("/**\n"); - out->Print(GetPHPComments(service, " *").c_str()); - out->Print(" */\n"); - vars["name"] = GetPHPServiceClassname(service, class_suffix, is_server); - vars["extends"] = is_server ? "" : "extends \\Grpc\\BaseStub "; - out->Print(vars, "class $name$ $extends${\n\n"); - out->Indent(); - out->Indent(); - if (!is_server) { - out->Print( - "/**\n * @param string $$hostname hostname\n" - " * @param array $$opts channel options\n" - " * @param \\Grpc\\Channel $$channel (optional) re-use channel object\n" - " */\n" - "public function __construct($$hostname, $$opts, " - "$$channel = null) {\n"); - out->Indent(); - out->Indent(); - out->Print("parent::__construct($$hostname, $$opts, $$channel);\n"); - out->Outdent(); - out->Outdent(); - out->Print("}\n\n"); - } - for (int i = 0; i < service->method_count(); i++) { - if (is_server) { - PrintServerMethod(service->method(i), out); - } else { - PrintMethod(service->method(i), out); - } - } - if (is_server) { - PrintServerMethodDescriptors(service, out); - } - out->Outdent(); - out->Outdent(); - out->Print("}\n"); -} -} // namespace - -TString GenerateFile(const FileDescriptor* file, - const ServiceDescriptor* service, - const TString& class_suffix, bool is_server) { - TString output; - { - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - - out.Print("<?php\n"); - out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); - - TString leading_comments = GetPHPComments(file, "//"); - if (!leading_comments.empty()) { - out.Print("// Original file comments:\n"); - out.PrintRaw(leading_comments.c_str()); - } - - map<TString, TString> vars; - TString php_namespace = PackageName(file); - vars["package"] = php_namespace; - out.Print(vars, "namespace $package$;\n\n"); - - PrintService(service, class_suffix, is_server, &out); - } - return output; -} - -} // namespace grpc_php_generator diff --git a/contrib/libs/grpc/src/compiler/php_generator_helpers.h b/contrib/libs/grpc/src/compiler/php_generator_helpers.h deleted file mode 100644 index 93479e20a2..0000000000 --- a/contrib/libs/grpc/src/compiler/php_generator_helpers.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright 2016 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_INTERNAL_COMPILER_PHP_GENERATOR_HELPERS_H -#define GRPC_INTERNAL_COMPILER_PHP_GENERATOR_HELPERS_H - -#include <algorithm> - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" - -namespace grpc_php_generator { - -inline TString GetPHPServiceClassname( - const grpc::protobuf::ServiceDescriptor* service, - const TString& class_suffix, bool is_server) { - return service->name() + - (class_suffix == "" ? (is_server ? "" : "Client") : class_suffix) + - (is_server ? "Stub" : ""); -} - -// ReplaceAll replaces all instances of search with replace in s. -inline TString ReplaceAll(TString s, const TString& search, - const TString& replace) { - size_t pos = 0; - while ((pos = s.find(search, pos)) != TString::npos) { - s.replace(pos, search.length(), replace); - pos += replace.length(); - } - return s; -} - -inline TString GetPHPServiceFilename( - const grpc::protobuf::FileDescriptor* file, - const grpc::protobuf::ServiceDescriptor* service, - const TString& class_suffix, bool is_server) { - std::ostringstream oss; - if (file->options().has_php_namespace()) { - oss << ReplaceAll(file->options().php_namespace(), "\\", "/"); - } else { - std::vector<TString> tokens = - grpc_generator::tokenize(file->package(), "."); - for (unsigned int i = 0; i < tokens.size(); i++) { - oss << (i == 0 ? "" : "/") - << grpc_generator::CapitalizeFirstLetter(tokens[i]); - } - } - return oss.str() + "/" + - GetPHPServiceClassname(service, class_suffix, is_server) + ".php"; -} - -// Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. -template <typename DescriptorType> -inline TString GetPHPComments(const DescriptorType* desc, - TString prefix) { - return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix), - "*/", "*/"); -} - -} // namespace grpc_php_generator - -#endif // GRPC_INTERNAL_COMPILER_PHP_GENERATOR_HELPERS_H diff --git a/contrib/libs/grpc/src/compiler/ruby_generator.cc b/contrib/libs/grpc/src/compiler/ruby_generator.cc deleted file mode 100644 index f5b9e9db87..0000000000 --- a/contrib/libs/grpc/src/compiler/ruby_generator.cc +++ /dev/null @@ -1,215 +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. - * - */ - -#include "src/compiler/ruby_generator.h" - -#include <cctype> -#include <map> -#include <vector> - -#include "src/compiler/config.h" -#include "src/compiler/ruby_generator_helpers-inl.h" -#include "src/compiler/ruby_generator_map-inl.h" -#include "src/compiler/ruby_generator_string-inl.h" - -using grpc::protobuf::FileDescriptor; -using grpc::protobuf::MethodDescriptor; -using grpc::protobuf::ServiceDescriptor; -using grpc::protobuf::io::Printer; -using grpc::protobuf::io::StringOutputStream; -using std::map; -using std::vector; - -namespace grpc_ruby_generator { -namespace { - -// Prints out the method using the ruby gRPC DSL. -void PrintMethod(const MethodDescriptor* method, Printer* out) { - TString input_type = RubyTypeOf(method->input_type()); - if (method->client_streaming()) { - input_type = "stream(" + input_type + ")"; - } - TString output_type = RubyTypeOf(method->output_type()); - if (method->server_streaming()) { - output_type = "stream(" + output_type + ")"; - } - std::map<TString, TString> method_vars = ListToDict({ - "mth.name", - method->name(), - "input.type", - input_type, - "output.type", - output_type, - }); - out->Print(GetRubyComments(method, true).c_str()); - out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n"); - out->Print(GetRubyComments(method, false).c_str()); -} - -// Prints out the service using the ruby gRPC DSL. -void PrintService(const ServiceDescriptor* service, Printer* out) { - if (service->method_count() == 0) { - return; - } - - // Begin the service module - std::map<TString, TString> module_vars = ListToDict({ - "module.name", - Modularize(service->name()), - }); - out->Print(module_vars, "module $module.name$\n"); - out->Indent(); - - out->Print(GetRubyComments(service, true).c_str()); - out->Print("class Service\n"); - - // Write the indented class body. - out->Indent(); - out->Print("\n"); - out->Print("include ::GRPC::GenericService\n"); - out->Print("\n"); - out->Print("self.marshal_class_method = :encode\n"); - out->Print("self.unmarshal_class_method = :decode\n"); - std::map<TString, TString> pkg_vars = - ListToDict({"service_full_name", service->full_name()}); - out->Print(pkg_vars, "self.service_name = '$service_full_name$'\n"); - out->Print("\n"); - for (int i = 0; i < service->method_count(); ++i) { - PrintMethod(service->method(i), out); - } - out->Outdent(); - - out->Print("end\n"); - out->Print("\n"); - out->Print("Stub = Service.rpc_stub_class\n"); - - // End the service module - out->Outdent(); - out->Print("end\n"); - out->Print(GetRubyComments(service, false).c_str()); -} - -} // namespace - -// The following functions are copied directly from the source for the protoc -// ruby generator -// to ensure compatibility (with the exception of int and string type changes). -// See -// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/ruby/ruby_generator.cc#L250 -// TODO: keep up to date with protoc code generation, though this behavior isn't -// expected to change -bool IsLower(char ch) { return ch >= 'a' && ch <= 'z'; } - -char ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; } - -// Package names in protobuf are snake_case by convention, but Ruby module -// names must be PascalCased. -// -// foo_bar_baz -> FooBarBaz -TString PackageToModule(const TString& name) { - bool next_upper = true; - TString result; - result.reserve(name.size()); - - for (TString::size_type i = 0; i < name.size(); i++) { - if (name[i] == '_') { - next_upper = true; - } else { - if (next_upper) { - result.push_back(ToUpper(name[i])); - } else { - result.push_back(name[i]); - } - next_upper = false; - } - } - - return result; -} -// end copying of protoc generator for ruby code - -TString GetServices(const FileDescriptor* file) { - TString output; - { - // Scope the output stream so it closes and finalizes output to the string. - - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - - // Don't write out any output if there no services, to avoid empty service - // files being generated for proto files that don't declare any. - if (file->service_count() == 0) { - return output; - } - - TString package_name = RubyPackage(file); - - // Write out a file header. - std::map<TString, TString> header_comment_vars = ListToDict({ - "file.name", - file->name(), - "file.package", - package_name, - }); - out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n"); - out.Print(header_comment_vars, - "# Source: $file.name$ for package '$file.package$'\n"); - - TString leading_comments = GetRubyComments(file, true); - if (!leading_comments.empty()) { - out.Print("# Original file comments:\n"); - out.PrintRaw(leading_comments.c_str()); - } - - out.Print("\n"); - out.Print("require 'grpc'\n"); - // Write out require statemment to import the separately generated file - // that defines the messages used by the service. This is generated by the - // main ruby plugin. - std::map<TString, TString> dep_vars = ListToDict({ - "dep.name", - MessagesRequireName(file), - }); - out.Print(dep_vars, "require '$dep.name$'\n"); - - // Write out services within the modules - out.Print("\n"); - std::vector<TString> modules = Split(package_name, '.'); - for (size_t i = 0; i < modules.size(); ++i) { - std::map<TString, TString> module_vars = ListToDict({ - "module.name", - PackageToModule(modules[i]), - }); - out.Print(module_vars, "module $module.name$\n"); - out.Indent(); - } - for (int i = 0; i < file->service_count(); ++i) { - auto service = file->service(i); - PrintService(service, &out); - } - for (size_t i = 0; i < modules.size(); ++i) { - out.Outdent(); - out.Print("end\n"); - } - - out.Print(GetRubyComments(file, false).c_str()); - } - return output; -} - -} // namespace grpc_ruby_generator diff --git a/contrib/libs/grpc/src/compiler/ruby_generator.h b/contrib/libs/grpc/src/compiler/ruby_generator.h deleted file mode 100644 index 325dc02294..0000000000 --- a/contrib/libs/grpc/src/compiler/ruby_generator.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H - -#include "src/compiler/config.h" - -namespace grpc_ruby_generator { - -TString GetServices(const grpc::protobuf::FileDescriptor* file); - -} // namespace grpc_ruby_generator - -#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h deleted file mode 100644 index 9a10976619..0000000000 --- a/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H -#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H - -#include "src/compiler/config.h" -#include "src/compiler/generator_helpers.h" -#include "src/compiler/ruby_generator_string-inl.h" - -namespace grpc_ruby_generator { - -inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, - TString* file_name_or_error) { - // Get output file name. - static const unsigned proto_suffix_length = 6; // length of ".proto" - if (file->name().size() > proto_suffix_length && - file->name().find_last_of(".proto") == file->name().size() - 1) { - *file_name_or_error = - file->name().substr(0, file->name().size() - proto_suffix_length) + - "_services_pb.rb"; - return true; - } else { - *file_name_or_error = "Invalid proto file name: must end with .proto"; - return false; - } -} - -inline TString MessagesRequireName( - const grpc::protobuf::FileDescriptor* file) { - return Replace(file->name(), ".proto", "_pb"); -} - -// Get leading or trailing comments in a string. Comment lines start with "# ". -// Leading detached comments are put in front of leading comments. -template <typename DescriptorType> -inline TString GetRubyComments(const DescriptorType* desc, bool leading) { - return grpc_generator::GetPrefixedComments(desc, leading, "#"); -} - -} // namespace grpc_ruby_generator - -#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h deleted file mode 100644 index 1221a5a705..0000000000 --- a/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H -#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H - -#include <initializer_list> -#include <iostream> -#include <map> -#include <ostream> // NOLINT -#include <vector> - -#include "src/compiler/config.h" - -using std::initializer_list; -using std::map; -using std::vector; - -namespace grpc_ruby_generator { - -// Converts an initializer list of the form { key0, value0, key1, value1, ... } -// into a map of key* to value*. Is merely a readability helper for later code. -inline std::map<TString, TString> ListToDict( - const initializer_list<TString>& values) { - if (values.size() % 2 != 0) { - std::cerr << "Not every 'key' has a value in `values`." << std::endl; - } - std::map<TString, TString> value_map; - auto value_iter = values.begin(); - for (unsigned i = 0; i < values.size() / 2; ++i) { - TString key = *value_iter; - ++value_iter; - TString value = *value_iter; - value_map[key] = value; - ++value_iter; - } - return value_map; -} - -} // namespace grpc_ruby_generator - -#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h deleted file mode 100644 index 0df783023e..0000000000 --- a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H -#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H - -#include <algorithm> -#include <sstream> -#include <vector> - -#include "src/compiler/config.h" - -using std::getline; -using std::transform; - -namespace grpc_ruby_generator { - -// Split splits a string using char into elems. -inline std::vector<TString>& Split(const TString& s, char delim, - std::vector<TString>* elems) { - std::stringstream ss(s); - TString item; - while (getline(ss, item, delim)) { - elems->push_back(item); - } - return *elems; -} - -// Split splits a string using char, returning the result in a vector. -inline std::vector<TString> Split(const TString& s, char delim) { - std::vector<TString> elems; - Split(s, delim, &elems); - return elems; -} - -// Replace replaces from with to in s. -inline TString Replace(TString s, const TString& from, - const TString& to) { - size_t start_pos = s.find(from); - if (start_pos == TString::npos) { - return s; - } - s.replace(start_pos, from.length(), to); - return s; -} - -// ReplaceAll replaces all instances of search with replace in s. -inline TString ReplaceAll(TString s, const TString& search, - const TString& replace) { - size_t pos = 0; - while ((pos = s.find(search, pos)) != TString::npos) { - s.replace(pos, search.length(), replace); - pos += replace.length(); - } - return s; -} - -// ReplacePrefix replaces from with to in s if search is a prefix of s. -inline bool ReplacePrefix(TString* s, const TString& from, - const TString& to) { - size_t start_pos = s->find(from); - if (start_pos == TString::npos || start_pos != 0) { - return false; - } - s->replace(start_pos, from.length(), to); - return true; -} - -// Modularize converts a string into a ruby module compatible name -inline TString Modularize(TString s) { - if (s.empty()) { - return s; - } - TString new_string = ""; - bool was_last_underscore = false; - new_string.append(1, ::toupper(s[0])); - for (TString::size_type i = 1; i < s.size(); ++i) { - if (was_last_underscore && s[i] != '_') { - new_string.append(1, ::toupper(s[i])); - } else if (s[i] != '_') { - new_string.append(1, s[i]); - } - was_last_underscore = s[i] == '_'; - } - return new_string; -} - -// RubyPackage gets the ruby package in either proto or ruby_package format -inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) { - TString package_name = file->package(); - if (file->options().has_ruby_package()) { - package_name = file->options().ruby_package(); - - // If :: is in the package convert the Ruby formatted name - // -> A::B::C - // to use the dot seperator notation - // -> A.B.C - package_name = ReplaceAll(package_name, "::", "."); - } - return package_name; -} - -// RubyTypeOf updates a proto type to the required ruby equivalent. -inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) { - TString proto_type = descriptor->full_name(); - if (descriptor->file()->options().has_ruby_package()) { - // remove the leading package if present - ReplacePrefix(&proto_type, descriptor->file()->package(), ""); - ReplacePrefix(&proto_type, ".", ""); // remove the leading . (no package) - proto_type = RubyPackage(descriptor->file()) + "." + proto_type; - } - TString res("." + proto_type); - if (res.find('.') == TString::npos) { - return res; - } else { - std::vector<TString> prefixes_and_type = Split(res, '.'); - res.clear(); - for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) { - if (i != 0) { - res += "::"; // switch '.' to the ruby module delim - } - if (i < prefixes_and_type.size() - 1) { - res += Modularize(prefixes_and_type[i]); // capitalize pkgs - } else { - res += prefixes_and_type[i]; - } - } - return res; - } -} - -} // namespace grpc_ruby_generator - -#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H diff --git a/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt deleted file mode 100644 index 6e637b3aa5..0000000000 --- a/contrib/libs/grpc/src/core/lib/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,66 +0,0 @@ -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2019 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2021 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2021 the gRPC authors. diff --git a/contrib/libs/grpc/src/core/lib/debug/stats_data_bq_schema.sql b/contrib/libs/grpc/src/core/lib/debug/stats_data_bq_schema.sql deleted file mode 100644 index 7d1ab1dae9..0000000000 --- a/contrib/libs/grpc/src/core/lib/debug/stats_data_bq_schema.sql +++ /dev/null @@ -1,98 +0,0 @@ -client_calls_created_per_iteration:FLOAT, -server_calls_created_per_iteration:FLOAT, -cqs_created_per_iteration:FLOAT, -client_channels_created_per_iteration:FLOAT, -client_subchannels_created_per_iteration:FLOAT, -server_channels_created_per_iteration:FLOAT, -syscall_poll_per_iteration:FLOAT, -syscall_wait_per_iteration:FLOAT, -pollset_kick_per_iteration:FLOAT, -pollset_kicked_without_poller_per_iteration:FLOAT, -pollset_kicked_again_per_iteration:FLOAT, -pollset_kick_wakeup_fd_per_iteration:FLOAT, -pollset_kick_wakeup_cv_per_iteration:FLOAT, -pollset_kick_own_thread_per_iteration:FLOAT, -syscall_epoll_ctl_per_iteration:FLOAT, -pollset_fd_cache_hits_per_iteration:FLOAT, -histogram_slow_lookups_per_iteration:FLOAT, -syscall_write_per_iteration:FLOAT, -syscall_read_per_iteration:FLOAT, -tcp_backup_pollers_created_per_iteration:FLOAT, -tcp_backup_poller_polls_per_iteration:FLOAT, -http2_op_batches_per_iteration:FLOAT, -http2_op_cancel_per_iteration:FLOAT, -http2_op_send_initial_metadata_per_iteration:FLOAT, -http2_op_send_message_per_iteration:FLOAT, -http2_op_send_trailing_metadata_per_iteration:FLOAT, -http2_op_recv_initial_metadata_per_iteration:FLOAT, -http2_op_recv_message_per_iteration:FLOAT, -http2_op_recv_trailing_metadata_per_iteration:FLOAT, -http2_settings_writes_per_iteration:FLOAT, -http2_pings_sent_per_iteration:FLOAT, -http2_writes_begun_per_iteration:FLOAT, -http2_writes_offloaded_per_iteration:FLOAT, -http2_writes_continued_per_iteration:FLOAT, -http2_partial_writes_per_iteration:FLOAT, -http2_initiate_write_due_to_initial_write_per_iteration:FLOAT, -http2_initiate_write_due_to_start_new_stream_per_iteration:FLOAT, -http2_initiate_write_due_to_send_message_per_iteration:FLOAT, -http2_initiate_write_due_to_send_initial_metadata_per_iteration:FLOAT, -http2_initiate_write_due_to_send_trailing_metadata_per_iteration:FLOAT, -http2_initiate_write_due_to_retry_send_ping_per_iteration:FLOAT, -http2_initiate_write_due_to_continue_pings_per_iteration:FLOAT, -http2_initiate_write_due_to_goaway_sent_per_iteration:FLOAT, -http2_initiate_write_due_to_rst_stream_per_iteration:FLOAT, -http2_initiate_write_due_to_close_from_api_per_iteration:FLOAT, -http2_initiate_write_due_to_stream_flow_control_per_iteration:FLOAT, -http2_initiate_write_due_to_transport_flow_control_per_iteration:FLOAT, -http2_initiate_write_due_to_send_settings_per_iteration:FLOAT, -http2_initiate_write_due_to_bdp_estimator_ping_per_iteration:FLOAT, -http2_initiate_write_due_to_flow_control_unstalled_by_setting_per_iteration:FLOAT, -http2_initiate_write_due_to_flow_control_unstalled_by_update_per_iteration:FLOAT, -http2_initiate_write_due_to_application_ping_per_iteration:FLOAT, -http2_initiate_write_due_to_keepalive_ping_per_iteration:FLOAT, -http2_initiate_write_due_to_transport_flow_control_unstalled_per_iteration:FLOAT, -http2_initiate_write_due_to_ping_response_per_iteration:FLOAT, -http2_initiate_write_due_to_force_rst_stream_per_iteration:FLOAT, -http2_spurious_writes_begun_per_iteration:FLOAT, -hpack_recv_indexed_per_iteration:FLOAT, -hpack_recv_lithdr_incidx_per_iteration:FLOAT, -hpack_recv_lithdr_incidx_v_per_iteration:FLOAT, -hpack_recv_lithdr_notidx_per_iteration:FLOAT, -hpack_recv_lithdr_notidx_v_per_iteration:FLOAT, -hpack_recv_lithdr_nvridx_per_iteration:FLOAT, -hpack_recv_lithdr_nvridx_v_per_iteration:FLOAT, -hpack_recv_uncompressed_per_iteration:FLOAT, -hpack_recv_huffman_per_iteration:FLOAT, -hpack_recv_binary_per_iteration:FLOAT, -hpack_recv_binary_base64_per_iteration:FLOAT, -hpack_send_indexed_per_iteration:FLOAT, -hpack_send_lithdr_incidx_per_iteration:FLOAT, -hpack_send_lithdr_incidx_v_per_iteration:FLOAT, -hpack_send_lithdr_notidx_per_iteration:FLOAT, -hpack_send_lithdr_notidx_v_per_iteration:FLOAT, -hpack_send_lithdr_nvridx_per_iteration:FLOAT, -hpack_send_lithdr_nvridx_v_per_iteration:FLOAT, -hpack_send_uncompressed_per_iteration:FLOAT, -hpack_send_huffman_per_iteration:FLOAT, -hpack_send_binary_per_iteration:FLOAT, -hpack_send_binary_base64_per_iteration:FLOAT, -combiner_locks_initiated_per_iteration:FLOAT, -combiner_locks_scheduled_items_per_iteration:FLOAT, -combiner_locks_scheduled_final_items_per_iteration:FLOAT, -combiner_locks_offloaded_per_iteration:FLOAT, -call_combiner_locks_initiated_per_iteration:FLOAT, -call_combiner_locks_scheduled_items_per_iteration:FLOAT, -call_combiner_set_notify_on_cancel_per_iteration:FLOAT, -call_combiner_cancelled_per_iteration:FLOAT, -executor_scheduled_short_items_per_iteration:FLOAT, -executor_scheduled_long_items_per_iteration:FLOAT, -executor_scheduled_to_self_per_iteration:FLOAT, -executor_wakeup_initiated_per_iteration:FLOAT, -executor_queue_drained_per_iteration:FLOAT, -executor_push_retries_per_iteration:FLOAT, -server_requested_calls_per_iteration:FLOAT, -server_slowpath_requests_queued_per_iteration:FLOAT, -cq_ev_queue_trylock_failures_per_iteration:FLOAT, -cq_ev_queue_trylock_successes_per_iteration:FLOAT, -cq_ev_queue_transient_pop_failures_per_iteration:FLOAT diff --git a/contrib/libs/grpc/src/core/lib/gprpp/capture.h b/contrib/libs/grpc/src/core/lib/gprpp/capture.h deleted file mode 100644 index 07949fd1c9..0000000000 --- a/contrib/libs/grpc/src/core/lib/gprpp/capture.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_GPRPP_CAPTURE_H -#define GRPC_CORE_LIB_GPRPP_CAPTURE_H - -#include <grpc/support/port_platform.h> - -#include <tuple> -#include <utility> - -#include "y_absl/utility/utility.h" - -namespace grpc_core { - -namespace detail { - -template <typename F, typename... Captures> -class Capture { - public: - explicit Capture(F f, Captures... captures) - : f_(std::move(f)), captures_(std::move(captures)...) {} - - template <typename... Args> - decltype(std::declval<F>()(static_cast<Captures*>(nullptr)..., - std::declval<Args>()...)) - operator()(Args... args) { - auto f = &f_; - return y_absl::apply( - [f, &args...](Captures&... captures) { - return (*f)(&captures..., std::move(args)...); - }, - captures_); - } - - private: - GPR_NO_UNIQUE_ADDRESS F f_; - GPR_NO_UNIQUE_ADDRESS std::tuple<Captures...> captures_; -}; - -} // namespace detail - -// C++11 helper - best explained by usage: -// -// BigThing big_thing; -// auto f = Capture( -// [](BigThing* c, int a, int b) { /*...*/ }, -// std::move(big_thing)); -// -// results in: f being a callable that takes arguments (int a, int b), and -// captures the original value of big_thing by move. Each call, a pointer to -// each captured thing is inserted into the argument list at the beginning so it -// can be manipulated. -// -// Captured values are mutable, and it's the users responsibility to ensure, -// should this callable be invoked from different threads, that proper locking -// is implemented. -template <typename F, typename... Captures> -detail::Capture<F, Captures...> Capture(F f, Captures... captures) { - return detail::Capture<F, Captures...>(std::move(f), std::move(captures)...); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_GPRPP_CAPTURE_H diff --git a/contrib/libs/grpc/src/core/lib/gprpp/match.h b/contrib/libs/grpc/src/core/lib/gprpp/match.h deleted file mode 100644 index 39892fe473..0000000000 --- a/contrib/libs/grpc/src/core/lib/gprpp/match.h +++ /dev/null @@ -1,73 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_GPRPP_MATCH_H -#define GRPC_CORE_LIB_GPRPP_MATCH_H - -#include <grpc/support/port_platform.h> - -#include "y_absl/types/variant.h" - -#include "src/core/lib/gprpp/overload.h" - -namespace grpc_core { - -namespace detail { - -template <typename... Cases> -struct MatchPointerExtractor { - OverloadType<Cases...> cases; - template <typename T> - auto operator()(T& value) -> decltype(cases(&value)) { - return cases(&value); - } -}; - -} // namespace detail - -/// Match on a variant. -/// Given variant \a value, and a set of callables \a fs, call the appropriate -/// callable based on the type contained in \a value. -/// -/// Example (prints "hoorah"): -/// variant<int, string> v = 42; -/// Match(v, -/// [](int i) { puts("hoorah"); }, -/// [](string s) { puts("boo"); }); -template <typename... Fs, typename T0, typename... Ts> -auto Match(const y_absl::variant<T0, Ts...>& value, Fs... fs) - -> decltype(std::declval<OverloadType<Fs...>>()(std::declval<T0>())) { - return y_absl::visit(Overload(std::move(fs)...), value); -} - -/// A version of Match that takes a mutable pointer to a variant and calls its -/// overload callables with a mutable pointer to the current variant value. -/// -/// Example: -/// variant<int, string> v = 42; -/// MatchMutable(&v, -/// [](int* i) { *i = 1; }, -/// [](string* s) { *s = "foo"; }); -/// // v now contains 1. -template <typename... Fs, typename T0, typename... Ts> -auto MatchMutable(y_absl::variant<T0, Ts...>* value, Fs... fs) - -> decltype(std::declval<OverloadType<Fs...>>()(std::declval<T0*>())) { - return y_absl::visit(detail::MatchPointerExtractor<Fs...>{OverloadType<Fs...>( - std::move(fs)...)}, - *value); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_GPRPP_MATCH_H diff --git a/contrib/libs/grpc/src/core/lib/gprpp/overload.h b/contrib/libs/grpc/src/core/lib/gprpp/overload.h deleted file mode 100644 index c243a8c010..0000000000 --- a/contrib/libs/grpc/src/core/lib/gprpp/overload.h +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_GPRPP_OVERLOAD_H -#define GRPC_CORE_LIB_GPRPP_OVERLOAD_H - -#include <grpc/support/port_platform.h> - -#include <utility> - -namespace grpc_core { - -template <typename... Cases> -struct OverloadType; -// Compose one overload with N more -- use inheritance to leverage using and the -// empty base class optimization. -template <typename Case, typename... Cases> -struct OverloadType<Case, Cases...> : public Case, - public OverloadType<Cases...> { - explicit OverloadType(Case&& c, Cases&&... cases) - : Case(std::forward<Case>(c)), - OverloadType<Cases...>(std::forward<Cases>(cases)...) {} - using Case::operator(); - using OverloadType<Cases...>::operator(); -}; -// Overload of a single case is just that case itself -template <typename Case> -struct OverloadType<Case> : public Case { - explicit OverloadType(Case&& c) : Case(std::forward<Case>(c)) {} - using Case::operator(); -}; - -/// Compose callables into a single callable. -/// e.g. given [](int i) { puts("a"); } and [](double d) { puts("b"); }, -/// return a callable object like: -/// struct { -/// void operator()(int i) { puts("a"); } -/// void operator()(double i) { puts("b"); } -/// }; -/// Preserves all captures. -template <typename... Cases> -OverloadType<Cases...> Overload(Cases... cases) { - return OverloadType<Cases...>(std::move(cases)...); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_GPRPP_OVERLOAD_H diff --git a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h b/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h deleted file mode 100644 index 2ac002b6f3..0000000000 --- a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2016 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_CORE_LIB_IOMGR_TIMER_GENERIC_H -#define GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H - -#include <grpc/support/port_platform.h> - -#include <grpc/support/time.h> - -#include "src/core/lib/iomgr/exec_ctx.h" - -struct grpc_timer { - gpr_atm deadline; - uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */ - bool pending; - struct grpc_timer* next; - struct grpc_timer* prev; - grpc_closure* closure; -#ifndef NDEBUG - struct grpc_timer* hash_table_next; -#endif -}; - -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H */ diff --git a/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d b/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d deleted file mode 100644 index 153de91752..0000000000 --- a/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d +++ /dev/null @@ -1,7 +0,0 @@ -provider _stap { - probe add_mark(int tag); - probe add_important_mark(int tag); - probe timing_ns_begin(int tag); - probe timing_ns_end(int tag); -}; - diff --git a/contrib/libs/grpc/src/core/lib/promise/arena_promise.h b/contrib/libs/grpc/src/core/lib/promise/arena_promise.h deleted file mode 100644 index ef0fff11e3..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/arena_promise.h +++ /dev/null @@ -1,184 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_ARENA_PROMISE_H -#define GRPC_CORE_LIB_PROMISE_ARENA_PROMISE_H - -#include <grpc/support/port_platform.h> - -#include <grpc/support/log.h> - -#include "src/core/lib/gprpp/arena.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -namespace arena_promise_detail { - -// Type erased promise stored in the arena. -template <typename T> -class ImplInterface { - public: - // Poll the promise, once. - virtual Poll<T> PollOnce() = 0; - // Destroy the underlying callable object if there is one. - // Since we don't delete (the arena owns the memory) but we may need to call a - // destructor, we expose this for when the ArenaPromise object is destroyed. - virtual void Destroy() = 0; - - protected: - ~ImplInterface() = default; -}; - -// Implementation of ImplInterface for an empty object. -// Used when an empty ArenaPromise is created, or when the ArenaPromise is moved -// from. Since in either case these objects should not be polled, we simply -// crash if it is. -template <typename T> -class NullImpl final : public ImplInterface<T> { - public: - Poll<T> PollOnce() override { - abort(); - GPR_UNREACHABLE_CODE(return Pending{}); - } - void Destroy() override {} - - static ImplInterface<T>* Get() { - static NullImpl<T> instance; - return &instance; - } - - private: - ~NullImpl() = default; -}; - -// Implementation of ImplInterface for a callable object. -template <typename T, typename Callable> -class CallableImpl final : public ImplInterface<T> { - public: - explicit CallableImpl(Callable&& callable) : callable_(std::move(callable)) {} - // Forward polls to the callable object. - Poll<T> PollOnce() override { return callable_(); } - // Destroy destructs the callable object. - void Destroy() override { this->~CallableImpl(); } - - private: - // Should only be called by Destroy(). - ~CallableImpl() = default; - - Callable callable_; -}; - -// If a callable object is empty we can substitute any instance of that callable -// for the one we call (for how could we tell the difference)? -// Since this corresponds to a lambda with no fields, and we expect these to be -// reasonably common, we can elide the arena allocation entirely and simply poll -// a global shared instance. -// (this comes up often when the promise only accesses context data from the -// containing activity). -template <typename T, typename Callable> -class SharedImpl final : public ImplInterface<T>, private Callable { - public: - // Call the callable, or at least an exact duplicate of it - if you have no - // members, all your instances look the same. - Poll<T> PollOnce() override { return Callable::operator()(); } - // Nothing to destroy. - void Destroy() override {} - // Return a pointer to the shared instance - these are singletons, and are - // needed just to get the vtable in place. - static SharedImpl* Get(Callable&& callable) { - static_assert(sizeof(SharedImpl) == sizeof(void*), - "SharedImpl should be pointer sized"); - static SharedImpl impl(std::forward<Callable>(callable)); - return &impl; - } - - private: - explicit SharedImpl(Callable&& callable) - : Callable(std::forward<Callable>(callable)) {} - ~SharedImpl() = default; -}; - -// Redirector type: given a callable type, expose a Make() function that creates -// the appropriate underlying implementation. -template <typename T, typename Callable, typename Ignored = void> -struct ChooseImplForCallable; - -template <typename T, typename Callable> -struct ChooseImplForCallable< - T, Callable, y_absl::enable_if_t<!std::is_empty<Callable>::value>> { - static ImplInterface<T>* Make(Arena* arena, Callable&& callable) { - return arena->template New<CallableImpl<T, Callable>>( - std::forward<Callable>(callable)); - } -}; - -template <typename T, typename Callable> -struct ChooseImplForCallable< - T, Callable, y_absl::enable_if_t<std::is_empty<Callable>::value>> { - static ImplInterface<T>* Make(Arena*, Callable&& callable) { - return SharedImpl<T, Callable>::Get(std::forward<Callable>(callable)); - } -}; - -// Wrap ChooseImplForCallable with a friend approachable syntax. -template <typename T, typename Callable> -ImplInterface<T>* MakeImplForCallable(Arena* arena, Callable&& callable) { - return ChooseImplForCallable<T, Callable>::Make( - arena, std::forward<Callable>(callable)); -} - -} // namespace arena_promise_detail - -// A promise for which the state memory is allocated from an arena. -template <typename T> -class ArenaPromise { - public: - // Construct an empty, uncallable, invalid ArenaPromise. - ArenaPromise() = default; - - // Construct an ArenaPromise that will call the given callable when polled. - template <typename Callable> - ArenaPromise(Arena* arena, Callable&& callable) - : impl_(arena_promise_detail::MakeImplForCallable<T>( - arena, std::forward<Callable>(callable))) {} - - // ArenaPromise is not copyable. - ArenaPromise(const ArenaPromise&) = delete; - ArenaPromise& operator=(const ArenaPromise&) = delete; - // ArenaPromise is movable. - ArenaPromise(ArenaPromise&& other) noexcept : impl_(other.impl_) { - other.impl_ = arena_promise_detail::NullImpl<T>::Get(); - } - ArenaPromise& operator=(ArenaPromise&& other) noexcept { - impl_ = other.impl_; - other.impl_ = arena_promise_detail::NullImpl<T>::Get(); - return *this; - } - - // Destruction => call Destroy on the underlying impl object. - ~ArenaPromise() { impl_->Destroy(); } - - // Expose the promise interface: a call operator that returns Poll<T>. - Poll<T> operator()() { return impl_->PollOnce(); } - - private: - // Underlying impl object. - arena_promise_detail::ImplInterface<T>* impl_ = - arena_promise_detail::NullImpl<T>::Get(); -}; - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_PROMISE_ARENA_PROMISE_H */ diff --git a/contrib/libs/grpc/src/core/lib/promise/detail/basic_join.h b/contrib/libs/grpc/src/core/lib/promise/detail/basic_join.h deleted file mode 100644 index 799109faf0..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/detail/basic_join.h +++ /dev/null @@ -1,199 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_DETAIL_BASIC_JOIN_H -#define GRPC_CORE_LIB_PROMISE_DETAIL_BASIC_JOIN_H - -#include <grpc/support/port_platform.h> - -#include <assert.h> -#include <stddef.h> - -#include <array> -#include <tuple> -#include <type_traits> -#include <utility> - -#include "y_absl/types/variant.h" -#include "y_absl/utility/utility.h" - -#include "src/core/lib/gprpp/bitset.h" -#include "src/core/lib/gprpp/construct_destruct.h" -#include "src/core/lib/promise/detail/promise_factory.h" -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { -namespace promise_detail { - -// This union can either be a functor, or the result of the functor (after -// mapping via a trait). Allows us to remember the result of one joined functor -// until the rest are ready. -template <typename Traits, typename F> -union Fused { - explicit Fused(F&& f) : f(std::forward<F>(f)) {} - explicit Fused(PromiseLike<F>&& f) : f(std::forward<PromiseLike<F>>(f)) {} - ~Fused() {} - // Wrap the functor in a PromiseLike to handle immediately returning functors - // and the like. - using Promise = PromiseLike<F>; - GPR_NO_UNIQUE_ADDRESS Promise f; - // Compute the result type: We take the result of the promise, and pass it via - // our traits, so that, for example, TryJoin and take a StatusOr<T> and just - // store a T. - using Result = typename Traits::template ResultType<typename Promise::Result>; - GPR_NO_UNIQUE_ADDRESS Result result; -}; - -// A join gets composed of joints... these are just wrappers around a Fused for -// their data, with some machinery as methods to get the system working. -template <typename Traits, size_t kRemaining, typename... Fs> -struct Joint : public Joint<Traits, kRemaining - 1, Fs...> { - // The index into Fs for this Joint - static constexpr size_t kIdx = sizeof...(Fs) - kRemaining; - // The next join (the one we derive from) - using NextJoint = Joint<Traits, kRemaining - 1, Fs...>; - // From Fs, extract the functor for this joint. - using F = typename std::tuple_element<kIdx, std::tuple<Fs...>>::type; - // Generate the Fused type for this functor. - using Fsd = Fused<Traits, F>; - GPR_NO_UNIQUE_ADDRESS Fsd fused; - // Figure out what kind of bitmask will be used by the outer join. - using Bits = BitSet<sizeof...(Fs)>; - // Initialize from a tuple of pointers to Fs - explicit Joint(std::tuple<Fs*...> fs) - : NextJoint(fs), fused(std::move(*std::get<kIdx>(fs))) {} - // Copy: assume that the Fuse is still in the promise state (since it's not - // legal to copy after the first poll!) - Joint(const Joint& j) : NextJoint(j), fused(j.fused.f) {} - // Move: assume that the Fuse is still in the promise state (since it's not - // legal to move after the first poll!) - Joint(Joint&& j) noexcept - : NextJoint(std::forward<NextJoint>(j)), fused(std::move(j.fused.f)) {} - // Destruct: check bits to see if we're in promise or result state, and call - // the appropriate destructor. Recursively, call up through the join. - void DestructAll(const Bits& bits) { - if (!bits.is_set(kIdx)) { - Destruct(&fused.f); - } else { - Destruct(&fused.result); - } - NextJoint::DestructAll(bits); - } - // Poll all joints up, and then call finally. - template <typename F> - auto Run(Bits* bits, F finally) -> decltype(finally()) { - // If we're still in the promise state... - if (!bits->is_set(kIdx)) { - // Poll the promise - auto r = fused.f(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - // If it's done, then ask the trait to unwrap it and store that result - // in the Fused, and continue the iteration. Note that OnResult could - // instead choose to return a value instead of recursing through the - // iteration, in that case we continue returning the same result up. - // Here is where TryJoin can escape out. - return Traits::OnResult( - std::move(*p), [this, bits, &finally](typename Fsd::Result result) { - bits->set(kIdx); - Destruct(&fused.f); - Construct(&fused.result, std::move(result)); - return NextJoint::Run(bits, std::move(finally)); - }); - } - } - // That joint is still pending... we'll still poll the result of the joints. - return NextJoint::Run(bits, std::move(finally)); - } -}; - -// Terminating joint... for each of the recursions, do the thing we're supposed -// to do at the end. -template <typename Traits, typename... Fs> -struct Joint<Traits, 0, Fs...> { - explicit Joint(std::tuple<Fs*...>) {} - Joint(const Joint&) {} - Joint(Joint&&) noexcept {} - template <typename T> - void DestructAll(const T&) {} - template <typename F> - auto Run(BitSet<sizeof...(Fs)>*, F finally) -> decltype(finally()) { - return finally(); - } -}; - -template <typename Traits, typename... Fs> -class BasicJoin { - private: - // How many things are we joining? - static constexpr size_t N = sizeof...(Fs); - // Bitset: if a bit is 0, that joint is still in promise state. If it's 1, - // then the joint has a result. - GPR_NO_UNIQUE_ADDRESS BitSet<N> state_; - // The actual joints, wrapped in an anonymous union to give us control of - // construction/destruction. - union { - GPR_NO_UNIQUE_ADDRESS Joint<Traits, sizeof...(Fs), Fs...> joints_; - }; - - // Access joint index I - template <size_t I> - Joint<Traits, sizeof...(Fs) - I, Fs...>* GetJoint() { - return static_cast<Joint<Traits, sizeof...(Fs) - I, Fs...>*>(&joints_); - } - - // The tuple of results of all our promises - using Tuple = std::tuple<typename Fused<Traits, Fs>::Result...>; - - // Collect up all the results and construct a tuple. - template <size_t... I> - Tuple Finish(y_absl::index_sequence<I...>) { - return Tuple(std::move(GetJoint<I>()->fused.result)...); - } - - public: - explicit BasicJoin(Fs&&... fs) : joints_(std::tuple<Fs*...>(&fs...)) {} - BasicJoin& operator=(const BasicJoin&) = delete; - // Copy a join - only available before polling. - BasicJoin(const BasicJoin& other) { - assert(other.state_.none()); - Construct(&joints_, other.joints_); - } - // Move a join - only available before polling. - BasicJoin(BasicJoin&& other) noexcept { - assert(other.state_.none()); - Construct(&joints_, std::move(other.joints_)); - } - ~BasicJoin() { joints_.DestructAll(state_); } - using Result = decltype(Traits::Wrap(std::declval<Tuple>())); - // Poll the join - Poll<Result> operator()() { - // Poll the joints... - return joints_.Run(&state_, [this]() -> Poll<Result> { - // If all of them are completed, collect the results, and then ask our - // traits to wrap them - allowing for example TryJoin to turn tuple<A,B,C> - // into StatusOr<tuple<A,B,C>>. - if (state_.all()) { - return Traits::Wrap(Finish(y_absl::make_index_sequence<N>())); - } else { - return Pending(); - } - }); - } -}; - -} // namespace promise_detail -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_DETAIL_BASIC_JOIN_H diff --git a/contrib/libs/grpc/src/core/lib/promise/for_each.h b/contrib/libs/grpc/src/core/lib/promise/for_each.h deleted file mode 100644 index b09f5e8493..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/for_each.h +++ /dev/null @@ -1,140 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_FOR_EACH_H -#define GRPC_CORE_LIB_PROMISE_FOR_EACH_H - -#include <grpc/support/port_platform.h> - -#include <type_traits> -#include <utility> - -#include "y_absl/status/status.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/detail/promise_factory.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -namespace for_each_detail { - -// Helper function: at the end of each iteration of a for-each loop, this is -// called. If the iteration failed, return failure. If the iteration succeeded, -// then call the next iteration. -template <typename Reader, typename CallPoll> -Poll<y_absl::Status> FinishIteration(y_absl::Status* r, Reader* reader, - CallPoll call_poll) { - if (r->ok()) { - auto next = reader->Next(); - return call_poll(next); - } - return std::move(*r); -} - -// Done creates statuses for the end of the iteration. It's templated on the -// type of the result of the ForEach loop, so that we can introduce new types -// easily. -template <typename T> -struct Done; - -template <> -struct Done<y_absl::Status> { - static y_absl::Status Make() { return y_absl::OkStatus(); } -}; - -template <typename Reader, typename Action> -class ForEach { - private: - using ReaderNext = decltype(std::declval<Reader>().Next()); - using ReaderResult = typename PollTraits<decltype( - std::declval<ReaderNext>()())>::Type::value_type; - using ActionFactory = promise_detail::PromiseFactory<ReaderResult, Action>; - using ActionPromise = typename ActionFactory::Promise; - - public: - using Result = - typename PollTraits<decltype(std::declval<ActionPromise>()())>::Type; - ForEach(Reader reader, Action action) - : reader_(std::move(reader)), - action_factory_(std::move(action)), - state_(reader_.Next()) {} - - ForEach(const ForEach&) = delete; - ForEach& operator=(const ForEach&) = delete; - // noexcept causes compiler errors on older gcc's - // NOLINTNEXTLINE(performance-noexcept-move-constructor) - ForEach(ForEach&&) = default; - // noexcept causes compiler errors on older gcc's - // NOLINTNEXTLINE(performance-noexcept-move-constructor) - ForEach& operator=(ForEach&&) = default; - - Poll<Result> operator()() { - return y_absl::visit(CallPoll<false>{this}, state_); - } - - private: - Reader reader_; - ActionFactory action_factory_; - y_absl::variant<ReaderNext, ActionPromise> state_; - - // Call the inner poll function, and if it's finished, start the next - // iteration. If kSetState==true, also set the current state in self->state_. - // We omit that on the first iteration because it's common to poll once and - // not change state, which saves us some work. - template <bool kSetState> - struct CallPoll { - ForEach* const self; - - Poll<Result> operator()(ReaderNext& reader_next) { - auto r = reader_next(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - if (p->has_value()) { - auto action = self->action_factory_.Repeated(std::move(**p)); - return CallPoll<true>{self}(action); - } else { - return Done<Result>::Make(); - } - } - if (kSetState) { - self->state_.template emplace<ReaderNext>(std::move(reader_next)); - } - return Pending(); - } - - Poll<Result> operator()(ActionPromise& promise) { - auto r = promise(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - return FinishIteration(p, &self->reader_, CallPoll<true>{self}); - } - if (kSetState) { - self->state_.template emplace<ActionPromise>(std::move(promise)); - } - return Pending(); - } - }; -}; - -} // namespace for_each_detail - -/// For each item acquired by calling Reader::Next, run the promise Action. -template <typename Reader, typename Action> -for_each_detail::ForEach<Reader, Action> ForEach(Reader reader, Action action) { - return for_each_detail::ForEach<Reader, Action>(std::move(reader), - std::move(action)); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_FOR_EACH_H diff --git a/contrib/libs/grpc/src/core/lib/promise/if.h b/contrib/libs/grpc/src/core/lib/promise/if.h deleted file mode 100644 index 475f1c60e9..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/if.h +++ /dev/null @@ -1,134 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_IF_H -#define GRPC_CORE_LIB_PROMISE_IF_H - -#include <grpc/support/port_platform.h> - -#include <type_traits> - -#include "y_absl/status/statusor.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/detail/promise_factory.h" -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -namespace promise_detail { - -template <typename CallPoll, typename T, typename F> -typename CallPoll::PollResult ChooseIf(CallPoll call_poll, bool result, - T* if_true, F* if_false) { - if (result) { - auto promise = if_true->Once(); - return call_poll(promise); - } else { - auto promise = if_false->Once(); - return call_poll(promise); - } -} - -template <typename CallPoll, typename T, typename F> -typename CallPoll::PollResult ChooseIf(CallPoll call_poll, - y_absl::StatusOr<bool> result, T* if_true, - F* if_false) { - if (!result.ok()) { - return typename CallPoll::PollResult(result.status()); - } else if (*result) { - auto promise = if_true->Once(); - return call_poll(promise); - } else { - auto promise = if_false->Once(); - return call_poll(promise); - } -} - -template <typename C, typename T, typename F> -class If { - private: - using TrueFactory = promise_detail::PromiseFactory<void, T>; - using FalseFactory = promise_detail::PromiseFactory<void, F>; - using ConditionPromise = PromiseLike<C>; - using TruePromise = typename TrueFactory::Promise; - using FalsePromise = typename FalseFactory::Promise; - using Result = - typename PollTraits<decltype(std::declval<TruePromise>()())>::Type; - - public: - If(C condition, T if_true, F if_false) - : state_(Evaluating{ConditionPromise(std::move(condition)), - TrueFactory(std::move(if_true)), - FalseFactory(std::move(if_false))}) {} - - Poll<Result> operator()() { - return y_absl::visit(CallPoll<false>{this}, state_); - } - - private: - struct Evaluating { - ConditionPromise condition; - TrueFactory if_true; - FalseFactory if_false; - }; - using State = y_absl::variant<Evaluating, TruePromise, FalsePromise>; - State state_; - - template <bool kSetState> - struct CallPoll { - using PollResult = Poll<Result>; - - If* const self; - - PollResult operator()(Evaluating& evaluating) const { - static_assert( - !kSetState, - "shouldn't need to set state coming through the initial branch"); - auto r = evaluating.condition(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - return ChooseIf(CallPoll<true>{self}, std::move(*p), - &evaluating.if_true, &evaluating.if_false); - } - return Pending(); - } - - template <class Promise> - PollResult operator()(Promise& promise) const { - auto r = promise(); - if (kSetState && y_absl::holds_alternative<Pending>(r)) { - self->state_.template emplace<Promise>(std::move(promise)); - } - return r; - } - }; -}; - -} // namespace promise_detail - -// If promise combinator. -// Takes 3 promise factories, and evaluates the first. -// If it returns failure, returns failure for the entire combinator. -// If it returns true, evaluates the second promise. -// If it returns false, evaluates the third promise. -template <typename C, typename T, typename F> -promise_detail::If<C, T, F> If(C condition, T if_true, F if_false) { - return promise_detail::If<C, T, F>(std::move(condition), std::move(if_true), - std::move(if_false)); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_IF_H diff --git a/contrib/libs/grpc/src/core/lib/promise/intra_activity_waiter.h b/contrib/libs/grpc/src/core/lib/promise/intra_activity_waiter.h deleted file mode 100644 index 889323bf3e..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/intra_activity_waiter.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_INTRA_ACTIVITY_WAITER_H -#define GRPC_CORE_LIB_PROMISE_INTRA_ACTIVITY_WAITER_H - -#include <grpc/support/port_platform.h> - -#include "src/core/lib/promise/activity.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -// Helper type to track wakeups between objects in the same activity. -// Can be fairly fast as no ref counting or locking needs to occur. -class IntraActivityWaiter { - public: - // Register for wakeup, return Pending(). If state is not ready to proceed, - // Promises should bottom out here. - Pending pending() { - waiting_ = true; - return Pending(); - } - // Wake the activity - void Wake() { - if (waiting_) { - waiting_ = false; - Activity::WakeupCurrent(); - } - } - - private: - bool waiting_ = false; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_INTRA_ACTIVITY_WAITER_H diff --git a/contrib/libs/grpc/src/core/lib/promise/join.h b/contrib/libs/grpc/src/core/lib/promise/join.h deleted file mode 100644 index 35331874ee..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/join.h +++ /dev/null @@ -1,55 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_JOIN_H -#define GRPC_CORE_LIB_PROMISE_JOIN_H - -#include <grpc/support/port_platform.h> - -#include "y_absl/meta/type_traits.h" - -#include "src/core/lib/promise/detail/basic_join.h" - -namespace grpc_core { -namespace promise_detail { - -struct JoinTraits { - template <typename T> - using ResultType = y_absl::remove_reference_t<T>; - template <typename T, typename F> - static auto OnResult(T result, F kontinue) - -> decltype(kontinue(std::move(result))) { - return kontinue(std::move(result)); - } - template <typename T> - static T Wrap(T x) { - return x; - } -}; - -template <typename... Promises> -using Join = BasicJoin<JoinTraits, Promises...>; - -} // namespace promise_detail - -/// Combinator to run all promises to completion, and return a tuple -/// of their results. -template <typename... Promise> -promise_detail::Join<Promise...> Join(Promise... promises) { - return promise_detail::Join<Promise...>(std::move(promises)...); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_JOIN_H diff --git a/contrib/libs/grpc/src/core/lib/promise/latch.h b/contrib/libs/grpc/src/core/lib/promise/latch.h deleted file mode 100644 index b97b186b40..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/latch.h +++ /dev/null @@ -1,104 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_LATCH_H -#define GRPC_CORE_LIB_PROMISE_LATCH_H - -#include <grpc/support/port_platform.h> - -#include <grpc/support/log.h> - -#include "src/core/lib/promise/activity.h" -#include "src/core/lib/promise/intra_activity_waiter.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -// Latch provides a single set waitable object. -// Initially the Latch is unset. -// It can be waited upon by the Wait method, which produces a Promise that -// resolves when the Latch is Set to a value of type T. -template <typename T> -class Latch { - public: - // This is the type of the promise returned by Wait. - class WaitPromise { - public: - Poll<T*> operator()() const { - if (latch_->has_value_) { - return &latch_->value_; - } else { - return latch_->waiter_.pending(); - } - } - - private: - friend class Latch; - explicit WaitPromise(Latch* latch) : latch_(latch) {} - Latch* latch_; - }; - - Latch() = default; - Latch(const Latch&) = delete; - Latch& operator=(const Latch&) = delete; - Latch(Latch&& other) noexcept - : value_(std::move(other.value_)), has_value_(other.has_value_) { -#ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); -#endif - } - Latch& operator=(Latch&& other) noexcept { -#ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); -#endif - value_ = std::move(other.value_); - has_value_ = other.has_value_; - return *this; - } - - // Produce a promise to wait for a value from this latch. - WaitPromise Wait() { -#ifndef NDEBUG - has_had_waiters_ = true; -#endif - return WaitPromise(this); - } - - // Set the value of the latch. Can only be called once. - void Set(T value) { - GPR_DEBUG_ASSERT(!has_value_); - value_ = std::move(value); - has_value_ = true; - waiter_.Wake(); - } - - private: - // The value stored (if has_value_ is true), otherwise some random value, we - // don't care. - // Why not y_absl::optional<>? Writing things this way lets us compress - // has_value_ with waiter_ and leads to some significant memory savings for - // some scenarios. - GPR_NO_UNIQUE_ADDRESS T value_; - // True if we have a value set, false otherwise. - bool has_value_ = false; -#ifndef NDEBUG - // Has this latch ever had waiters. - bool has_had_waiters_ = false; -#endif - IntraActivityWaiter waiter_; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_LATCH_H diff --git a/contrib/libs/grpc/src/core/lib/promise/observable.h b/contrib/libs/grpc/src/core/lib/promise/observable.h deleted file mode 100644 index d99dedb745..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/observable.h +++ /dev/null @@ -1,295 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_OBSERVABLE_H -#define GRPC_CORE_LIB_PROMISE_OBSERVABLE_H - -#include <grpc/support/port_platform.h> - -#include <stdint.h> - -#include <limits> -#include <memory> -#include <type_traits> - -#include "y_absl/base/thread_annotations.h" -#include "y_absl/synchronization/mutex.h" -#include "y_absl/types/optional.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/activity.h" -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/poll.h" -#include "src/core/lib/promise/wait_set.h" - -namespace grpc_core { - -namespace promise_detail { - -using ObservableVersion = uint64_t; -static constexpr ObservableVersion kTombstoneVersion = - std::numeric_limits<ObservableVersion>::max(); - -} // namespace promise_detail - -class WatchCommitter { - public: - void Commit() { version_seen_ = promise_detail::kTombstoneVersion; } - - protected: - promise_detail::ObservableVersion version_seen_ = 0; -}; - -namespace promise_detail { - -// Shared state between Observable and Observer. -template <typename T> -class ObservableState { - public: - explicit ObservableState(y_absl::optional<T> value) - : value_(std::move(value)) {} - - // Publish that we're closed. - void Close() { - mu_.Lock(); - version_ = kTombstoneVersion; - value_.reset(); - auto wakeup = waiters_.TakeWakeupSet(); - mu_.Unlock(); - wakeup.Wakeup(); - } - - // Synchronously publish a new value, and wake any waiters. - void Push(T value) { - mu_.Lock(); - version_++; - value_ = std::move(value); - auto wakeup = waiters_.TakeWakeupSet(); - mu_.Unlock(); - wakeup.Wakeup(); - } - - Poll<y_absl::optional<T>> PollGet(ObservableVersion* version_seen) { - y_absl::MutexLock lock(&mu_); - if (!Started()) return Pending(); - *version_seen = version_; - return value_; - } - - Poll<y_absl::optional<T>> PollNext(ObservableVersion* version_seen) { - y_absl::MutexLock lock(&mu_); - if (!NextValueReady(version_seen)) return Pending(); - return value_; - } - - Poll<y_absl::optional<T>> PollWatch(ObservableVersion* version_seen) { - if (*version_seen == kTombstoneVersion) return Pending(); - - y_absl::MutexLock lock(&mu_); - if (!NextValueReady(version_seen)) return Pending(); - // Watch needs to be woken up if the value changes even if it's ready now. - waiters_.AddPending(Activity::current()->MakeNonOwningWaker()); - return value_; - } - - private: - // Returns true if an initial value is set. - // If one is not set, add ourselves as pending to waiters_, and return false. - bool Started() Y_ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { - if (!value_.has_value()) { - if (version_ != kTombstoneVersion) { - // We allow initial no-value, which does not indicate closure. - waiters_.AddPending(Activity::current()->MakeNonOwningWaker()); - return false; - } - } - return true; - } - - // If no value is ready, add ourselves as pending to waiters_ and return - // false. - // If the next value is ready, update the last version seen and return true. - bool NextValueReady(ObservableVersion* version_seen) - Y_ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { - if (!Started()) return false; - if (version_ == *version_seen) { - waiters_.AddPending(Activity::current()->MakeNonOwningWaker()); - return false; - } - *version_seen = version_; - return true; - } - - y_absl::Mutex mu_; - WaitSet waiters_ Y_ABSL_GUARDED_BY(mu_); - ObservableVersion version_ Y_ABSL_GUARDED_BY(mu_) = 1; - y_absl::optional<T> value_ Y_ABSL_GUARDED_BY(mu_); -}; - -// Promise implementation for Observer::Get. -template <typename T> -class ObservableGet { - public: - ObservableGet(ObservableVersion* version_seen, ObservableState<T>* state) - : version_seen_(version_seen), state_(state) {} - - Poll<y_absl::optional<T>> operator()() { - return state_->PollGet(version_seen_); - } - - private: - ObservableVersion* version_seen_; - ObservableState<T>* state_; -}; - -// Promise implementation for Observer::Next. -template <typename T> -class ObservableNext { - public: - ObservableNext(ObservableVersion* version_seen, ObservableState<T>* state) - : version_seen_(version_seen), state_(state) {} - - Poll<y_absl::optional<T>> operator()() { - return state_->PollNext(version_seen_); - } - - private: - ObservableVersion* version_seen_; - ObservableState<T>* state_; -}; - -template <typename T, typename F> -class ObservableWatch final : private WatchCommitter { - private: - using Promise = PromiseLike<decltype( - std::declval<F>()(std::declval<T>(), std::declval<WatchCommitter*>()))>; - using Result = typename Promise::Result; - - public: - explicit ObservableWatch(F factory, std::shared_ptr<ObservableState<T>> state) - : state_(std::move(state)), factory_(std::move(factory)) {} - ObservableWatch(const ObservableWatch&) = delete; - ObservableWatch& operator=(const ObservableWatch&) = delete; - ObservableWatch(ObservableWatch&& other) noexcept - : state_(std::move(other.state_)), - promise_(std::move(other.promise_)), - factory_(std::move(other.factory_)) {} - ObservableWatch& operator=(ObservableWatch&&) noexcept = default; - - Poll<Result> operator()() { - auto r = state_->PollWatch(&version_seen_); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - if (p->has_value()) { - promise_ = Promise(factory_(std::move(**p), this)); - } else { - promise_ = {}; - } - } - if (promise_.has_value()) { - return (*promise_)(); - } else { - return Pending(); - } - } - - private: - std::shared_ptr<ObservableState<T>> state_; - y_absl::optional<Promise> promise_; - F factory_; -}; - -} // namespace promise_detail - -template <typename T> -class Observable; - -// Observer watches an Observable for updates. -// It can see either the latest value or wait for a new value, but is not -// guaranteed to see every value pushed to the Observable. -template <typename T> -class Observer { - public: - Observer(const Observer&) = delete; - Observer& operator=(const Observer&) = delete; - Observer(Observer&& other) noexcept - : version_seen_(other.version_seen_), state_(std::move(other.state_)) {} - Observer& operator=(Observer&& other) noexcept { - version_seen_ = other.version_seen_; - state_ = std::move(other.state_); - return *this; - } - - // Return a promise that will produce an optional<T>. - // If the Observable is still present, this will be a value T, but if the - // Observable has been closed, this will be nullopt. Borrows data from the - // Observer, so this value must stay valid until the promise is resolved. Only - // one Next, Get call is allowed to be outstanding at a time. - promise_detail::ObservableGet<T> Get() { - return promise_detail::ObservableGet<T>{&version_seen_, &*state_}; - } - - // Return a promise that will produce the next unseen value as an optional<T>. - // If the Observable is still present, this will be a value T, but if the - // Observable has been closed, this will be nullopt. Borrows data from the - // Observer, so this value must stay valid until the promise is resolved. Only - // one Next, Get call is allowed to be outstanding at a time. - promise_detail::ObservableNext<T> Next() { - return promise_detail::ObservableNext<T>{&version_seen_, &*state_}; - } - - private: - using State = promise_detail::ObservableState<T>; - friend class Observable<T>; - explicit Observer(std::shared_ptr<State> state) : state_(state) {} - promise_detail::ObservableVersion version_seen_ = 0; - std::shared_ptr<State> state_; -}; - -// Observable models a single writer multiple reader broadcast channel. -// Readers can observe the latest value, or await a new latest value, but they -// are not guaranteed to observe every value. -template <typename T> -class Observable { - public: - Observable() : state_(std::make_shared<State>(y_absl::nullopt)) {} - explicit Observable(T value) - : state_(std::make_shared<State>(std::move(value))) {} - ~Observable() { state_->Close(); } - Observable(const Observable&) = delete; - Observable& operator=(const Observable&) = delete; - - // Push a new value into the observable. - void Push(T value) { state_->Push(std::move(value)); } - - // Create a new Observer - which can pull the current state from this - // Observable. - Observer<T> MakeObserver() { return Observer<T>(state_); } - - // Create a new Watch - a promise that pushes state into the passed in promise - // factory. The promise factory takes two parameters - the current value and a - // commit token. If the commit token is used (the Commit function on it is - // called), then no further Watch updates are provided. - template <typename F> - promise_detail::ObservableWatch<T, F> Watch(F f) { - return promise_detail::ObservableWatch<T, F>(std::move(f), state_); - } - - private: - using State = promise_detail::ObservableState<T>; - std::shared_ptr<State> state_; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_OBSERVABLE_H diff --git a/contrib/libs/grpc/src/core/lib/promise/pipe.h b/contrib/libs/grpc/src/core/lib/promise/pipe.h deleted file mode 100644 index 2600ef49e5..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/pipe.h +++ /dev/null @@ -1,599 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_PIPE_H -#define GRPC_CORE_LIB_PROMISE_PIPE_H - -#include <grpc/support/port_platform.h> - -#include <assert.h> -#include <stddef.h> -#include <stdint.h> - -#include <new> -#include <type_traits> -#include <utility> - -#include "y_absl/container/inlined_vector.h" -#include "y_absl/status/status.h" -#include "y_absl/status/statusor.h" -#include "y_absl/types/optional.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/activity.h" -#include "src/core/lib/promise/detail/promise_factory.h" -#include "src/core/lib/promise/intra_activity_waiter.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -template <typename T> -struct Pipe; -template <typename T> -class PipeSender; -template <typename T> -class PipeReceiver; - -namespace pipe_detail { - -template <typename T> -class Push; -template <typename T> -class Next; - -template <class T> -class Promise { - public: - virtual Poll<bool> Step(T* output) = 0; - virtual void Stop() = 0; - - protected: - inline virtual ~Promise() = default; -}; - -struct alignas(alignof(void*)) Scratch { - uint8_t scratch[32]; -}; - -template <typename T> -class FilterInterface { - public: - FilterInterface() = default; - FilterInterface(const FilterInterface&) = delete; - FilterInterface& operator=(const FilterInterface&) = delete; - virtual Promise<T>* Step(T* p, Scratch* scratch_space) = 0; - virtual void UpdateReceiver(PipeReceiver<T>* receiver) = 0; - - protected: - inline virtual ~FilterInterface() {} - static void SetReceiverIndex(PipeReceiver<T>* receiver, int idx, - FilterInterface* p); - char AllocIndex(PipeReceiver<T>* receiver); -}; - -template <typename T, typename F> -class Filter; - -} // namespace pipe_detail - -// Send end of a Pipe. -template <typename T> -class PipeSender { - public: - PipeSender(const PipeSender&) = delete; - PipeSender& operator=(const PipeSender&) = delete; - - PipeSender(PipeSender&& other) noexcept - : receiver_(other.receiver_), push_(other.push_) { - if (receiver_ != nullptr) { - receiver_->sender_ = this; - other.receiver_ = nullptr; - } - if (push_ != nullptr) { - push_->sender_ = this; - other.push_ = nullptr; - } - } - PipeSender& operator=(PipeSender&& other) noexcept { - if (receiver_ != nullptr) { - receiver_->sender_ = nullptr; - } - if (push_ != nullptr) { - push_->sender_ = nullptr; - } - receiver_ = other.receiver_; - if (receiver_ != nullptr) { - receiver_->sender_ = this; - other.receiver_ = nullptr; - } - if (push_ != nullptr) { - push_->sender_ = this; - other.push_ = nullptr; - } - return *this; - } - - ~PipeSender() { - if (receiver_ != nullptr) { - receiver_->MarkClosed(); - } - if (push_ != nullptr) { - push_->sender_ = nullptr; - } - } - - // Send a single message along the pipe. - // Returns a promise that will resolve to a bool - true if the message was - // sent, false if it could never be sent. Blocks the promise until the - // receiver is either closed or able to receive another message. - pipe_detail::Push<T> Push(T value); - - // Attach a promise factory based filter to this pipe. - // The overall promise returned from this will be active until the pipe is - // closed. If this promise is cancelled before the pipe is closed, the pipe - // will close. The filter will be run _after_ any other registered filters. - template <typename F> - pipe_detail::Filter<T, F> Filter(F f); - - private: - friend struct Pipe<T>; - friend class PipeReceiver<T>; - friend class pipe_detail::Next<T>; - friend class pipe_detail::Push<T>; - explicit PipeSender(PipeReceiver<T>* receiver) : receiver_(receiver) {} - PipeReceiver<T>* receiver_; - pipe_detail::Push<T>* push_ = nullptr; -}; - -// Receive end of a Pipe. -template <typename T> -class PipeReceiver { - public: - PipeReceiver(const PipeReceiver&) = delete; - PipeReceiver& operator=(const PipeReceiver&) = delete; - - PipeReceiver(PipeReceiver&& other) noexcept - : sender_(other.sender_), - next_(other.next_), - filters_(std::move(other.filters_)), - pending_(std::move(other.pending_)), - waiting_to_send_(std::move(other.waiting_to_send_)), - waiting_to_receive_(other.waiting_to_receive_) { - if (sender_ != nullptr) { - sender_->receiver_ = this; - other.sender_ = nullptr; - } - if (next_ != nullptr) { - next_->receiver_ = this; - other.next_ = nullptr; - } - for (auto filter : filters_) { - filter->UpdateReceiver(this); - } - } - PipeReceiver& operator=(PipeReceiver&& other) noexcept { - if (sender_ != nullptr) { - sender_->receiver_ = nullptr; - } - if (next_ != nullptr) { - next_->receiver_ = nullptr; - } - sender_ = other.sender_; - next_ = other.next_; - filters_ = std::move(other.filters_); - for (auto filter : filters_) { - filter->UpdateReceiver(this); - } - pending_ = std::move(other.pending_); - waiting_to_send_ = std::move(other.waiting_to_send_); - waiting_to_receive_ = std::move(other.waiting_to_receive_); - if (sender_ != nullptr) { - sender_->receiver_ = this; - other.sender_ = nullptr; - } - if (next_ != nullptr) { - next_->receiver_ = this; - other.next_ = nullptr; - } - return *this; - } - ~PipeReceiver() { - MarkClosed(); - if (next_ != nullptr) { - next_->receiver_ = nullptr; - } - } - - // Receive a single message from the pipe. - // Returns a promise that will resolve to an optional<T> - with a value if a - // message was received, or no value if the other end of the pipe was closed. - // Blocks the promise until the receiver is either closed or a message is - // available. - pipe_detail::Next<T> Next(); - - // Attach a promise factory based filter to this pipe. - // The overall promise returned from this will be active until the pipe is - // closed. If this promise is cancelled before the pipe is closed, the pipe - // will close. The filter will be run _after_ any other registered filters. - template <typename F> - pipe_detail::Filter<T, F> Filter(F f); - - private: - friend struct Pipe<T>; - friend class PipeSender<T>; - friend class pipe_detail::Next<T>; - friend class pipe_detail::Push<T>; - friend class pipe_detail::FilterInterface<T>; - explicit PipeReceiver(PipeSender<T>* sender) : sender_(sender) {} - PipeSender<T>* sender_; - pipe_detail::Next<T>* next_ = nullptr; - y_absl::InlinedVector<pipe_detail::FilterInterface<T>*, 12> filters_; - y_absl::optional<T> pending_; - IntraActivityWaiter waiting_to_send_; - IntraActivityWaiter waiting_to_receive_; - - void MarkClosed() { - if (sender_ == nullptr) { - return; - } - - sender_->receiver_ = nullptr; - - waiting_to_receive_.Wake(); - waiting_to_send_.Wake(); - sender_ = nullptr; - - for (auto* filter : filters_) { - if (filter != nullptr) { - filter->UpdateReceiver(nullptr); - } - } - } -}; - -namespace pipe_detail { - -// Implementation of PipeSender::Push promise. -template <typename T> -class Push { - public: - Push(const Push&) = delete; - Push& operator=(const Push&) = delete; - Push(Push&& other) noexcept - : sender_(other.sender_), push_(std::move(other.push_)) { - if (sender_ != nullptr) { - sender_->push_ = this; - other.sender_ = nullptr; - } - } - Push& operator=(Push&& other) noexcept { - if (sender_ != nullptr) { - sender_->push_ = nullptr; - } - sender_ = other.sender_; - push_ = std::move(other.push_); - if (sender_ != nullptr) { - sender_->push_ = this; - other.sender_ = nullptr; - } - return *this; - } - - ~Push() { - if (sender_ != nullptr) { - assert(sender_->push_ == this); - sender_->push_ = nullptr; - } - } - - Poll<bool> operator()() { - auto* receiver = sender_->receiver_; - if (receiver == nullptr) { - return false; - } - if (receiver->pending_.has_value()) { - return receiver->waiting_to_send_.pending(); - } - receiver->pending_ = std::move(push_); - receiver->waiting_to_receive_.Wake(); - sender_->push_ = nullptr; - sender_ = nullptr; - return true; - } - - private: - friend class PipeSender<T>; - Push(PipeSender<T>* sender, T push) - : sender_(sender), push_(std::move(push)) { - assert(sender_->push_ == nullptr); - sender_->push_ = this; - } - PipeSender<T>* sender_; - T push_; -}; - -// Implementation of PipeReceiver::Next promise. -template <typename T> -class Next { - public: - Next(const Next&) = delete; - Next& operator=(const Next&) = delete; - Next(Next&& other) noexcept - : receiver_(other.receiver_), - next_filter_(other.next_filter_), - current_promise_(nullptr) { - assert(other.current_promise_ == nullptr); - if (receiver_ != nullptr) { - receiver_->next_ = this; - other.receiver_ = nullptr; - } - } - Next& operator=(Next&& other) noexcept { - assert(current_promise_ == nullptr); - assert(other.current_promise_ == nullptr); - if (receiver_ != nullptr) { - receiver_->next_ = nullptr; - } - receiver_ = other.receiver_; - next_filter_ = other.next_filter_; - if (receiver_ != nullptr) { - receiver_->next_ = this; - other.receiver_ = nullptr; - } - return *this; - } - - ~Next() { - if (receiver_ != nullptr) { - assert(receiver_->next_ == this); - receiver_->next_ = nullptr; - } - if (current_promise_ != nullptr) { - current_promise_->Stop(); - } - } - - Poll<y_absl::optional<T>> operator()() { - if (receiver_->pending_.has_value()) { - auto* pending = &*receiver_->pending_; - if (current_promise_ != nullptr) { - auto r = current_promise_->Step(pending); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - current_promise_->Stop(); - current_promise_ = nullptr; - if (!*p) { - receiver_->MarkClosed(); - return y_absl::optional<T>(); - } - } else { - return Pending(); - } - } - while (true) { - if (next_filter_ >= receiver_->filters_.size()) { - auto result = y_absl::optional<T>(std::move(*pending)); - receiver_->pending_.reset(); - receiver_->waiting_to_send_.Wake(); - receiver_->next_ = nullptr; - receiver_ = nullptr; - return result; - } - auto* filter = receiver_->filters_[next_filter_]; - current_promise_ = filter ? filter->Step(pending, &scratch_) : nullptr; - next_filter_++; - if (current_promise_ == - reinterpret_cast<Promise<T>*>(uintptr_t(false))) { - current_promise_ = nullptr; - receiver_->MarkClosed(); - return y_absl::optional<T>(); - } else if (current_promise_ == - reinterpret_cast<Promise<T>*>(uintptr_t(true))) { - current_promise_ = nullptr; - } else { - return Pending(); - } - } - } - if (receiver_->sender_ == nullptr) { - return y_absl::optional<T>(); - } - return receiver_->waiting_to_receive_.pending(); - } - - private: - friend class PipeReceiver<T>; - explicit Next(PipeReceiver<T>* receiver) : receiver_(receiver) { - assert(receiver_->next_ == nullptr); - receiver_->next_ = this; - } - PipeReceiver<T>* receiver_; - size_t next_filter_ = 0; - Promise<T>* current_promise_ = nullptr; - Scratch scratch_; -}; - -template <typename T, typename F> -class Filter final : private FilterInterface<T> { - public: - Filter(PipeReceiver<T>* receiver, F f) - : active_{receiver, promise_detail::PromiseFactory<T, F>(std::move(f))}, - index_(this->AllocIndex(receiver)){}; - explicit Filter(y_absl::Status already_finished) - : done_(std::move(already_finished)) {} - ~Filter() { - if (index_ != kTombstoneIndex) { - this->SetReceiverIndex(active_.receiver, index_, nullptr); - active_.~Active(); - } else { - done_.~Status(); - } - } - Filter(Filter&& other) noexcept : index_(other.index_) { - if (index_ != kTombstoneIndex) { - new (&active_) Active(std::move(other.active_)); - other.active_.~Active(); - new (&other.done_) y_absl::Status(y_absl::OkStatus()); - other.index_ = kTombstoneIndex; - this->SetReceiverIndex(active_.receiver, index_, this); - } else { - new (&done_) y_absl::Status(std::move(other.done_)); - } - } - - Filter(const Filter&) = delete; - Filter& operator=(const Filter&) = delete; - - Poll<y_absl::Status> operator()() { - if (index_ == kTombstoneIndex) { - return std::move(done_); - } - return Pending(); - } - - private: - static constexpr char kTombstoneIndex = -1; - struct Active { - GPR_NO_UNIQUE_ADDRESS PipeReceiver<T>* receiver; - GPR_NO_UNIQUE_ADDRESS promise_detail::PromiseFactory<T, F> factory; - }; - union { - GPR_NO_UNIQUE_ADDRESS Active active_; - GPR_NO_UNIQUE_ADDRESS y_absl::Status done_; - }; - GPR_NO_UNIQUE_ADDRESS char index_; - - class PromiseImpl final : public ::grpc_core::pipe_detail::Promise<T> { - using PF = typename promise_detail::PromiseFactory<T, F>::Promise; - - public: - PromiseImpl(PF f, Filter* filter) : f_(std::move(f)), filter_(filter) {} - - Poll<bool> Step(T* output) final { - auto r = f_(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - if (p->ok()) { - *output = std::move(**p); - return true; - } else { - filter_->SetReceiverIndex(filter_->active_.receiver, filter_->index_, - nullptr); - filter_->active_.~Active(); - filter_->index_ = kTombstoneIndex; - new (&filter_->done_) y_absl::Status(std::move(p->status())); - Activity::WakeupCurrent(); - return false; - } - } else { - return Pending(); - } - } - - void Stop() final { this->~PromiseImpl(); } - - private: - PF f_; - Filter* filter_; - }; - - Promise<T>* Step(T* p, Scratch* scratch) final { - if (index_ != kTombstoneIndex) { - PromiseImpl promise(active_.factory.Repeated(std::move(*p)), this); - auto r = promise.Step(p); - if (auto* result = y_absl::get_if<kPollReadyIdx>(&r)) { - return reinterpret_cast<Promise<T>*>(uintptr_t(*result)); - } - static_assert(sizeof(promise) <= sizeof(Scratch), - "scratch size too small"); - static_assert(alignof(decltype(promise)) <= alignof(Scratch), - "bad alignment"); - return new (scratch) decltype(promise)(std::move(promise)); - } else { - return nullptr; - } - } - - void UpdateReceiver(PipeReceiver<T>* receiver) final { - if (index_ != kTombstoneIndex) { - if (receiver == nullptr) { - active_.~Active(); - index_ = kTombstoneIndex; - new (&done_) y_absl::Status(y_absl::OkStatus()); - } else { - active_.receiver = receiver; - } - Activity::WakeupCurrent(); - } - } -}; - -template <typename T> -void FilterInterface<T>::SetReceiverIndex(PipeReceiver<T>* receiver, int idx, - FilterInterface* p) { - receiver->filters_[idx] = p; -} - -template <typename T> -char FilterInterface<T>::AllocIndex(PipeReceiver<T>* receiver) { - auto r = receiver->filters_.size(); - receiver->filters_.push_back(this); - return r; -} - -} // namespace pipe_detail - -template <typename T> -pipe_detail::Push<T> PipeSender<T>::Push(T value) { - return pipe_detail::Push<T>(this, std::move(value)); -} - -template <typename T> -pipe_detail::Next<T> PipeReceiver<T>::Next() { - return pipe_detail::Next<T>(this); -} - -template <typename T> -template <typename F> -pipe_detail::Filter<T, F> PipeSender<T>::Filter(F f) { - if (receiver_) { - return pipe_detail::Filter<T, F>(receiver_, std::move(f)); - } else { - return pipe_detail::Filter<T, F>(y_absl::OkStatus()); - } -} - -template <typename T> -template <typename F> -pipe_detail::Filter<T, F> PipeReceiver<T>::Filter(F f) { - return pipe_detail::Filter<T, F>(this, std::move(f)); -} - -// A Pipe is an intra-Activity communications channel that transmits T's from -// one end to the other. -// It is only safe to use a Pipe within the context of a single Activity. -// No synchronization is performed internally. -template <typename T> -struct Pipe { - Pipe() : sender(&receiver), receiver(&sender) {} - Pipe(const Pipe&) = delete; - Pipe& operator=(const Pipe&) = delete; - Pipe(Pipe&&) noexcept = default; - Pipe& operator=(Pipe&&) noexcept = default; - - PipeSender<T> sender; - PipeReceiver<T> receiver; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_PIPE_H diff --git a/contrib/libs/grpc/src/core/lib/promise/promise.h b/contrib/libs/grpc/src/core/lib/promise/promise.h deleted file mode 100644 index aba0150e91..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/promise.h +++ /dev/null @@ -1,90 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_PROMISE_H -#define GRPC_CORE_LIB_PROMISE_PROMISE_H - -#include <grpc/support/port_platform.h> - -#include <functional> -#include <type_traits> - -#include "y_absl/types/optional.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -// A Promise is any functor that takes no arguments and returns Poll<T>. -// Most of the time we just pass around the functor, but occasionally -// it pays to have a type erased variant, which we define here. -template <typename T> -using Promise = std::function<Poll<T>()>; - -// Helper to execute a promise immediately and return either the result or -// nothing. -template <typename Promise> -auto NowOrNever(Promise promise) - -> y_absl::optional<typename promise_detail::PromiseLike<Promise>::Result> { - auto r = promise_detail::PromiseLike<Promise>(std::move(promise))(); - if (auto* p = y_absl::get_if<kPollReadyIdx>(&r)) { - return std::move(*p); - } - return {}; -} - -// A promise that never completes. -template <typename T> -struct Never { - Poll<T> operator()() { return Pending(); } -}; - -namespace promise_detail { -// A promise that immediately completes. -template <typename T> -class Immediate { - public: - explicit Immediate(T value) : value_(std::move(value)) {} - - Poll<T> operator()() { return std::move(value_); } - - private: - T value_; -}; - -} // namespace promise_detail - -// Return \a value immediately -template <typename T> -promise_detail::Immediate<T> Immediate(T value) { - return promise_detail::Immediate<T>(std::move(value)); -} - -// Typecheck that a promise returns the expected return type. -// usage: auto promise = WithResult<int>([]() { return 3; }); -// NOTE: there are tests in promise_test.cc that are commented out because they -// should fail to compile. When modifying this code these should be uncommented -// and their miscompilation verified. -template <typename T, typename F> -auto WithResult(F f) -> - typename std::enable_if<std::is_same<decltype(f()), Poll<T>>::value, - F>::type { - return f; -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_PROMISE_H diff --git a/contrib/libs/grpc/src/core/lib/promise/try_join.h b/contrib/libs/grpc/src/core/lib/promise/try_join.h deleted file mode 100644 index 7070e49060..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/try_join.h +++ /dev/null @@ -1,83 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_TRY_JOIN_H -#define GRPC_CORE_LIB_PROMISE_TRY_JOIN_H - -#include <grpc/support/port_platform.h> - -#include <type_traits> - -#include "y_absl/meta/type_traits.h" -#include "y_absl/status/status.h" -#include "y_absl/status/statusor.h" - -#include "src/core/lib/promise/detail/basic_join.h" -#include "src/core/lib/promise/detail/status.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -namespace promise_detail { - -// Extract the T from a StatusOr<T> -template <typename T> -T IntoResult(y_absl::StatusOr<T>* status) { - return std::move(**status); -} - -// TryJoin returns a StatusOr<tuple<A,B,C>> for f()->Poll<StatusOr<A>>, -// g()->Poll<StatusOr<B>>, h()->Poll<StatusOr<C>>. If one of those should be a -// Status instead, we need a placeholder type to return, and this is it. -struct Empty {}; -inline Empty IntoResult(y_absl::Status*) { return Empty{}; } - -// Traits object to pass to BasicJoin -struct TryJoinTraits { - template <typename T> - using ResultType = - decltype(IntoResult(std::declval<y_absl::remove_reference_t<T>*>())); - template <typename T, typename F> - static auto OnResult(T result, F kontinue) - -> decltype(kontinue(IntoResult(&result))) { - using Result = - typename PollTraits<decltype(kontinue(IntoResult(&result)))>::Type; - if (!result.ok()) { - return Result(IntoStatus(&result)); - } - return kontinue(IntoResult(&result)); - } - template <typename T> - static y_absl::StatusOr<T> Wrap(T x) { - return y_absl::StatusOr<T>(std::move(x)); - } -}; - -// Implementation of TryJoin combinator. -template <typename... Promises> -using TryJoin = BasicJoin<TryJoinTraits, Promises...>; - -} // namespace promise_detail - -// Run all promises. -// If any fail, cancel the rest and return the failure. -// If all succeed, return Ok(tuple-of-results). -template <typename... Promises> -promise_detail::TryJoin<Promises...> TryJoin(Promises... promises) { - return promise_detail::TryJoin<Promises...>(std::move(promises)...); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_TRY_JOIN_H diff --git a/contrib/libs/grpc/src/core/lib/promise/try_seq.h b/contrib/libs/grpc/src/core/lib/promise/try_seq.h deleted file mode 100644 index 432a5b46ec..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/try_seq.h +++ /dev/null @@ -1,106 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_TRY_SEQ_H -#define GRPC_CORE_LIB_PROMISE_TRY_SEQ_H - -#include <grpc/support/port_platform.h> - -#include <tuple> -#include <utility> - -#include "y_absl/status/status.h" -#include "y_absl/status/statusor.h" -#include "y_absl/types/variant.h" - -#include "src/core/lib/promise/detail/basic_seq.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -namespace promise_detail { - -template <typename T> -struct TrySeqTraits { - using UnwrappedType = T; - using WrappedType = y_absl::StatusOr<T>; - template <typename Next> - static auto CallFactory(Next* next, T&& value) - -> decltype(next->Once(std::forward<T>(value))) { - return next->Once(std::forward<T>(value)); - } - template <typename Result, typename RunNext> - static Poll<Result> CheckResultAndRunNext(T prior, RunNext run_next) { - return run_next(std::move(prior)); - } -}; - -template <typename T> -struct TrySeqTraits<y_absl::StatusOr<T>> { - using UnwrappedType = T; - using WrappedType = y_absl::StatusOr<T>; - template <typename Next> - static auto CallFactory(Next* next, y_absl::StatusOr<T>&& status) - -> decltype(next->Once(std::move(*status))) { - return next->Once(std::move(*status)); - } - template <typename Result, typename RunNext> - static Poll<Result> CheckResultAndRunNext(y_absl::StatusOr<T> prior, - RunNext run_next) { - if (!prior.ok()) return Result(prior.status()); - return run_next(std::move(prior)); - } -}; -template <> -struct TrySeqTraits<y_absl::Status> { - using UnwrappedType = void; - using WrappedType = y_absl::Status; - template <typename Next> - static auto CallFactory(Next* next, y_absl::Status&&) - -> decltype(next->Once()) { - return next->Once(); - } - template <typename Result, typename RunNext> - static Poll<Result> CheckResultAndRunNext(y_absl::Status prior, - RunNext run_next) { - if (!prior.ok()) return Result(prior); - return run_next(std::move(prior)); - } -}; - -template <typename... Fs> -using TrySeq = BasicSeq<TrySeqTraits, Fs...>; - -} // namespace promise_detail - -// Try a sequence of operations. -// * Run the first functor as a promise. -// * Feed its success result into the second functor to create a promise, -// then run that. -// * ... -// * Feed the second-final success result into the final functor to create a -// promise, then run that, with the overall success result being that -// promises success result. -// If any step fails, fail everything. -// Functors can return StatusOr<> to signal that a value is fed forward, or -// Status to indicate only success/failure. In the case of returning Status, -// the construction functors take no arguments. -template <typename... Functors> -promise_detail::TrySeq<Functors...> TrySeq(Functors... functors) { - return promise_detail::TrySeq<Functors...>(std::move(functors)...); -} - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_TRY_SEQ_H diff --git a/contrib/libs/grpc/src/core/lib/promise/wait_set.h b/contrib/libs/grpc/src/core/lib/promise/wait_set.h deleted file mode 100644 index 5d0b3714bf..0000000000 --- a/contrib/libs/grpc/src/core/lib/promise/wait_set.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_PROMISE_WAIT_SET_H -#define GRPC_CORE_LIB_PROMISE_WAIT_SET_H - -#include <grpc/support/port_platform.h> - -#include <utility> - -#include "y_absl/container/flat_hash_set.h" - -#include "src/core/lib/promise/activity.h" -#include "src/core/lib/promise/poll.h" - -namespace grpc_core { - -// Helper type that can be used to enqueue many Activities waiting for some -// external state. -// Typically the external state should be guarded by mu_, and a call to -// WakeAllAndUnlock should be made when the state changes. -// Promises should bottom out polling inside pending(), which will register for -// wakeup and return Pending(). -// Queues handles to Activities, and not Activities themselves, meaning that if -// an Activity is destroyed prior to wakeup we end up holding only a small -// amount of memory (around 16 bytes + malloc overhead) until the next wakeup -// occurs. -class WaitSet final { - using WakerSet = y_absl::flat_hash_set<Waker>; - - public: - // Register for wakeup, return Pending(). If state is not ready to proceed, - // Promises should bottom out here. - Pending AddPending(Waker waker) { - pending_.emplace(std::move(waker)); - return Pending(); - } - - class WakeupSet { - public: - void Wakeup() { - while (!wakeup_.empty()) { - wakeup_.extract(wakeup_.begin()).value().Wakeup(); - } - } - - private: - friend class WaitSet; - explicit WakeupSet(WakerSet&& wakeup) - : wakeup_(std::forward<WakerSet>(wakeup)) {} - WakerSet wakeup_; - }; - - GRPC_MUST_USE_RESULT WakeupSet TakeWakeupSet() { - return WakeupSet(std::move(pending_)); - } - - private: - // Handles to activities that need to be awoken. - WakerSet pending_; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_PROMISE_WAIT_SET_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/cel_authorization_engine.h b/contrib/libs/grpc/src/core/lib/security/authorization/cel_authorization_engine.h deleted file mode 100644 index 53d27369b1..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/cel_authorization_engine.h +++ /dev/null @@ -1,85 +0,0 @@ - -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_CEL_AUTHORIZATION_ENGINE_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_CEL_AUTHORIZATION_ENGINE_H - -#include <grpc/support/port_platform.h> - -#include <map> -#include <memory> -#include <util/generic/string.h> -#include <vector> - -#include "y_absl/container/flat_hash_set.h" -#include "envoy/config/rbac/v3/rbac.upb.h" -#include "google/api/expr/v1alpha1/syntax.upb.h" -#include "upb/upb.hpp" - -#include <grpc/support/log.h> - -#include "src/core/lib/security/authorization/evaluate_args.h" -#include "src/core/lib/security/authorization/mock_cel/activation.h" - -namespace grpc_core { - -// CelAuthorizationEngine makes an AuthorizationDecision to ALLOW or DENY the -// current action based on the condition fields in provided RBAC policies. -// The engine may be constructed with one or two policies. If two polcies, -// the first policy is deny-if-matched and the second is allow-if-matched. -// The engine returns UNDECIDED decision if it fails to find a match in any -// policy. This engine ignores the principal and permission fields in RBAC -// policies. It is the caller's responsibility to provide RBAC policies that -// are compatible with this engine. -// -// Example: -// CelAuthorizationEngine* engine = -// CelAuthorizationEngine::CreateCelAuthorizationEngine(rbac_policies); -// engine->Evaluate(evaluate_args); // returns authorization decision. -class CelAuthorizationEngine { - public: - // rbac_policies must be a vector containing either a single policy of any - // kind, or one deny policy and one allow policy, in that order. - static std::unique_ptr<CelAuthorizationEngine> CreateCelAuthorizationEngine( - const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies); - - // Users should use the CreateCelAuthorizationEngine factory function - // instead of calling the CelAuthorizationEngine constructor directly. - explicit CelAuthorizationEngine( - const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies); - // TODO(mywang@google.com): add an Evaluate member function. - - private: - enum Action { - kAllow, - kDeny, - }; - - std::unique_ptr<mock_cel::Activation> CreateActivation( - const EvaluateArgs& args); - - std::map<const TString, const google_api_expr_v1alpha1_Expr*> - deny_if_matched_; - std::map<const TString, const google_api_expr_v1alpha1_Expr*> - allow_if_matched_; - upb::Arena arena_; - y_absl::flat_hash_set<TString> envoy_attributes_; - y_absl::flat_hash_set<TString> header_keys_; - std::unique_ptr<mock_cel::CelMap> headers_; -}; - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_SECURITY_AUTHORIZATION_CEL_AUTHORIZATION_ENGINE_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_engine.h b/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_engine.h deleted file mode 100644 index 0e958afcdb..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_engine.h +++ /dev/null @@ -1,60 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H - -#include <grpc/support/port_platform.h> - -#include "src/core/lib/security/authorization/authorization_engine.h" -#include "src/core/lib/security/authorization/matchers.h" -#include "src/core/lib/security/authorization/rbac_policy.h" - -namespace grpc_core { - -// GrpcAuthorizationEngine can be either an Allow engine or Deny engine. This -// engine makes authorization decisions to Allow or Deny incoming RPC request -// based on permission and principal configs in the provided RBAC policy and the -// engine type. This engine ignores condition field in RBAC config. It is the -// caller's responsibility to provide RBAC policies that are compatible with -// this engine. -class GrpcAuthorizationEngine : public AuthorizationEngine { - public: - // Builds GrpcAuthorizationEngine without any policies. - explicit GrpcAuthorizationEngine(Rbac::Action action) : action_(action) {} - // Builds GrpcAuthorizationEngine with allow/deny RBAC policy. - explicit GrpcAuthorizationEngine(Rbac policy); - - Rbac::Action action() { return action_; } - - // Required only for testing purpose. - size_t num_policies() { return policies_.size(); } - - // Evaluates incoming request against RBAC policy and makes a decision to - // whether allow/deny this request. - Decision Evaluate(const EvaluateArgs& args) const override; - - private: - struct Policy { - TString name; - std::unique_ptr<AuthorizationMatcher> matcher; - }; - - Rbac::Action action_; - std::vector<Policy> policies_; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_ENGINE_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h b/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h deleted file mode 100644 index bd521d66d6..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/grpc_authorization_policy_provider.h +++ /dev/null @@ -1,103 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_POLICY_PROVIDER_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_POLICY_PROVIDER_H - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "y_absl/status/statusor.h" - -#include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/gprpp/thd.h" -#include "src/core/lib/security/authorization/authorization_policy_provider.h" -#include "src/core/lib/security/authorization/rbac_translator.h" - -namespace grpc_core { - -// Provider class will get SDK Authorization policy from string during -// initialization. This policy will be translated to Envoy RBAC policies and -// used to initialize allow and deny AuthorizationEngine objects. This provider -// will return the same authorization engines everytime. -class StaticDataAuthorizationPolicyProvider - : public grpc_authorization_policy_provider { - public: - static y_absl::StatusOr<RefCountedPtr<grpc_authorization_policy_provider>> - Create(y_absl::string_view authz_policy); - - // Use factory method "Create" to create an instance of - // StaticDataAuthorizationPolicyProvider. - explicit StaticDataAuthorizationPolicyProvider(RbacPolicies policies); - - AuthorizationEngines engines() override { - return {allow_engine_, deny_engine_}; - } - - void Orphan() override {} - - private: - RefCountedPtr<AuthorizationEngine> allow_engine_; - RefCountedPtr<AuthorizationEngine> deny_engine_; -}; - -// Provider class will get SDK Authorization policy from provided file path. -// This policy will be translated to Envoy RBAC policies and used to initialize -// allow and deny AuthorizationEngine objects. This provider will periodically -// load file contents in specified path, and upon modification update the engine -// instances with new policy configuration. During reload if the file contents -// are invalid or there are I/O errors, we will skip that particular update and -// log error status. The authorization decisions will be made using the latest -// valid policy. -class FileWatcherAuthorizationPolicyProvider - : public grpc_authorization_policy_provider { - public: - static y_absl::StatusOr<RefCountedPtr<grpc_authorization_policy_provider>> - Create(y_absl::string_view authz_policy_path, - unsigned int refresh_interval_sec); - - // Use factory method "Create" to create an instance of - // FileWatcherAuthorizationPolicyProvider. - FileWatcherAuthorizationPolicyProvider(y_absl::string_view authz_policy_path, - unsigned int refresh_interval_sec, - y_absl::Status* status); - - void Orphan() override; - - AuthorizationEngines engines() override { - MutexLock lock(&mu_); - return {allow_engine_, deny_engine_}; - } - - private: - // Force an update from the file system regardless of the interval. - y_absl::Status ForceUpdate(); - - TString authz_policy_path_; - TString file_contents_; - unsigned int refresh_interval_sec_; - - std::unique_ptr<Thread> refresh_thread_; - gpr_event shutdown_event_; - - Mutex mu_; - // Engines created using authz_policy_. - RefCountedPtr<AuthorizationEngine> allow_engine_ Y_ABSL_GUARDED_BY(mu_); - RefCountedPtr<AuthorizationEngine> deny_engine_ Y_ABSL_GUARDED_BY(mu_); -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_GRPC_AUTHORIZATION_POLICY_PROVIDER_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/matchers.h b/contrib/libs/grpc/src/core/lib/security/authorization/matchers.h deleted file mode 100644 index 95ebd51583..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/matchers.h +++ /dev/null @@ -1,197 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MATCHERS_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MATCHERS_H - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "src/core/lib/matchers/matchers.h" -#include "src/core/lib/security/authorization/evaluate_args.h" -#include "src/core/lib/security/authorization/rbac_policy.h" - -namespace grpc_core { - -// Describes the rules for matching permission or principal. -class AuthorizationMatcher { - public: - virtual ~AuthorizationMatcher() = default; - - // Returns whether or not the permission/principal matches the rules of the - // matcher. - virtual bool Matches(const EvaluateArgs& args) const = 0; - - // Creates an instance of a matcher based off the rules defined in Permission - // config. - static std::unique_ptr<AuthorizationMatcher> Create( - Rbac::Permission permission); - - // Creates an instance of a matcher based off the rules defined in Principal - // config. - static std::unique_ptr<AuthorizationMatcher> Create( - Rbac::Principal principal); -}; - -class AlwaysAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit AlwaysAuthorizationMatcher() = default; - - bool Matches(const EvaluateArgs&) const override { return true; } -}; - -class AndAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit AndAuthorizationMatcher( - std::vector<std::unique_ptr<AuthorizationMatcher>> matchers) - : matchers_(std::move(matchers)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - std::vector<std::unique_ptr<AuthorizationMatcher>> matchers_; -}; - -class OrAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit OrAuthorizationMatcher( - std::vector<std::unique_ptr<AuthorizationMatcher>> matchers) - : matchers_(std::move(matchers)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - std::vector<std::unique_ptr<AuthorizationMatcher>> matchers_; -}; - -// Negates matching the provided permission/principal. -class NotAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit NotAuthorizationMatcher( - std::unique_ptr<AuthorizationMatcher> matcher) - : matcher_(std::move(matcher)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - std::unique_ptr<AuthorizationMatcher> matcher_; -}; - -// TODO(ashithasantosh): Add matcher implementation for metadata field. - -// Perform a match against HTTP headers. -class HeaderAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit HeaderAuthorizationMatcher(HeaderMatcher matcher) - : matcher_(std::move(matcher)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - const HeaderMatcher matcher_; -}; - -// Perform a match against IP Cidr Range. -class IpAuthorizationMatcher : public AuthorizationMatcher { - public: - enum class Type { - kDestIp, - kSourceIp, - kDirectRemoteIp, - kRemoteIp, - }; - - IpAuthorizationMatcher(Type type, Rbac::CidrRange range); - - bool Matches(const EvaluateArgs& args) const override; - - private: - const Type type_; - // Subnet masked address. - grpc_resolved_address subnet_address_; - const uint32_t prefix_len_; -}; - -// Perform a match against port number of the destination (local) address. -class PortAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit PortAuthorizationMatcher(int port) : port_(port) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - const int port_; -}; - -// Matches the principal name as described in the peer certificate. Uses URI SAN -// or DNS SAN in that order, otherwise uses subject field. -class AuthenticatedAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit AuthenticatedAuthorizationMatcher(StringMatcher auth) - : matcher_(std::move(auth)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - const StringMatcher matcher_; -}; - -// Perform a match against the request server from the client's connection -// request. This is typically TLS SNI. Currently unsupported. -class ReqServerNameAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit ReqServerNameAuthorizationMatcher( - StringMatcher requested_server_name) - : matcher_(std::move(requested_server_name)) {} - - bool Matches(const EvaluateArgs&) const override; - - private: - const StringMatcher matcher_; -}; - -// Perform a match against the path header of HTTP request. -class PathAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit PathAuthorizationMatcher(StringMatcher path) - : matcher_(std::move(path)) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - const StringMatcher matcher_; -}; - -// Performs a match for policy field in RBAC, which is a collection of -// permission and principal matchers. Policy matches iff, we find a match in one -// of its permissions and a match in one of its principals. -class PolicyAuthorizationMatcher : public AuthorizationMatcher { - public: - explicit PolicyAuthorizationMatcher(Rbac::Policy policy) - : permissions_( - AuthorizationMatcher::Create(std::move(policy.permissions))), - principals_( - AuthorizationMatcher::Create(std::move(policy.principals))) {} - - bool Matches(const EvaluateArgs& args) const override; - - private: - std::unique_ptr<AuthorizationMatcher> permissions_; - std::unique_ptr<AuthorizationMatcher> principals_; -}; - -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MATCHERS_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h deleted file mode 100644 index 05f00a5048..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/activation.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H - -#include <grpc/support/port_platform.h> - -#include "y_absl/strings/string_view.h" - -#include "src/core/lib/security/authorization/mock_cel/cel_value.h" - -namespace grpc_core { -namespace mock_cel { - -// Base class for an activation. This is a temporary stub implementation of CEL -// APIs. Once gRPC imports the CEL library, this class will be removed. -class BaseActivation { - public: - BaseActivation() = default; - - // Non-copyable/non-assignable - BaseActivation(const BaseActivation&) = delete; - BaseActivation& operator=(const BaseActivation&) = delete; -}; - -// Instance of Activation class is used by evaluator. -// It provides binding between references used in expressions -// and actual values. This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this class will be removed. -class Activation : public BaseActivation { - public: - Activation() = default; - - // Non-copyable/non-assignable - Activation(const Activation&) = delete; - Activation& operator=(const Activation&) = delete; - - // Insert value into Activation. - void InsertValue(y_absl::string_view /*name*/, const CelValue& /*value*/) {} -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_ACTIVATION_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h deleted file mode 100644 index 630b0bc0d2..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "y_absl/memory/memory.h" - -#include "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h" - -namespace grpc_core { -namespace mock_cel { - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this file will be removed. - -struct InterpreterOptions { - bool short_circuiting = true; -}; - -inline std::unique_ptr<CelExpressionBuilder> CreateCelExpressionBuilder( - const InterpreterOptions& options) { - return y_absl::make_unique<FlatExprBuilder>(); -} - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H
\ No newline at end of file diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h deleted file mode 100644 index 2b4c3666e7..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_expression.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H - -#include <grpc/support/port_platform.h> - -#include <memory> -#include <vector> - -#include "y_absl/status/statusor.h" -#include "google/api/expr/v1alpha1/syntax.upb.h" - -#include "src/core/lib/security/authorization/mock_cel/activation.h" -#include "src/core/lib/security/authorization/mock_cel/cel_value.h" - -namespace grpc_core { -namespace mock_cel { - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this file will be removed. - -// Base interface for expression evaluating objects. -class CelExpression { - public: - virtual ~CelExpression() = default; - - // Evaluates expression and returns value. - // activation contains bindings from parameter names to values - virtual y_absl::StatusOr<CelValue> Evaluate( - const BaseActivation& activation) const = 0; -}; - -// Base class for Expression Builder implementations -// Provides user with factory to register extension functions. -// ExpressionBuilder MUST NOT be destroyed before CelExpression objects -// it built. -class CelExpressionBuilder { - public: - virtual ~CelExpressionBuilder() = default; - - // Creates CelExpression object from AST tree. - // expr specifies root of AST tree - virtual y_absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression( - const google_api_expr_v1alpha1_Expr* expr, - const google_api_expr_v1alpha1_SourceInfo* source_info) const = 0; - - virtual y_absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression( - const google_api_expr_v1alpha1_Expr* expr, - const google_api_expr_v1alpha1_SourceInfo* source_info, - std::vector<y_absl::Status>* warnings) const = 0; -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H
\ No newline at end of file diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h deleted file mode 100644 index ccb4ffeab0..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/cel_value.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H - -// CelValue is a holder, capable of storing all kinds of data -// supported by CEL. -// CelValue defines explicitly typed/named getters/setters. -// When storing pointers to objects, CelValue does not accept ownership -// to them and does not control their lifecycle. Instead objects are expected -// to be either external to expression evaluation, and controlled beyond the -// scope or to be allocated and associated with some allocation/ownership -// controller (Arena). -// Usage examples: -// (a) For primitive types: -// CelValue value = CelValue::CreateInt64(1); -// (b) For string: -// TString* msg("test"); -// CelValue value = CelValue::CreateString(msg); - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "y_absl/memory/memory.h" -#include "y_absl/strings/string_view.h" -#include "y_absl/types/span.h" - -namespace grpc_core { -namespace mock_cel { - -// Break cyclic depdendencies for container types. -class CelMap { - public: - CelMap() = default; -}; - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this class will be removed. -class CelValue { - public: - // Default constructor. - // Creates CelValue with null data type. - CelValue() : CelValue(nullptr) {} - - // We will use factory methods instead of public constructors - // The reason for this is the high risk of implicit type conversions - // between bool/int/pointer types. - // We rely on copy elision to avoid extra copying. - static CelValue CreateNull() { return CelValue(nullptr); } - - static CelValue CreateInt64(int64_t /*value*/) { return CreateNull(); } - - static CelValue CreateUint64(uint64_t /*value*/) { return CreateNull(); } - - static CelValue CreateStringView(y_absl::string_view /*value*/) { - return CreateNull(); - } - - static CelValue CreateString(const TString* /*str*/) { - return CreateNull(); - } - - static CelValue CreateMap(const CelMap* /*value*/) { return CreateNull(); } - - private: - // Constructs CelValue wrapping value supplied as argument. - // Value type T should be supported by specification of ValueHolder. - template <class T> - explicit CelValue(T /*value*/) {} -}; - -// CelMap implementation that uses STL map container as backing storage. -class ContainerBackedMapImpl : public CelMap { - public: - ContainerBackedMapImpl() = default; - - static std::unique_ptr<CelMap> Create( - y_absl::Span<std::pair<CelValue, CelValue>> /*key_values*/) { - return y_absl::make_unique<ContainerBackedMapImpl>(); - } -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_VALUE_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h deleted file mode 100644 index e6d4aea743..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/evaluator_core.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H - -#include <grpc/support/port_platform.h> - -#include <memory> -#include <set> -#include <vector> - -#include "y_absl/status/statusor.h" -#include "google/api/expr/v1alpha1/syntax.upb.h" - -#include "src/core/lib/security/authorization/mock_cel/activation.h" -#include "src/core/lib/security/authorization/mock_cel/cel_expression.h" -#include "src/core/lib/security/authorization/mock_cel/cel_value.h" - -namespace grpc_core { -namespace mock_cel { - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this file will be removed. - -class ExecutionPath { - public: - ExecutionPath() = default; -}; - -// Implementation of the CelExpression that utilizes flattening -// of the expression tree. -class CelExpressionFlatImpl : public CelExpression { - // Constructs CelExpressionFlatImpl instance. - // path is flat execution path that is based upon - // flattened AST tree. Max iterations dictates the maximum number of - // iterations in the comprehension expressions (use 0 to disable the upper - // bound). - public: - CelExpressionFlatImpl(const google_api_expr_v1alpha1_Expr* root_expr, - ExecutionPath path, int max_iterations, - std::set<TString> iter_variable_names, - bool enable_unknowns = false, - bool enable_unknown_function_results = false) {} - - // Implementation of CelExpression evaluate method. - y_absl::StatusOr<CelValue> Evaluate( - const BaseActivation& activation) const override { - return CelValue::CreateNull(); - } -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H
\ No newline at end of file diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h b/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h deleted file mode 100644 index c4f4568fd0..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2020 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_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "src/core/lib/security/authorization/mock_cel/evaluator_core.h" - -namespace grpc_core { -namespace mock_cel { - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this file will be removed. - -// CelExpressionBuilder implementation. -// Builds instances of CelExpressionFlatImpl. -class FlatExprBuilder : public CelExpressionBuilder { - public: - FlatExprBuilder() = default; - - y_absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression( - const google_api_expr_v1alpha1_Expr* expr, - const google_api_expr_v1alpha1_SourceInfo* source_info) const override { - ExecutionPath path; - return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0, - std::set<TString>{}); - } - - y_absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression( - const google_api_expr_v1alpha1_Expr* expr, - const google_api_expr_v1alpha1_SourceInfo* source_info, - std::vector<y_absl::Status>* warnings) const override { - ExecutionPath path; - return y_absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0, - std::set<TString>{}); - } -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/rbac_policy.h b/contrib/libs/grpc/src/core/lib/security/authorization/rbac_policy.h deleted file mode 100644 index eb691b0ec9..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/rbac_policy.h +++ /dev/null @@ -1,163 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_POLICY_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_POLICY_H - -#include <grpc/support/port_platform.h> - -#include <memory> - -#include "src/core/lib/matchers/matchers.h" - -namespace grpc_core { - -// Represents Envoy RBAC Proto. [See -// https://github.com/envoyproxy/envoy/blob/release/v1.17/api/envoy/config/rbac/v3/rbac.proto] -struct Rbac { - enum class Action { - kAllow, - kDeny, - }; - - struct CidrRange { - CidrRange() = default; - CidrRange(TString address_prefix, uint32_t prefix_len); - - CidrRange(CidrRange&& other) noexcept; - CidrRange& operator=(CidrRange&& other) noexcept; - - TString ToString() const; - - TString address_prefix; - uint32_t prefix_len; - }; - - // TODO(ashithasantosh): Add metadata field to Permission and Principal. - struct Permission { - enum class RuleType { - kAnd, - kOr, - kNot, - kAny, - kHeader, - kPath, - kDestIp, - kDestPort, - kReqServerName, - }; - - Permission() = default; - // For kAnd/kOr RuleType. - Permission(Permission::RuleType type, - std::vector<std::unique_ptr<Permission>> permissions); - // For kNot RuleType. - Permission(Permission::RuleType type, Permission permission); - // For kAny RuleType. - explicit Permission(Permission::RuleType type); - // For kHeader RuleType. - Permission(Permission::RuleType type, HeaderMatcher header_matcher); - // For kPath/kReqServerName RuleType. - Permission(Permission::RuleType type, StringMatcher string_matcher); - // For kDestIp RuleType. - Permission(Permission::RuleType type, CidrRange ip); - // For kDestPort RuleType. - Permission(Permission::RuleType type, int port); - - Permission(Permission&& other) noexcept; - Permission& operator=(Permission&& other) noexcept; - - TString ToString() const; - - RuleType type; - HeaderMatcher header_matcher; - StringMatcher string_matcher; - CidrRange ip; - int port; - // For type kAnd/kOr/kNot. For kNot type, the vector will have only one - // element. - std::vector<std::unique_ptr<Permission>> permissions; - }; - - struct Principal { - enum class RuleType { - kAnd, - kOr, - kNot, - kAny, - kPrincipalName, - kSourceIp, - kDirectRemoteIp, - kRemoteIp, - kHeader, - kPath, - }; - - Principal() = default; - // For kAnd/kOr RuleType. - Principal(Principal::RuleType type, - std::vector<std::unique_ptr<Principal>> principals); - // For kNot RuleType. - Principal(Principal::RuleType type, Principal principal); - // For kAny RuleType. - explicit Principal(Principal::RuleType type); - // For kPrincipalName/kPath RuleType. - Principal(Principal::RuleType type, StringMatcher string_matcher); - // For kSourceIp/kDirectRemoteIp/kRemoteIp RuleType. - Principal(Principal::RuleType type, CidrRange ip); - // For kHeader RuleType. - Principal(Principal::RuleType type, HeaderMatcher header_matcher); - - Principal(Principal&& other) noexcept; - Principal& operator=(Principal&& other) noexcept; - - TString ToString() const; - - RuleType type; - HeaderMatcher header_matcher; - StringMatcher string_matcher; - CidrRange ip; - // For type kAnd/kOr/kNot. For kNot type, the vector will have only one - // element. - std::vector<std::unique_ptr<Principal>> principals; - }; - - struct Policy { - Policy() = default; - Policy(Permission permissions, Principal principals); - - Policy(Policy&& other) noexcept; - Policy& operator=(Policy&& other) noexcept; - - TString ToString() const; - - Permission permissions; - Principal principals; - }; - - Rbac() = default; - Rbac(Rbac::Action action, std::map<TString, Policy> policies); - - Rbac(Rbac&& other) noexcept; - Rbac& operator=(Rbac&& other) noexcept; - - TString ToString() const; - - Action action; - std::map<TString, Policy> policies; -}; - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_POLICY_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/authorization/rbac_translator.h b/contrib/libs/grpc/src/core/lib/security/authorization/rbac_translator.h deleted file mode 100644 index ab687859ab..0000000000 --- a/contrib/libs/grpc/src/core/lib/security/authorization/rbac_translator.h +++ /dev/null @@ -1,40 +0,0 @@ -// 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_TRANSLATOR_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_TRANSLATOR_H - -#include <grpc/support/port_platform.h> - -#include "y_absl/status/statusor.h" - -#include "src/core/lib/json/json.h" -#include "src/core/lib/security/authorization/rbac_policy.h" - -namespace grpc_core { - -struct RbacPolicies { - Rbac deny_policy; - Rbac allow_policy; -}; - -// Translates SDK authorization policy to Envoy RBAC policies. Returns error on -// failure. -// authz_policy: Authorization Policy string in JSON format. -y_absl::StatusOr<RbacPolicies> GenerateRbacPolicies( - y_absl::string_view authz_policy); - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_SECURITY_AUTHORIZATION_RBAC_TRANSLATOR_H */ diff --git a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/altscontext.proto b/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/altscontext.proto deleted file mode 100644 index 9a1dad5f56..0000000000 --- a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/altscontext.proto +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -import "transport_security_common.proto"; - -package grpc.gcp; - -option java_package = "io.grpc.alts.internal"; - -message AltsContext { - // The application protocol negotiated for this connection. - string application_protocol = 1; - - // The record protocol negotiated for this connection. - string record_protocol = 2; - - // The security level of the created secure channel. - SecurityLevel security_level = 3; - - // The peer service account. - string peer_service_account = 4; - - // The local service account. - string local_service_account = 5; - - // The RPC protocol versions supported by the peer. - RpcProtocolVersions peer_rpc_versions = 6; -} diff --git a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/handshaker.proto b/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/handshaker.proto deleted file mode 100644 index 84a4153b70..0000000000 --- a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/handshaker.proto +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -import "transport_security_common.proto"; - -package grpc.gcp; - -option java_package = "io.grpc.alts.internal"; - -enum HandshakeProtocol { - // Default value. - HANDSHAKE_PROTOCOL_UNSPECIFIED = 0; - - // TLS handshake protocol. - TLS = 1; - - // Application Layer Transport Security handshake protocol. - ALTS = 2; -} - -enum NetworkProtocol { - NETWORK_PROTOCOL_UNSPECIFIED = 0; - TCP = 1; - UDP = 2; -} - -message Endpoint { - // IP address. It should contain an IPv4 or IPv6 string literal, e.g. - // "192.168.0.1" or "2001:db8::1". - string ip_address = 1; - - // Port number. - int32 port = 2; - - // Network protocol (e.g., TCP, UDP) associated with this endpoint. - NetworkProtocol protocol = 3; -} - -message Identity { - oneof identity_oneof { - // Service account of a connection endpoint. - string service_account = 1; - - // Hostname of a connection endpoint. - string hostname = 2; - } -} - -message StartClientHandshakeReq { - // Handshake security protocol requested by the client. - HandshakeProtocol handshake_security_protocol = 1; - - // The application protocols supported by the client, e.g., "h2" (for http2), - // "grpc". - repeated string application_protocols = 2; - - // The record protocols supported by the client, e.g., - // "ALTSRP_GCM_AES128". - repeated string record_protocols = 3; - - // (Optional) Describes which server identities are acceptable by the client. - // If target identities are provided and none of them matches the peer - // identity of the server, handshake will fail. - repeated Identity target_identities = 4; - - // (Optional) Application may specify a local identity. Otherwise, the - // handshaker chooses a default local identity. - Identity local_identity = 5; - - // (Optional) Local endpoint information of the connection to the server, - // such as local IP address, port number, and network protocol. - Endpoint local_endpoint = 6; - - // (Optional) Endpoint information of the remote server, such as IP address, - // port number, and network protocol. - Endpoint remote_endpoint = 7; - - // (Optional) If target name is provided, a secure naming check is performed - // to verify that the peer authenticated identity is indeed authorized to run - // the target name. - string target_name = 8; - - // (Optional) RPC protocol versions supported by the client. - RpcProtocolVersions rpc_versions = 9; -} - -message ServerHandshakeParameters { - // The record protocols supported by the server, e.g., - // "ALTSRP_GCM_AES128". - repeated string record_protocols = 1; - - // (Optional) A list of local identities supported by the server, if - // specified. Otherwise, the handshaker chooses a default local identity. - repeated Identity local_identities = 2; -} - -message StartServerHandshakeReq { - // The application protocols supported by the server, e.g., "h2" (for http2), - // "grpc". - repeated string application_protocols = 1; - - // Handshake parameters (record protocols and local identities supported by - // the server) mapped by the handshake protocol. Each handshake security - // protocol (e.g., TLS or ALTS) has its own set of record protocols and local - // identities. Since protobuf does not support enum as key to the map, the key - // to handshake_parameters is the integer value of HandshakeProtocol enum. - map<int32, ServerHandshakeParameters> handshake_parameters = 2; - - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple HandshakReq messages. - bytes in_bytes = 3; - - // (Optional) Local endpoint information of the connection to the client, - // such as local IP address, port number, and network protocol. - Endpoint local_endpoint = 4; - - // (Optional) Endpoint information of the remote client, such as IP address, - // port number, and network protocol. - Endpoint remote_endpoint = 5; - - // (Optional) RPC protocol versions supported by the server. - RpcProtocolVersions rpc_versions = 6; -} - -message NextHandshakeMessageReq { - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple NextHandshakerMessageReq - // messages. - bytes in_bytes = 1; -} - -message HandshakerReq { - oneof req_oneof { - // The start client handshake request message. - StartClientHandshakeReq client_start = 1; - - // The start server handshake request message. - StartServerHandshakeReq server_start = 2; - - // The next handshake request message. - NextHandshakeMessageReq next = 3; - } -} - -message HandshakerResult { - // The application protocol negotiated for this connection. - string application_protocol = 1; - - // The record protocol negotiated for this connection. - string record_protocol = 2; - - // Cryptographic key data. The key data may be more than the key length - // required for the record protocol, thus the client of the handshaker - // service needs to truncate the key data into the right key length. - bytes key_data = 3; - - // The authenticated identity of the peer. - Identity peer_identity = 4; - - // The local identity used in the handshake. - Identity local_identity = 5; - - // Indicate whether the handshaker service client should keep the channel - // between the handshaker service open, e.g., in order to handle - // post-handshake messages in the future. - bool keep_channel_open = 6; - - // The RPC protocol versions supported by the peer. - RpcProtocolVersions peer_rpc_versions = 7; -} - -message HandshakerStatus { - // The status code. This could be the gRPC status code. - uint32 code = 1; - - // The status details. - string details = 2; -} - -message HandshakerResp { - // Frames to be given to the peer for the NextHandshakeMessageReq. May be - // empty if no out_frames have to be sent to the peer or if in_bytes in the - // HandshakerReq are incomplete. All the non-empty out frames must be sent to - // the peer even if the handshaker status is not OK as these frames may - // contain the alert frames. - bytes out_frames = 1; - - // Number of bytes in the in_bytes consumed by the handshaker. It is possible - // that part of in_bytes in HandshakerReq was unrelated to the handshake - // process. - uint32 bytes_consumed = 2; - - // This is set iff the handshake was successful. out_frames may still be set - // to frames that needs to be forwarded to the peer. - HandshakerResult result = 3; - - // Status of the handshaker. - HandshakerStatus status = 4; -} - -service HandshakerService { - // Handshaker service accepts a stream of handshaker request, returning a - // stream of handshaker response. Client is expected to send exactly one - // message with either client_start or server_start followed by one or more - // messages with next. Each time client sends a request, the handshaker - // service expects to respond. Client does not have to wait for service's - // response before sending next request. - rpc DoHandshake(stream HandshakerReq) - returns (stream HandshakerResp) { - } -} diff --git a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/transport_security_common.proto b/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/transport_security_common.proto deleted file mode 100644 index d0f861e644..0000000000 --- a/contrib/libs/grpc/src/core/tsi/alts/handshaker/proto/transport_security_common.proto +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package grpc.gcp; - -option java_package = "io.grpc.alts.internal"; - -// The security level of the created channel. The list is sorted in increasing -// level of security. This order must always be maintained. -enum SecurityLevel { - SECURITY_NONE = 0; - INTEGRITY_ONLY = 1; - INTEGRITY_AND_PRIVACY = 2; -} - -// Max and min supported RPC protocol versions. -message RpcProtocolVersions { - // RPC version contains a major version and a minor version. - message Version { - uint32 major = 1; - uint32 minor = 2; - } - // Maximum supported RPC version. - Version max_rpc_version = 1; - // Minimum supported RPC version. - Version min_rpc_version = 2; -} diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/BUILD b/contrib/libs/grpc/src/core/tsi/test_creds/BUILD deleted file mode 100644 index 1ff24718ec..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/BUILD +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) - -exports_files([ - "ca.pem", - "server1.key", - "server1.pem", - "server0.key", - "server0.pem", - "client.key", - "client.pem", - "badserver.key", - "badserver.pem", - "badclient.key", - "badclient.pem", - "multi-domain.key", - "multi-domain.pem", -]) diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/badclient.key b/contrib/libs/grpc/src/core/tsi/test_creds/badclient.key deleted file mode 100644 index 6cd102b830..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/badclient.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDvdzKDTYvRgjBO -UOrzDwkAZGwNFHHlMYyMGI5tItj3tCzXkbpM0uz3ZjHVahu+eYc+KvYApM64F2dB -b16hs713FCk8mihYABjnSndrQsl/U2v8YFT7DipfLReqqaOGu2o9HdvWfiUlaiC/ -UGGfR+YblpK7CG+7/hvTXtUsMw+OppoeH9z87rhOJMxtiC7XwU5rhEmab/1f1XM/ -nLoZrfDAcTbDywoeu826SJ3mifajq7oK3LDdNLjWZwfEsCO1qp2C4gLvBlOOKsWO -LNby6ByxCOPlCTa0UCaVuoNclYol71jyi17KW+Nk0nNe9yaVcyr6H0z3bImfJhbS -u4rzI93nAgMBAAECggEBAOIPOJRTpGaH7GpCYUpLK0g/hPFkF5EyEWg/1lSYzRIp -+RsX6zOS+zkiNHEv1jkeKNo7XDiHXM7U6RkQtdkZAQdk9PjM3sEUdm4CEnIjfmzA -p/R8TD0kxkNLIkhuFH2gd05y3ZHDS/XiFkAE9eOT0FrC7om6ESD7ZfFIWR18pncW -ZGq7tFAZZRmpkum2D+MJy1gWxIXBxt5madTEpRxQd56toEnfx372F0y4zkcX3pnE -4H6FaJUBjdvKl2QzF5c0jBqgxMRvWP5YfNu8+dmaQORPkpzSptOPmZM9VKV+tJVS -1xnOI6DtrnNZRojegR/E6KhNyiPTYy97UgYzdKS+SSECgYEA+wgSIqrfkeqqotJx -cGxF4x9v/ldKr5hlhJNoKXLkepkcrvhhxfHKgjWz1nZY/+Rpg42GFMvxWRrGTMIJ -ddiOr24p0HCkusWRMKQL7XxvuHDq0ro8SGqXzqWGuH31R+YNP8dy2pqd3OlwzTgg -8v0wwzx8AuyP5Ys4M20Ewv7Xuy0CgYEA9DSGMU8jmjxJ/uPDCXWOEAqtE78wTtIw -uMBv+ge0inc37xf+fN6D/ziTrJvgw/XyT15pmQdOlXx3Sg1h9XBZeIlaeCdFWrFB -oYrVsiuoXRswfkFwA0yOkCsHyGiI4TE0W1rGbqP158IjwXPczBswWI7i/D6LpINL -BD7YYpfHmeMCgYB08AiKr7Cf54H/gSqo5TcVGzLvdzhqXgKEZKp0DHpUhfivpTLe -o8jjKSMSN2U0JvHj/0xDadGO4YMYhJcll3C4VggSejaybpA46WJJCdt9PtSUv36P -eWAoOkFstfhJuufXGxDstnPtUa1jW881gi5x9D4MmqhZlKXkhtdeApr6LQKBgQDd -ItsJt9JTjpirGfC5lhwI5sIICa9jEO9RveEoluWkJYUfG6k1xgHdkYwYWCdXDFZa -DPKuwnEk6MrU4f181joO7sJf35/sGmuGL0SHzQTvGvn0uqkGM8M9RdoMXqzkzzvM -Jg1ej1bUgXcDbTnaEhzbdLiTFsg5NzMtKwOjdDIpZQKBgEIHeJIqiGjYgf7mUlX2 -vNWgFNlzApkFSCQ8TkzkDOjtCdSHfdRDJ6+q8cS2TSQ7QPoAlI1woS0G48TNbVSo -wD0jNVRTdpA6R5FPsg09ohB/caSn0zlGVha2GS08ceYrn7nn4PSZ/UIYTm3pjUlV -H5tvHv0gG2C5vy3tIYQtSQCk ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/badclient.pem b/contrib/libs/grpc/src/core/tsi/test_creds/badclient.pem deleted file mode 100644 index 345da3932d..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/badclient.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDszCCApugAwIBAgIUONWbkUn1obHCw9L7lMNEE5REvb8wDQYJKoZIhvcNAQEL -BQAwaTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM -GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEiMCAGA1UEAwwZYmFkY2xpZW50LnRl -c3QuZ29vZ2xlLmNvbTAeFw0yMDAzMTcxNzQzMjNaFw0zMDAzMTUxNzQzMjNaMGkx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxIjAgBgNVBAMMGWJhZGNsaWVudC50ZXN0Lmdv -b2dsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDvdzKDTYvR -gjBOUOrzDwkAZGwNFHHlMYyMGI5tItj3tCzXkbpM0uz3ZjHVahu+eYc+KvYApM64 -F2dBb16hs713FCk8mihYABjnSndrQsl/U2v8YFT7DipfLReqqaOGu2o9HdvWfiUl -aiC/UGGfR+YblpK7CG+7/hvTXtUsMw+OppoeH9z87rhOJMxtiC7XwU5rhEmab/1f -1XM/nLoZrfDAcTbDywoeu826SJ3mifajq7oK3LDdNLjWZwfEsCO1qp2C4gLvBlOO -KsWOLNby6ByxCOPlCTa0UCaVuoNclYol71jyi17KW+Nk0nNe9yaVcyr6H0z3bImf -JhbSu4rzI93nAgMBAAGjUzBRMB0GA1UdDgQWBBTKJskEYd2ndrwihPTg2PzYF/kP -gzAfBgNVHSMEGDAWgBTKJskEYd2ndrwihPTg2PzYF/kPgzAPBgNVHRMBAf8EBTAD -AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBoGwWR0pLM1icX4bIJ6yduFU/A4jSiqET6 -gvJhwgErilqTKfH6Y89rqtzW8k4UurAOCsE4FA6wbkHWwrUMnClY4lkHJh+MuNaJ -nCGrK8wRKGb/mqW9d5pP72Et1Q6OW6DAKqGfjDWh2MzSPHBxcCLeyigO1wqd4W1T -nvvql6l4L+B5IT/c+/EHO3PwbI9v6MGTtLjsZgkRKItaPh+YeJdmBYhRD1BvWb6s -VwEb7aQ1oSF+esUvMmjGVuHXuQvWJahnjYdYT2DikyqR+AwaKzre4GJMHsX3/Cf8 -qdxyI+B1jUwNr7sLA2EYDjnUR0jEHcrOBSpIQyRMGWduj0P16yb9 ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/badserver.key b/contrib/libs/grpc/src/core/tsi/test_creds/badserver.key deleted file mode 100644 index 1f5a31666c..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/badserver.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDRY2Z886nT6KF4 -tjgJTX0l1M4j8bQp+jKfXz+hwUZbn/PnCXJlu/5denpyu4XrLxr6Ix4Il97SrKfQ -iGaSZQ8hcq6WQdEDfuo/U7R/dk6lYG7q+yg7+xHm02DzVdPLp09kLhU+fWH3Wek0 -9GCk9iC1/sVTIomBYpar61Ris04iA1QveR+LZKNkQ8rL2i191Djs8cdrn9yhWdfJ -Ai89lLl6S6d8cXru1LwtEe0ejctnKf6ANqMnmyWTbHV8h0Cc3fbAnx92HsWDMJKe -8mI0CClauxrlagMHyw10NuFb9/MBEkFPJfxcUyW6F45LmqGHVfcxx6/BU7XRbWx8 -aQM/pt2LAgMBAAECggEBAKWpei3D7op9FDvYF0+s4iXrT0j682r+y8xx5HtK2iql -y6fwPnUlHqPAwl5B5TtkonhjDmEIH0AZYBBJyrVqhWUWQfEZk4+rexOtWzI5XRHU -0QzSt0t1Yf15IcyEDDSlY9fD6gTt2HOFzE+cRVZecRTsxBv5SEd4w/KzFqmcaWXY -Q7mLvCs6eQ55LBQ6EMweZ3XE57qPf71oV8Ckxv/jstLlkE+3JICgEAaiOEzi7oCm -hYbkoU2VNewx5EA5ka52DQzbVYYYuDbjqtVPXCmlVdejBBmUCAlhdjAIDBYq/RMf -sVMagAo19Wt5lYuNGD9qzMUmzZPaVmkg4yUmU8EYFVkCgYEA8Tyup/0yx+/tp8KQ -cLyGc4RDUTfabL8mlvxcbEge9fQ12aHE3cA/hkHCI7AZxwrHYwb1hxzLaOmKYfFC -oLxfzx81p5BO0lQWcKiFZ6ISiku4TPdmBaauKKxd62kFUPO4Q6Zk1MFHMXrvZUxZ -BsK058HZ5JALDdQ5wBfJE5P58rcCgYEA3jPDMiXsH1s5gM/bh0s+cC1AFSst6YM3 -rRPmHrqJJhKgU6gSB0d0LCUdj4/NkQT/Bw8DrfxLIqytsfRLKCx85K6lk8GfCk6T -1OhPKRp8bgg6WDQiJfJMokJN5zrnC02ns1cVdQSPY8bFxB++tv3du6DKLYx0e46D -Q9ojYqWHh80CgYEA0Shh7nkTrFKUZZ3GClkK4eFNVH/uu9bIKKTJpYCqh2mjvvwJ -apKjAU7GepbW4sKvuWZxPyJyIpZKSz0ZHa/2CejvZkcycB5EDo2ujPnyxUF9nA3s -wP2RhuZb0B4QY+3MV6tPRUAG8Bm8ssGNdtUecMqclxVk4Cqfn7N/vZ/RWOUCgYAL -i2rv1xKOioHRVHtWay1iTKeQsf6frEafQnJpVE294afc0NWm9SpvBLqlc9Y9W6IY -bspFJt+MfKZFoaip/K28f+pwY9XshiqeHDfIreybFuhZHtRLXmxm3cUIZ4ILj0xQ -QA0IWGVOzMwHpZKWFViI4BDBDxQaO0xMoS/Hd0w0XQKBgF5uZXXrNLmCeU6oco1R -gjGJE4gRwaSVcVJbs/VLbBmHT1VhBGsiluBuTpbmzDfyHWHJprnthlSTgqHXSax1 -6GvHZ2NHBqmD2uxEGuwBffzhwWVxHpgSrRgvnnaeIph2Iv92/ATN5LCc5vF+SNGx -2kKWYTDSRu9q1xHpXcax+nmJ ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/badserver.pem b/contrib/libs/grpc/src/core/tsi/test_creds/badserver.pem deleted file mode 100644 index 217dd640eb..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/badserver.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDszCCApugAwIBAgIULEum14ranwlUZjuZchSWaHtj8Z4wDQYJKoZIhvcNAQEL -BQAwaTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM -GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEiMCAGA1UEAwwZYmFkc2VydmVyLnRl -c3QuZ29vZ2xlLmNvbTAeFw0yMDAzMTcxNzE5NTRaFw0zMDAzMTUxNzE5NTRaMGkx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxIjAgBgNVBAMMGWJhZHNlcnZlci50ZXN0Lmdv -b2dsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDRY2Z886nT -6KF4tjgJTX0l1M4j8bQp+jKfXz+hwUZbn/PnCXJlu/5denpyu4XrLxr6Ix4Il97S -rKfQiGaSZQ8hcq6WQdEDfuo/U7R/dk6lYG7q+yg7+xHm02DzVdPLp09kLhU+fWH3 -Wek09GCk9iC1/sVTIomBYpar61Ris04iA1QveR+LZKNkQ8rL2i191Djs8cdrn9yh -WdfJAi89lLl6S6d8cXru1LwtEe0ejctnKf6ANqMnmyWTbHV8h0Cc3fbAnx92HsWD -MJKe8mI0CClauxrlagMHyw10NuFb9/MBEkFPJfxcUyW6F45LmqGHVfcxx6/BU7XR -bWx8aQM/pt2LAgMBAAGjUzBRMB0GA1UdDgQWBBTYP9Av5QoPxsDRE33wQedENOke -wDAfBgNVHSMEGDAWgBTYP9Av5QoPxsDRE33wQedENOkewDAPBgNVHRMBAf8EBTAD -AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCXA/Ewb5laDDxJi4YJxnmqQsb4WSsm65Hj -MX21Ii2vzf4XZ+i8c9xBezCae85Bkhtb/oMC/V15DshjVkkJNmdQfAlYD1NASSrN -hTaiQ4AfXWjO7H8o2B/rneZtA21NDCwvFxTXeJzAVnBkpIePR//KmuHjtCMjsrtP -ovckcTRGmhWJJ9sRx4HCsJXygBvnCIIIYC585aU4+nE53UDNT2T+Bd4b1vPmwf9R -9XgbyN6AhQ+0F11zlnftwsJ23nbnXqX/fpG/YZuhnPwaUILRodc6HZQtf/8xpRcA -0dKMdnL2YtBjuL5QFJMLT0mdsmnXj3h/oK8894nYBZYSmlb3bzZK ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/ca-openssl.cnf b/contrib/libs/grpc/src/core/tsi/test_creds/ca-openssl.cnf deleted file mode 100644 index e97b945e4b..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/ca-openssl.cnf +++ /dev/null @@ -1,17 +0,0 @@ -[req] -distinguished_name = req_distinguished_name -req_extensions = v3_req - -[req_distinguished_name] -countryName = Country Name (2 letter code) -countryName_default = AU -stateOrProvinceName = State or Province Name (full name) -stateOrProvinceName_default = Some-State -organizationName = Organization Name (eg, company) -organizationName_default = Internet Widgits Pty Ltd -commonName = Common Name (eg, YOUR name) -commonName_default = testca - -[v3_req] -basicConstraints = CA:true -keyUsage = critical, keyCertSign diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/ca.key b/contrib/libs/grpc/src/core/tsi/test_creds/ca.key deleted file mode 100644 index 03be0bfa6e..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/ca.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwYvShd+UXQvOg -z4GH6pRT3KGrPDbDw45fma7+I0LJQ4GupoeLuYYfHvcYPTV2I3MLO+VxCp00gfo1 -BIvsNOkGNxrrqNhP27ve9l7YwOuvWdVu4u9+73znRx3GJQ4ie/nF/z6xMcbQL5r5 -UC8yGwuJGOyr6VcpEnKTnORtuwRPJuqnGgn4rsKhLLfJz+RAhjdOKnAS3CQo/iHP -KjoqIZ38M97GJ7icFQic3dtLUFR41nnN5ogLZ6DduR55btypPnlv5h6foLFjRMST -MEroAq39ZSJqUoyBPTBtPFFk7uRQIfdKrp7/Bd4V0n4e91Us+UCDlOcxo2lF1CKH -/ydEWmx3AgMBAAECggEAKrDosKQKKKUlvkg6+6CFIf8GiiFax+ru7KiPuCbkpT3X -h2P67pCKq8Gc4Jr/84YE9DUdBU0iW3ESE/7ztsnflIeF1n/ZSwrN39sVfbTD1n8R -r3LxsHFac8e8pxaU4zfKbmemztBTZFQBWFJV+fSdyCLmNX2WgPRcEuooR366PkWv -xZLAxeDGqpnsa62o1GdGmalxx8aljLN/QcbQi73mR9Osim1OtSd1cyDlZ/8x6OoV -Ae5GDN3Bj0hO9ZKzNWTbQpRw9SHKU6sWXtHlcDx4xi5kN/n9aptn7kixbY9y8uOM -5zjErVGWvxdP94IvlSkrkenwnIjlHBtdlAjVuCFioQKBgQDoJLyfHNWPBnjPGVnK -xcbIIwmf4C9UnZBbHRD3YxU/GBpsPgPh9EwhQTAXlGQGHeuslxCIh4cEfbOIrJ9b -/s3OqeL9CSUaz/N+1av1ZuwOI9CEvNPi51IK+rXNRmVJG8pG6RaKNx57pXaFtmqq -FUtC7twbPECvjspapn61nZYSiQKBgQDCg1tpGwZJJOCIkhYH4wFc4j4p0LxIcBJ2 -E3L9VnQ+APT/x8uitkZsuRY9tmWcHK8/zWTc1GpFdwGUJ9+Yzvprtej+P/buxM9J -Y6ZJZdCIHWDuh3eq+sXS4lwr5fi7ir5m97npG1bXPlOoYIJ7p172EyoNmurRIgiP -LWnzK0jG/wKBgQCRQtOouNFFcyZLaTCPutxdRddy7ESRrRq0eOax9pVH6tw12URy -snyk3naqepdwYG6li82zsSKig8nA/0uktDeyVwoLjhpiwbc7KZc1sxaI7o4/US1B -McBb0G/MqH0elz4myxnomP8BHhOhLflmvnZexrqCbFyJvk8PFFn7aUWMCQKBgDvX -9BCzOszYJqh94X9NrQapqJxu1u6mZFelhjRBHARTgQ0MqC8IS0R58UjNTBeqj5Re -mdCDHar/gSHW3qkBzPPEhMlsXol5TZjzqp5cT7sA5uicDwowmxpVgCwVVeBFQG0n -fDAmtCIGz/A2uQ5YIRQuMzr6VZJAGUgLndQtlfd7AoGBAMq1imggFKd1rt49XCnO -t97lpWOT+TlWYblHr01tOw+esawG5MFucqVI6tGpBSccTRQw6orWf4GK3KmkgQ6J -UgHKjwYsA0sf4U5vppkdkbAbM/WwUPOTQpGFRERyJqMqFGIc4wMtZOJBxXwf+9iD -l8tvan8w/6HugqnI7qqkTgLq ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/ca.pem b/contrib/libs/grpc/src/core/tsi/test_creds/ca.pem deleted file mode 100644 index 49d39cd8ed..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/ca.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDWjCCAkKgAwIBAgIUWrP0VvHcy+LP6UuYNtiL9gBhD5owDQYJKoZIhvcNAQEL -BQAwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM -GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAwwGdGVzdGNhMB4XDTIw -MDMxNzE4NTk1MVoXDTMwMDMxNTE4NTk1MVowVjELMAkGA1UEBhMCQVUxEzARBgNV -BAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0 -ZDEPMA0GA1UEAwwGdGVzdGNhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEAsGL0oXflF0LzoM+Bh+qUU9yhqzw2w8OOX5mu/iNCyUOBrqaHi7mGHx73GD01 -diNzCzvlcQqdNIH6NQSL7DTpBjca66jYT9u73vZe2MDrr1nVbuLvfu9850cdxiUO -Inv5xf8+sTHG0C+a+VAvMhsLiRjsq+lXKRJyk5zkbbsETybqpxoJ+K7CoSy3yc/k -QIY3TipwEtwkKP4hzyo6KiGd/DPexie4nBUInN3bS1BUeNZ5zeaIC2eg3bkeeW7c -qT55b+Yen6CxY0TEkzBK6AKt/WUialKMgT0wbTxRZO7kUCH3Sq6e/wXeFdJ+HvdV -LPlAg5TnMaNpRdQih/8nRFpsdwIDAQABoyAwHjAMBgNVHRMEBTADAQH/MA4GA1Ud -DwEB/wQEAwICBDANBgkqhkiG9w0BAQsFAAOCAQEAkTrKZjBrJXHps/HrjNCFPb5a -THuGPCSsepe1wkKdSp1h4HGRpLoCgcLysCJ5hZhRpHkRihhef+rFHEe60UePQO3S -CVTtdJB4CYWpcNyXOdqefrbJW5QNljxgi6Fhvs7JJkBqdXIkWXtFk2eRgOIP2Eo9 -/OHQHlYnwZFrk6sp4wPyR+A95S0toZBcyDVz7u+hOW0pGK3wviOe9lvRgj/H3Pwt -bewb0l+MhRig0/DVHamyVxrDRbqInU1/GTNCwcZkXKYFWSf92U+kIcTth24Q1gcw -eZiLl5FfrWokUNytFElXob0V0a5/kbhiLc3yWmvWqHTpqCALbVyF+rKJo2f5Kw== ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client.key b/contrib/libs/grpc/src/core/tsi/test_creds/client.key deleted file mode 100644 index 349b40033d..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCyqYRp+DXVp72N -FbQH8hdhTZLycZXOlJhmMsrJmrjn2p7pI/8mTZ/0FC+SGWBGZV+ELiHrmCX5zfaI -Lr9Iuw7Ghr3Vzoefi8r62rLupVPNi/qdqyjWk2dECHC9Z3+Ag3KzKTyerXWjKcvy -KVmM0ZxE0RXhDW/RoQbqZsU2GKg1B2rhUU8KN0gVmKn0rJHOxzRVSYeYLYp5Yn7K -rtPJcKyo9aVuEr7dGANzpyF6lg/nYBWc+9SGwkoLdFvKvABYJMyrbNhHUQfv0fza -Z0P86dfTENrDxzALrzGnqcx3KTrwJjkZ/aSr1tyD0/tXvukRFiPxWBJhjHQ70GqT -FQY19RbhAgMBAAECggEAIL8JUhL4awyvpWhQ8xPgTSlWwbEn8BE0TacJnCILuhNM -BRdf8LlRk/8PKQwVpVF3TFbYSMI+U6b4hMVssfv3HVQc/083dHq+3XOwUCVlUstR -SAzTE2E5EDMr1stdh0SQhV4Nilfos9s5Uk1Z6IGSztoz1GgOErIc/mGPy/aA/hbr -fRWHvTp35+MbCJSvZuOeevX2iLs0dNzqdk6DiOWIH/BVGirVPtO6ykrkuTj1FWiN -hyZ3MBChShlNH2poNX46ntOc7nEus0qteOgxBK8lummFEtlehCA7hd/8xuvYlP0k -7aN684LCRDajmAGpoZO57NSDYQhAFGZeUZ93SMFucQKBgQDe7GGkzZFEiv91u1q9 -lgMy1h5dZjIZKgQaOarPC6wCQMUdqCf6cSLsAPr4T8EDoWsnY7dSnrTZ6YCIFL1T -idg8M3BQXipICCJkFORS76pKKZ0wMn3/NgkSepsmNct91WHr6okvx4tOaoRCtdzU -g7jt4Mr3sfLCiZtqTQyySdMUEwKBgQDNK+ZFKL0XhkWZP+PGKjWG8LWpPiK3d78/ -wYBFXzSTGlkr6FvRmYtZeNwXWRYLB4UxZ9At4hbJVEdi/2dITOz/sehVDyCAjjs3 -gycsc3UJqiZbcw5XKhI5TWBuWxkKENdbMSayogVbp2aSYoRblH764//t0ACmbfTW -KUQRQPB/uwKBgQC5QjjjfPL8w4cJkGoYpFKELO2PMR7xSrmeEc6hwlFwjeNCgjy3 -JM6g0y++rIj7O2qRkY0IXFxvvF3UuWedxTCu1xC/uYHp2ti506LsScB7YZoAM/YB -4iYn9Tx6xLoYGP0H0iGwU2SyBlNkHT8oXU+SYP5MWtYkVbeS3/VtNWz1gQKBgQCA -6Nk4kN0mH7YxEKRzSOfyzeDF4oV7kuB2FYUbkTL+TirC3K58JiYY5Egc31trOKFm -Jlz1xz0b6DkmKWTiV3r9OPHKJ8P7IeJxAZWmZzCdDuwkv0i+WW+z0zsIe3JjEavN -3zb6O7R0HtziksWoqMeTqZeO+wa9iw6vVKQw1wWEqwKBgFHfahFs0DZ5cUTpGpBt -F/AQG7ukgipB6N6AkB9kDbgCs1FLgd199MQrEncug5hfpq8QerbyMatmA+GXoGMb -7vztKEH85yzp4n02FNL6H7xL4VVILvyZHdolmiORJ4qT2hZnl8pEQ2TYuF4RlHUd -nSwXX+2o0J/nF85fm4AwWKAc ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client.pem b/contrib/libs/grpc/src/core/tsi/test_creds/client.pem deleted file mode 100644 index 8815875f32..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDNzCCAh8CFGyX00RCepOv/qCJ1oVdTtY92U83MA0GCSqGSIb3DQEBCwUAMFYx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMMBnRlc3RjYTAeFw0yMDAzMTgw -MTA2MTBaFw0zMDAzMTYwMTA2MTBaMFoxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApT -b21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEzAR -BgNVBAMMCnRlc3RjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQCyqYRp+DXVp72NFbQH8hdhTZLycZXOlJhmMsrJmrjn2p7pI/8mTZ/0FC+SGWBG -ZV+ELiHrmCX5zfaILr9Iuw7Ghr3Vzoefi8r62rLupVPNi/qdqyjWk2dECHC9Z3+A -g3KzKTyerXWjKcvyKVmM0ZxE0RXhDW/RoQbqZsU2GKg1B2rhUU8KN0gVmKn0rJHO -xzRVSYeYLYp5Yn7KrtPJcKyo9aVuEr7dGANzpyF6lg/nYBWc+9SGwkoLdFvKvABY -JMyrbNhHUQfv0fzaZ0P86dfTENrDxzALrzGnqcx3KTrwJjkZ/aSr1tyD0/tXvukR -FiPxWBJhjHQ70GqTFQY19RbhAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAFXCewK8 -cWT+zWxXyGFnouFSBzTi0BMBJRrhsiNoiQxkqityJHWFExiQZie+7CA+EabXCQUB -+JwMSWM29j3mSw10DTfmC3rhheQqGxy304BZyUpdpvI2dt3p/mcsE7O+p4sQrSep -gijiDssKAfxTAmUM93N6+Q8yJK5immxlbeYfijoBvmkzyB/B+qNRPsx0n7aFGnfv -oWfkW296iPhWLiwknpC3xB6oK3vRbK4Zj1OaGb0grK7VN8EyhBix2xVF61i4dzCK -kMIpl7CUpw1Mb2z8q3F2bHBS7iF7g1Ccn5VGcO+aJ+6PWydaeqJ6VEBF0Nwv9woe -mL5AluNRLaqjZvE= ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client1.key b/contrib/libs/grpc/src/core/tsi/test_creds/client1.key deleted file mode 100644 index c37df79f31..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client1.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQD0d1XmFuS1iwBQ -wzGnGhA/ovsFp5jTF0v+aJptNKcwQzlMCkbpBtkVB2SFcsgWew0qtQH57E4iS8pe -gdW5JO6Jgl04aFuVDU2gKYRUB2pXQYObw9GZ6k8SyvDWfZIpTj+qCQ25zQ1/CzgD -b9FKPBPXaIuW8eiYZJwPoOlhBX+RxAfKt79/Ilj2V9JnWi5wH6kRKbfZYg/usKT/ -lfHtlxZ8TdORqVFncnMxoxPTEwLwbqYaUyW6x3kqoFjixdYDuEkOIVoHs/+SBp1H -fRKpfnyErQkd3YcjQm0JgjqCG4+hFNb2HfEUfCSeeWHhAD/S4r1s3sepCm71/huU -GmO7IV2VAgMBAAECggEARy/o55OLDgJoGRx9/Pbt/FntVvwy2GVUT8UOEvbeKIOq -z6W+eGTyGdmJQALomQNEFkeXR7u0FPCVAWg1YDCM9aXsl1xsLr8s95KfYgi2wqnl -NRqUkolUdVh7QTpXsYeDqnPwd0Zqw6/0o6uP+ln8PSHIZDAVVysU9sgYrZP4Te2B -0l5lmmBp8wRtKjZqhQPPuEhW3UETYRWK0QK3siVsnQJrH4k7Sys7AEnMP5NWewBC -R79DQL7eHPX19H/7vBY2cAI8e51yhcT2b+tK6oMn/Xg/sHelVs/uRmShSxwo0eya -Du9oXbV1h3DoIRP2rC1aXQ67sMJQvQvINV8jRgIHkQKBgQD9Mo2XrCWK9W+qFc67 -9MeKX8LG0pz7ORJnx7sORYfsIbfhD5/u22K9RuaHrPoLcjTNXKvQHR54fGJFevaL -h7X+MrXYxtgCIOQeebdHgkb//Px4VqUOoTOz3YfZ754M6S2x2Nf/eqvTSd1hjxKa -L4FHVe65/7ENmLiFTbmTMFNTtwKBgQD3LAq2b3q8CTEhF9CaFrSCHnyvKtQYtGzg -JE2ZfX5qAz6JlM/hOiVprRLEk/5g88519Q+odoPwzOFDSeWAhD7/tPA/OtLkqaSc -reB6Gytu//yVKyPJ0eIDFKbWMWeDEObSwZtEwUf78wcABm5SMuoKC3C2y/woOke3 -a3bb9LUREwKBgHU5YICmPMN3Gnm+mvY+P9v6tezjOba+F51gxWO4IVPb0Iwsdbla -bP6Awt5x4VpHR9cEXq99q8vQmpbcdSTocgP8amCwvvVNURAi/g3nbQO7lxAH3WdG -ju9pUyo9XAlSM8uxP1+S5dZuzkYKvWwRLmNej6YhkVFgMZ3V/GL+7rVFAoGAaQ0Q -6ITs9yo49UW35SWtRnhKqfBcALv+Yi1LxeauacRDOhpDWAhsikOC7IWx4eb9Yujq -5MCqRxfszbqEjmCmnet7CISpyYHIcsb71ynhBeZKpeOV7FsF4iVO205YHj56vCyJ -H2m+fHjICtyw2sLE8cv29dowq7BJds130PhqVH0CgYA3rlDMoCZiSKARwJr0/D6d -B3ez0ZpxKbIHHB7e+T5PFll607I+F+S6IpPfKab3CZQiG/5H/7WFXda1t+rkdayM -QKYvAk8Z8DdDDtdF6GygQq6kq5L54H8w+hcAhPA/AFvGM+59HBOkXlbF1ONmrH2D -btxOGV07JxZEj0IlBMYIaA== ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client1.pem b/contrib/libs/grpc/src/core/tsi/test_creds/client1.pem deleted file mode 100644 index c616b310dd..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client1.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDODCCAiACFDrXOoJ6yF2DsFledztcRyjY+3BcMA0GCSqGSIb3DQEBCwUAMFYx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMMBnRlc3RjYTAeFw0yMDEyMDEy -MzE2MTFaFw0zMDExMjkyMzE2MTFaMFsxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApT -b21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFDAS -BgNVBAMMC3Rlc3RjbGllbnQxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEA9HdV5hbktYsAUMMxpxoQP6L7BaeY0xdL/miabTSnMEM5TApG6QbZFQdkhXLI -FnsNKrUB+exOIkvKXoHVuSTuiYJdOGhblQ1NoCmEVAdqV0GDm8PRmepPEsrw1n2S -KU4/qgkNuc0Nfws4A2/RSjwT12iLlvHomGScD6DpYQV/kcQHyre/fyJY9lfSZ1ou -cB+pESm32WIP7rCk/5Xx7ZcWfE3TkalRZ3JzMaMT0xMC8G6mGlMlusd5KqBY4sXW -A7hJDiFaB7P/kgadR30SqX58hK0JHd2HI0JtCYI6ghuPoRTW9h3xFHwknnlh4QA/ -0uK9bN7HqQpu9f4blBpjuyFdlQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAbJTrl -e8OAQJMrB9utPrCemvV2xC3aK/jtKLOrJ/7n6Atf7Zd5cymfbK2XAGWUiUePvF06 -MlN5AJpN4ujQOB0y+UYS8y/58VGCC9UJnQLo5UATE8w5cAIq5j91vuW9roE/UU4x -jSZ5kjKOPjOpAjbKM5Dp4WVff9/veve+gA+nXA8Xv7Hn0vCLcjdRpFPEfvgp66qP -E+tpeRWOu6fggxtTlAK68HMkQqKpb6R+obMePzxiAAgGiy4o6RvsHLA0iuViqHuE -mu8cmPbEvWxwzTthkZEj2ekdLKecFN4ub4suZyAF85mz2SI7D0p4C8M46VIhWq6i -bBfU/DCPHpZpcVIl ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client2.key b/contrib/libs/grpc/src/core/tsi/test_creds/client2.key deleted file mode 100644 index 613c47ac9a..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client2.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQClO55XKwBIEnTa -KeclFa6l3Bc3G4lMdDa+JdCi3x+5KYlBN9NJth5z7Pj6Nrv/bpm4g69qhVV2sIjJ -4XeEeObLY+0cadU58hdPXlhWHoMJst5uU+DkV0yjPwvLkmhsRj0RPicV+2qV6Scq -zQDqXMMx8jyhhExkZBeOz1xCGR4Abo1zdpNfusZJ3GsFGQwqxwdK/l4dIkyLqtxp -IS+vSsYeAMyuVZJHD61u7YiZasREyrFqkkSyDPGeCR3k6+4ajwfz1rVMITP5EZJ2 -pUdvdRgke7Okpwanf8og9LF5AaJz53yuUBVz40O/3whI7J4e+D3i5V5JGftLl0/V -xJDdHrU1AgMBAAECggEATQ701Wo0g2g4HtaT+fOWs7tlCEpLSeCY9yzjlFHClbQN -UuEaJLJOmXnW07pbCtEl16tyT5dHOEc0RBJmjt1jpU9A8ZNZ4eBJhrZVNDSeoBNP -MNzlcRhVoXxxn8rz8CsBp9z4lYPfPXKy1X8uAh6o2c5DAICWr+sOIYgLWrgkCcbF -QxP5cRs53nFwImnOJka7sxgUvQNW74Zto3WByCQ3QkFDQEOMEFPP2v5J0AiZTuIC -nFfB1/O2YByKOUjhA+7ZYX/3qSXRrC7VW4kaMl1fVABccUCWhPdc9u+xz+m2fWnQ -ZZXeTbgNbhykldz6J6JmKnDtIdj5WfdNTdLSDGgasQKBgQDTBwW/y7NT0r+IJEOF -hbxN2XtB+i2VDVoeS0TYpJFMZfufXkBc331jyQid/8yusPjYW31n5vHYopDydsde -NGAdCfjtBFawVGPYvbTgXSrB5n120merdHQ6TFmp7QhjHU5ds7N8ihh1OQfkBw/6 -UUaHVn3sBAKOLYbcCvGin7FuFwKBgQDIcjFmajYPHQ+yom8zn1bCvfgJ1aEXsP6m -PxHeP4JeBjaD1ukuq+LUGCgViDWCO8c/j1AcnrNihh2oP7brY+xEqpm6IfQI79KZ -kp++ybm4w6yvuYNnWR9yXJc0LTrTu4IOMuDpbPBFT9gGDLZYYc7yT8U55NGC3ry7 -tv0lZKQykwKBgQCjUf8IFj3etO+ZDP/Y+cznr1aulFHs1p2VbomE5bCyIQehqs9D -UZB4xuDNb2jZFoww3nXrERjBoeduT7Ey3nQ4ZTxrK31wEJAJ8aBoOJLb6GfXqzWi -w4kkiWynj5R7KPY6nNZfn30YVCAgQbsC7x4Xpj/khqH3qZKDAFFMnC001wKBgCTA -Sy5r6t16hpZKEfl1DYNHMWMcOB0P5qC0j6IgItb6bKRfkwFronsgsri/8I+gRjfx -Hs8gieNWk7l1dSRTfc5ZOTZXY1cAIazmpUNl2Rd3SQIvEVixjoJ5V3/Jiy+nAYF4 -8qPZxXPv37u8OPKbfEYROigTPBayoAgK1P82JKThAoGAJQ7aR+ItRUSOyD/ofZKB -wQeYSVnv+UQg6gTh4GWf91D4WYgBVCGWhPJ8zMRZfcy1/TplJC917MVnkLP7k91D -paxsSdRDVkSATGTX3bOTw2P9CbNFpRUIdz++7hmbhZjT/DBvtFYiRuaylGAuAdH7 -YzdO4ZLBuBW7jbDc7a2RHNg= ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/client2.pem b/contrib/libs/grpc/src/core/tsi/test_creds/client2.pem deleted file mode 100644 index 0565b1b136..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/client2.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDODCCAiACFBjjQkCIdrl6SU6uUtepyES0xVV2MA0GCSqGSIb3DQEBCwUAMFYx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMMBnRlc3RjYTAeFw0yMDEyMDIw -MTExNDNaFw0zMDExMzAwMTExNDNaMFsxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApT -b21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFDAS -BgNVBAMMC3Rlc3RjbGllbnQyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEApTueVysASBJ02innJRWupdwXNxuJTHQ2viXQot8fuSmJQTfTSbYec+z4+ja7 -/26ZuIOvaoVVdrCIyeF3hHjmy2PtHGnVOfIXT15YVh6DCbLeblPg5FdMoz8Ly5Jo -bEY9ET4nFftqleknKs0A6lzDMfI8oYRMZGQXjs9cQhkeAG6Nc3aTX7rGSdxrBRkM -KscHSv5eHSJMi6rcaSEvr0rGHgDMrlWSRw+tbu2ImWrERMqxapJEsgzxngkd5Ovu -Go8H89a1TCEz+RGSdqVHb3UYJHuzpKcGp3/KIPSxeQGic+d8rlAVc+NDv98ISOye -Hvg94uVeSRn7S5dP1cSQ3R61NQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQB4WZlD -CgvMA/LD3wJAG2v53IuG8rJ2R0QG3dKbN6hCKsqVfJpF51L55RB+ABn7FT3CAfqJ -w8IvisQ4vlr6dqxkGS7MPTou2H2LU6PARWPgqJnwRAB5gvjecHzDjKqhHlsQQXBw -PHFt54EcyWtX2xgQmP5acjCj8o03gC3+tWtaAQgM6CExgXB4PgeUGIgTH5c016aZ -YzxJgZS4UDfgA8+YVmzWNsGvgbITKu84hU2dqLCLoIqJPzwSikUVNS7Bo07o0hgH -NNSDLaMNpaMC51dDiHbtER8hPp9elhSWOZRPXgEGbvQCFOt/Wz79Mw2dnpbBXVdb -ANSsdO2Qu7snGMXr ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain-openssl.cnf b/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain-openssl.cnf deleted file mode 100644 index 33ecc9d9b8..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain-openssl.cnf +++ /dev/null @@ -1,33 +0,0 @@ -[req] -distinguished_name = req_distinguished_name -req_extensions = v3_req - -[req_distinguished_name] -countryName = Country Name (2 letter code) -countryName_default = US -stateOrProvinceName = State or Province Name (full name) -stateOrProvinceName_default = CA -localityName = Locality Name (eg, city) -localityName_default = SF -organizationalUnitName = Organizational Unit Name (eg, section) -organizationalUnitName_default = Google -commonName = Common Name (CN) -commonName_default =xpigors -commonName_max = 64 - -[ v3_req ] -basicConstraints = CA:FALSE -keyUsage = nonRepudiation, digitalSignature, keyEncipherment -subjectAltName = @alt_names - -[alt_names] -DNS.1 = foo.test.domain.com -DNS.2 = bar.test.domain.com -URI.1 = https://foo.test.domain.com/test -URI.2 = https://bar.test.domain.com/test -URI.3 = spiffe://foo.com/bar/baz -email.1 = foo@test.domain.com -email.2 = bar@test.domain.com -IP.1 = 192.168.7.1 -IP.2 = 13::17 -RID.1 = 1.2.3.4 diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.key b/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.key deleted file mode 100644 index 2b9cce0bdb..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDAg51YU8NkgC7w -Hx7Jf9Zj+wjHcLxedY6czsFjhl9wUlYRkQ+wdt3suH998TrbdVMc38tpI460pGk7 -gGBpMkbZgo1YNnwz/U1jAOR11EVGHN1QDy3H0BI2E5RYtl/vTWQLFo1khIaKK4eS -3ptrPd+1XB6L25E4ISOVgd3yn4b5eTMGRbEei+wrkZIyZAVgCIw8d6BHHwldWz3A -ljKRErMPzKtnyVL+ctp0Kx6ObppiBPPOWhNNTtMkmLgfeZQK3U7cPN5WI13Fso05 -FA3wVo/w6sXTtz4inIT14Y57E34V6sWZezrBbTtAI0yN3DqXSKTBgGjOQUbjqVxS -i/JzRbZpAgMBAAECggEAXJMt59qn3D1T1P5yFJ2X4A5Io3eP7bCEOt2l25EzddTy -NJJYRBh1Ea+LB2ooTn410G3B6DZEGpPxUr6iHhQiQ9hm1eOliG6ndxNnyU2hXlzl -A+m4rxxclYqGzL4ulenWUQqwRYUBGZJjKHpJrKFdYV4CBmk4hRBSh0OjElgqVO5g -nliMl3fC+GgUXtdMDGoPnC6MwD8q0RSJxbzpd8r+yREgX6KveEfPTfgSLAUieJrf -2qqEk0Prdrwzsu0iyDYCaWLOq0cUstnHCo3e5synV4VzAFnaqxMT7lCVuUHgFpHj -62rTwBCG/n3s+IVAp9CGBe37+SiJPRE8t5PDr65F3QKBgQDovkKLWzXxVJauTF/E -tFRA+HqNDzYC3yiN0MIBmcF7IntdwCHznMyqydkaSE6WYn+NKglbH3c4RD5Hmdxc -PUta8wgpmTg264568Svgna5jhwoqStrzh7qeBPXHmJvK4MkWALH4ukr3hIsWzsAh -881ebstQDke8uHzyNZBY/URebwKBgQDTwEP6hgcgDOaf9yzipeMhtsArIm7zXn+r -1RknpKUA8wM6fpEMpdUTgReu9tdJDgrcKac6imSZoNM6DBoOb/Hdj6FourHiTTvE -dXAOjAzkDz/c86HFuDNoz27usoMPu/3iJPwuLQSO0IlflccLuOirhnnY8yVxIuy2 -+9g+2iOkpwKBgE/Kin3EM2YdHdt7i4mgWRI9HaamhFnPr9OOsjRiRha0555odDtU -kkYrFScRiv+7nQcEVljLHNBJdSCO+yEUUnVHxJCeWstZTmuPqv9Cj7rHXRDKwO2k -prHt+WUISMDw9393lYw0MedRpW2YS/5X2xx413MGsklc5lkTS/12Nq45AoGAaVCf -vrL4Sj2AWqEhxtwAmlz9OLbYfdxLHVhQOYJOuqkiuu4GEEdOMXQsJk4IhwIf7p4c -2SXJoQr241DviKyum6Z6/c6U+Fu3VR+fiuym4Kqg9bCKjf7uOruojbllK+cw/0+r -yP+E287l9A9XPwJJXj30zi0oOxvGpb+eLqxpu9MCgYEAxIgVhzyfRvoAdNYk7FE7 -JDig38EGC4m9grh/9G0tMvWT/E+F1Hb5V9NDK/iWA25dD3hOASxza1Hqkt1dP5on -FMZrmP2T9Ov0wgfVuRIf8/c3YyiS1wJXb3wROVaJJDSvE5c2UszR5pfqvNE5C1YV -zpc3ITQSAX66LK6ImkHb9Jw= ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.pem b/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.pem deleted file mode 100644 index 727b8ff490..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/multi-domain.pem +++ /dev/null @@ -1,24 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEGzCCAwOgAwIBAgIUVwCmP2zKfeoWdaMbn32PjFgpdRswDQYJKoZIhvcNAQEL -BQAwSjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEPMA0G -A1UECwwGR29vZ2xlMRAwDgYDVQQDDAd4cGlnb3JzMB4XDTIxMDQwOTE5MzgxOVoX -DTMxMDQwNzE5MzgxOVowSjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYD -VQQHDAJTRjEPMA0GA1UECwwGR29vZ2xlMRAwDgYDVQQDDAd4cGlnb3JzMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwIOdWFPDZIAu8B8eyX/WY/sIx3C8 -XnWOnM7BY4ZfcFJWEZEPsHbd7Lh/ffE623VTHN/LaSOOtKRpO4BgaTJG2YKNWDZ8 -M/1NYwDkddRFRhzdUA8tx9ASNhOUWLZf701kCxaNZISGiiuHkt6baz3ftVwei9uR -OCEjlYHd8p+G+XkzBkWxHovsK5GSMmQFYAiMPHegRx8JXVs9wJYykRKzD8yrZ8lS -/nLadCsejm6aYgTzzloTTU7TJJi4H3mUCt1O3DzeViNdxbKNORQN8FaP8OrF07c+ -IpyE9eGOexN+FerFmXs6wW07QCNMjdw6l0ikwYBozkFG46lcUovyc0W2aQIDAQAB -o4H4MIH1MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMIHaBgNVHREEgdIwgc+CE2Zv -by50ZXN0LmRvbWFpbi5jb22CE2Jhci50ZXN0LmRvbWFpbi5jb22GIGh0dHBzOi8v -Zm9vLnRlc3QuZG9tYWluLmNvbS90ZXN0hiBodHRwczovL2Jhci50ZXN0LmRvbWFp -bi5jb20vdGVzdIYYc3BpZmZlOi8vZm9vLmNvbS9iYXIvYmF6gRNmb29AdGVzdC5k -b21haW4uY29tgRNiYXJAdGVzdC5kb21haW4uY29thwTAqAcBhxAAEwAAAAAAAAAA -AAAAAAAXiAMqAwQwDQYJKoZIhvcNAQELBQADggEBAIHzi/MWANQDYqpNDGVA6HGg -vYPnwxjLXL/8apVf1ZMHzS/R6Eudu8ugppnnEL7Cjsd4oA0r/sJLjBvhaZtf0r4S -GguWdmai2RR1ghwkCLPF/HlCqiBKwUfWrjTxq8GOwwodhW7lk4hLPzhFRzh/I93g -uN5/ugPKcloWQ7X/0okMdkdPmk8uLpMckXNKj13Lupl/0BgDggghVXRTA2t0ujhx -TvRWfYi5H1eJtNcj824PaIDifPiSOpzeXZi+na2XzzVmCz5n/e2H4nlTMVcN6YGG -M3U3uJqjjjpKkCrrdNAJJpqqJpln4P6fVvO2ND1QmyE5YIKV3tZ8p38AJOheUcw= ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/server0.key b/contrib/libs/grpc/src/core/tsi/test_creds/server0.key deleted file mode 100644 index 261097a87e..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/server0.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCei9aKutDNg2mr -COICW4hT6+LVJfI5J6DZ3yqb6MBzbc//VeUj1OCX/vt5vvPm1Qb5XNk1MOIFPEW6 -t2/0Mhj2VbQfjDe/PhZRhwu4PBtuoJBDeBsKkdnxD0I+4G0XRbeTtUsGMGBgWSAd -qHMD2HnEhgydRw0krYjZp4a/HMCnZZ1WFamw1PCvQK6AuWSSk4iHGaYklXUaKd3r -Rlkujr7//ihcvqweJ+OdaTwXD8z4P0YfFe/bkWWpuqIZz1Or/nxiNBtvWKlI8pR2 -K3wkoWsW+6bnFN8u81nstHDardR6zy3B7QXke02q4sddUERcwNFyPqpscetMpnhg -lhjrmnAXAgMBAAECggEAA6pB5GUbLJUMHUsQRnOtPBto2/qLleynmEHDb2U7BbAV -LdbjfCeQpZLcZ10VsFFeXudZkhQ2NV7GUeGpseBymUcz6cLJCx+5Tlsr1y90huMp -UpX1MhJbEmqC4oc3nmEbNEvtlxAJOlD1IBpjxkP71KIwqnYZBK8KSdXIlKRqg7QZ -VUgjA08TmWlZSxnOt1hpt2ZVjTOn7973YoTb4D7SZydMuVjTkwv9YjPFZOZ/wIP4 -JTZczY/bJjEF7QBYL/wtir/vNJlxxi+FunJdoO3blhf8li5QU0iPd/YsyBFBBWfF -vD7QslaB7wQ8zyWxWpPLiWeD83XGE+7CY2+8EpG3AQKBgQDMK6N7jDQCq9F7n+5B -R8YPDMdINpcVsN8bIeEVKSxYE86oADQg/0jPUct+4liUS1dv0DUmUP1U0zbvupX7 -NxE+gI8KFwCyq8nqZ1guW9oO00ZAGo4Rn0TIeoHWVgsE2tDqBFeC2wWYle1AaZLx -ZtFH6Ya4Q3a4xvjkXXabhbBDlwKBgQDGyzuNCGT1Xa1DXKLzyKspahdm9r7QXifo -jjZkcmzwItC535MBbQMq5+THD+WUbWrZ/rJ8KaSsoGmnjaWguSG0WLFpH3UiGn1W -FOSG2UGc0mWyz2p/j97EuhK12fabzn8rkuiohiFXjJDYrAIulcM++0ar3q2LyqXr -gleBEHLHgQKBgEAt44j9rIe+bO44etOIdUjb0nTvvBR0cd18i910AN169HY5Ainx -NXj+FELBcejDuiuKvnpZ8RhOALHg7C54w/HqxYv9aRnBCIqni7+e3e/VF/sknc4K -S7vdTp0KlRIkmpFFZiDbKmopjte1mBxMHrNFRDT99/7jhO98NcFzh9HnAoGAMf62 -sVdlHJg8lO5dRPY4pae6zvhLMNgdLU1mvIhSgWogGD70F6202DuNu8pxsIx8DOsT -NEq80XVeXPcwqmUk5thPdeKlcLg8wUNr3cYRzEDVtsyXOhGSsuMhBX8VmEWskebW -gFuLUxtU6kkIG3MqsVI8icjs2HVUmRAktZ7PXwECgYA9V/zZe2DpP36gp63wRk6S -FI7bDbLPQCKah23mwp3WeP5T+/HmFFRrl0OCaDLwudTolqgPa47CV7JYa9LmJAPj -QBxcnL4CxjlaaS3V9kxVWOXabMEtwSUurELJwFKTEC/AFN9dR/nv4AzXInZznotG -7qDX8EhfjbFVJw4riAmlEw== ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/server0.pem b/contrib/libs/grpc/src/core/tsi/test_creds/server0.pem deleted file mode 100644 index ab20787fa5..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/server0.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQTCCAikCFGyX00RCepOv/qCJ1oVdTtY92U84MA0GCSqGSIb3DQEBCwUAMFYx -CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl -cm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMMBnRlc3RjYTAeFw0yMDAzMTgw -MTA3MzhaFw0zMDAzMTYwMTA3MzhaMGQxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApT -b21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxHTAb -BgNVBAMMFCoudGVzdC5nb29nbGUuY29tLmF1MIIBIjANBgkqhkiG9w0BAQEFAAOC -AQ8AMIIBCgKCAQEAnovWirrQzYNpqwjiAluIU+vi1SXyOSeg2d8qm+jAc23P/1Xl -I9Tgl/77eb7z5tUG+VzZNTDiBTxFurdv9DIY9lW0H4w3vz4WUYcLuDwbbqCQQ3gb -CpHZ8Q9CPuBtF0W3k7VLBjBgYFkgHahzA9h5xIYMnUcNJK2I2aeGvxzAp2WdVhWp -sNTwr0CugLlkkpOIhxmmJJV1Gind60ZZLo6+//4oXL6sHifjnWk8Fw/M+D9GHxXv -25FlqbqiGc9Tq/58YjQbb1ipSPKUdit8JKFrFvum5xTfLvNZ7LRw2q3Ues8twe0F -5HtNquLHXVBEXMDRcj6qbHHrTKZ4YJYY65pwFwIDAQABMA0GCSqGSIb3DQEBCwUA -A4IBAQCCGvZpM+t83xWPCsz5FyuCqA6LI+j0NMMmKpe1wJ8JcK2o9Qw4d0wPxWdy -0O7Ti2YlJS3gups00zsaFhQymIKUBi5Gc+1VC7qHUUrVtkoIRe6QSpcVlxPVczlD -If1egkjBCUZKVSWqYRKB6AMqjpp7/dF06j6zAaAH54jaLv9VmiBtsFyd017AsC9W -+OG2ke2dNtXySfVX4VusCcji86qb5sr6hNIQWMXk6dZoLDsZvwvVi7KnrqQOza8J -klcJXV8Hsnq/faHr/ZmsIA65N0+H8KuYfbO+s5nKPG9th6ZZAu4aY2VDei++TH+H -EAQhivPNUC1DgCmx0P7vKLhgka7S ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/server1-openssl.cnf b/contrib/libs/grpc/src/core/tsi/test_creds/server1-openssl.cnf deleted file mode 100644 index 8a02108289..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/server1-openssl.cnf +++ /dev/null @@ -1,26 +0,0 @@ -[req] -distinguished_name = req_distinguished_name -req_extensions = v3_req - -[req_distinguished_name] -countryName = Country Name (2 letter code) -countryName_default = US -stateOrProvinceName = State or Province Name (full name) -stateOrProvinceName_default = Illinois -localityName = Locality Name (eg, city) -localityName_default = Chicago -organizationName = Organization Name (eg, company) -organizationName_default = Example, Co. -commonName = Common Name (eg, YOUR name) -commonName_max = 64 - -[v3_req] -basicConstraints = CA:FALSE -keyUsage = nonRepudiation, digitalSignature, keyEncipherment -subjectAltName = @alt_names - -[alt_names] -DNS.1 = *.test.google.fr -DNS.2 = waterzooi.test.google.be -DNS.3 = *.test.youtube.com -IP.1 = "192.168.1.3" diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/server1.key b/contrib/libs/grpc/src/core/tsi/test_creds/server1.key deleted file mode 100644 index 086462992c..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/server1.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDnE443EknxvxBq -6+hvn/t09hl8hx366EBYvZmVM/NC+7igXRAjiJiA/mIaCvL3MS0Iz5hBLxSGICU+ -WproA3GCIFITIwcf/ETyWj/5xpgZ4AKrLrjQmmX8mhwUajfF3UvwMJrCOVqPp67t -PtP+2kBXaqrXdvnvXR41FsIB8V7zIAuIZB6bHQhiGVlc1sgZYsE2EGG9WMmHtS86 -qkAOTjG2XyjmPTGAwhGDpYkYrpzp99IiDh4/Veai81hn0ssQkbry0XRD/Ig3jcHh -23WiriPNJ0JsbgXUSLKRPZObA9VgOLy2aXoN84IMaeK3yy+cwSYG/99w93fUZJte -MXwz4oYZAgMBAAECggEBAIVn2Ncai+4xbH0OLWckabwgyJ4IM9rDc0LIU368O1kU -koais8qP9dujAWgfoh3sGh/YGgKn96VnsZjKHlyMgF+r4TaDJn3k2rlAOWcurGlj -1qaVlsV4HiEzp7pxiDmHhWvp4672Bb6iBG+bsjCUOEk/n9o9KhZzIBluRhtxCmw5 -nw4Do7z00PTvN81260uPWSc04IrytvZUiAIx/5qxD72bij2xJ8t/I9GI8g4FtoVB -8pB6S/hJX1PZhh9VlU6Yk+TOfOVnbebG4W5138LkB835eqk3Zz0qsbc2euoi8Hxi -y1VGwQEmMQ63jXz4c6g+X55ifvUK9Jpn5E8pq+pMd7ECgYEA93lYq+Cr54K4ey5t -sWMa+ye5RqxjzgXj2Kqr55jb54VWG7wp2iGbg8FMlkQwzTJwebzDyCSatguEZLuB -gRGroRnsUOy9vBvhKPOch9bfKIl6qOgzMJB267fBVWx5ybnRbWN/I7RvMQf3k+9y -biCIVnxDLEEYyx7z85/5qxsXg/MCgYEA7wmWKtCTn032Hy9P8OL49T0X6Z8FlkDC -Rk42ygrc/MUbugq9RGUxcCxoImOG9JXUpEtUe31YDm2j+/nbvrjl6/bP2qWs0V7l -dTJl6dABP51pCw8+l4cWgBBX08Lkeen812AAFNrjmDCjX6rHjWHLJcpS18fnRRkP -V1d/AHWX7MMCgYEA6Gsw2guhp0Zf2GCcaNK5DlQab8OL4Hwrpttzo4kuTlwtqNKp -Q9H4al9qfF4Cr1TFya98+EVYf8yFRM3NLNjZpe3gwYf2EerlJj7VLcahw0KKzoN1 -QBENfwgPLRk5sDkx9VhSmcfl/diLroZdpAwtv3vo4nEoxeuGFbKTGx3Qkf0CgYEA -xyR+dcb05Ygm3w4klHQTowQ10s1H80iaUcZBgQuR1ghEtDbUPZHsoR5t1xCB02ys -DgAwLv1bChIvxvH/L6KM8ovZ2LekBX4AviWxoBxJnfz/EVau98B0b1auRN6eSC83 -FRuGldlSOW1z/nSh8ViizSYE5H5HX1qkXEippvFRE88CgYB3Bfu3YQY60ITWIShv -nNkdcbTT9eoP9suaRJjw92Ln+7ZpALYlQMKUZmJ/5uBmLs4RFwUTQruLOPL4yLTH -awADWUzs3IRr1fwn9E+zM8JVyKCnUEM3w4N5UZskGO2klashAd30hWO+knRv/y0r -uGIYs9Ek7YXlXIRVrzMwcsrt1w== ------END PRIVATE KEY----- diff --git a/contrib/libs/grpc/src/core/tsi/test_creds/server1.pem b/contrib/libs/grpc/src/core/tsi/test_creds/server1.pem deleted file mode 100644 index 88244f856c..0000000000 --- a/contrib/libs/grpc/src/core/tsi/test_creds/server1.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDtDCCApygAwIBAgIUbJfTREJ6k6/+oInWhV1O1j3ZT0IwDQYJKoZIhvcNAQEL -BQAwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM -GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAwwGdGVzdGNhMB4XDTIw -MDMxODAzMTA0MloXDTMwMDMxNjAzMTA0MlowZTELMAkGA1UEBhMCVVMxETAPBgNV -BAgMCElsbGlub2lzMRAwDgYDVQQHDAdDaGljYWdvMRUwEwYDVQQKDAxFeGFtcGxl -LCBDby4xGjAYBgNVBAMMESoudGVzdC5nb29nbGUuY29tMIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEA5xOONxJJ8b8Qauvob5/7dPYZfIcd+uhAWL2ZlTPz -Qvu4oF0QI4iYgP5iGgry9zEtCM+YQS8UhiAlPlqa6ANxgiBSEyMHH/xE8lo/+caY -GeACqy640Jpl/JocFGo3xd1L8DCawjlaj6eu7T7T/tpAV2qq13b5710eNRbCAfFe -8yALiGQemx0IYhlZXNbIGWLBNhBhvVjJh7UvOqpADk4xtl8o5j0xgMIRg6WJGK6c -6ffSIg4eP1XmovNYZ9LLEJG68tF0Q/yIN43B4dt1oq4jzSdCbG4F1EiykT2TmwPV -YDi8tml6DfOCDGnit8svnMEmBv/fcPd31GSbXjF8M+KGGQIDAQABo2swaTAJBgNV -HRMEAjAAMAsGA1UdDwQEAwIF4DBPBgNVHREESDBGghAqLnRlc3QuZ29vZ2xlLmZy -ghh3YXRlcnpvb2kudGVzdC5nb29nbGUuYmWCEioudGVzdC55b3V0dWJlLmNvbYcE -wKgBAzANBgkqhkiG9w0BAQsFAAOCAQEAS8hDQA8PSgipgAml7Q3/djwQ644ghWQv -C2Kb+r30RCY1EyKNhnQnIIh/OUbBZvh0M0iYsy6xqXgfDhCB93AA6j0i5cS8fkhH -Jl4RK0tSkGQ3YNY4NzXwQP/vmUgfkw8VBAZ4Y4GKxppdATjffIW+srbAmdDruIRM -wPeikgOoRrXf0LA1fi4TqxARzeRwenQpayNfGHTvVF9aJkl8HoaMunTAdG5pIVcr -9GKi/gEMpXUJbbVv3U5frX1Wo4CFo+rZWJ/LyCMeb0jciNLxSdMwj/E/ZuExlyeZ -gc9ctPjSMvgSyXEKv6Vwobleeg88V2ZgzenziORoWj4KszG/lbQZvg== ------END CERTIFICATE----- diff --git a/contrib/libs/grpc/src/cpp/common/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/cpp/common/.yandex_meta/licenses.list.txt deleted file mode 100644 index b042e4af0c..0000000000 --- a/contrib/libs/grpc/src/cpp/common/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,50 +0,0 @@ -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2019 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. diff --git a/contrib/libs/grpc/src/proto/grpc/channelz/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/channelz/.yandex_meta/licenses.list.txt deleted file mode 100644 index 8b7269ff4c..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/channelz/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2018 The gRPC Authors diff --git a/contrib/libs/grpc/src/proto/grpc/core/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/core/.yandex_meta/licenses.list.txt deleted file mode 100644 index 28e08e9def..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/core/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. diff --git a/contrib/libs/grpc/src/proto/grpc/gcp/altscontext.proto b/contrib/libs/grpc/src/proto/grpc/gcp/altscontext.proto deleted file mode 100644 index cce6dd2afc..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/gcp/altscontext.proto +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2018 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. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/altscontext.proto - -syntax = "proto3"; - -package grpc.gcp; - -import "src/proto/grpc/gcp/transport_security_common.proto"; - -option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; -option java_multiple_files = true; -option java_outer_classname = "AltsContextProto"; -option java_package = "io.grpc.alts.internal"; - -message AltsContext { - // The application protocol negotiated for this connection. - string application_protocol = 1; - - // The record protocol negotiated for this connection. - string record_protocol = 2; - - // The security level of the created secure channel. - SecurityLevel security_level = 3; - - // The peer service account. - string peer_service_account = 4; - - // The local service account. - string local_service_account = 5; - - // The RPC protocol versions supported by the peer. - RpcProtocolVersions peer_rpc_versions = 6; - - // Additional attributes of the peer. - map<string, string> peer_attributes = 7; -} diff --git a/contrib/libs/grpc/src/proto/grpc/gcp/handshaker.proto b/contrib/libs/grpc/src/proto/grpc/gcp/handshaker.proto deleted file mode 100644 index fe0e1e199a..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/gcp/handshaker.proto +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2018 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. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/handshaker.proto - -syntax = "proto3"; - -package grpc.gcp; - -import "src/proto/grpc/gcp/transport_security_common.proto"; - -option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; -option java_multiple_files = true; -option java_outer_classname = "HandshakerProto"; -option java_package = "io.grpc.alts.internal"; - - -enum HandshakeProtocol { - // Default value. - HANDSHAKE_PROTOCOL_UNSPECIFIED = 0; - - // TLS handshake protocol. - TLS = 1; - - // Application Layer Transport Security handshake protocol. - ALTS = 2; -} - -enum NetworkProtocol { - NETWORK_PROTOCOL_UNSPECIFIED = 0; - TCP = 1; - UDP = 2; -} - -message Endpoint { - // IP address. It should contain an IPv4 or IPv6 string literal, e.g. - // "192.168.0.1" or "2001:db8::1". - string ip_address = 1; - - // Port number. - int32 port = 2; - - // Network protocol (e.g., TCP, UDP) associated with this endpoint. - NetworkProtocol protocol = 3; -} - -message Identity { - oneof identity_oneof { - // Service account of a connection endpoint. - string service_account = 1; - - // Hostname of a connection endpoint. - string hostname = 2; - } - - // Additional attributes of the identity. - map<string, string> attributes = 3; -} - -message StartClientHandshakeReq { - // Handshake security protocol requested by the client. - HandshakeProtocol handshake_security_protocol = 1; - - // The application protocols supported by the client, e.g., "h2" (for http2), - // "grpc". - repeated string application_protocols = 2; - - // The record protocols supported by the client, e.g., - // "ALTSRP_GCM_AES128". - repeated string record_protocols = 3; - - // (Optional) Describes which server identities are acceptable by the client. - // If target identities are provided and none of them matches the peer - // identity of the server, handshake will fail. - repeated Identity target_identities = 4; - - // (Optional) Application may specify a local identity. Otherwise, the - // handshaker chooses a default local identity. - Identity local_identity = 5; - - // (Optional) Local endpoint information of the connection to the server, - // such as local IP address, port number, and network protocol. - Endpoint local_endpoint = 6; - - // (Optional) Endpoint information of the remote server, such as IP address, - // port number, and network protocol. - Endpoint remote_endpoint = 7; - - // (Optional) If target name is provided, a secure naming check is performed - // to verify that the peer authenticated identity is indeed authorized to run - // the target name. - string target_name = 8; - - // (Optional) RPC protocol versions supported by the client. - RpcProtocolVersions rpc_versions = 9; - - // (Optional) Maximum frame size supported by the client. - uint32 max_frame_size = 10; -} - -message ServerHandshakeParameters { - // The record protocols supported by the server, e.g., - // "ALTSRP_GCM_AES128". - repeated string record_protocols = 1; - - // (Optional) A list of local identities supported by the server, if - // specified. Otherwise, the handshaker chooses a default local identity. - repeated Identity local_identities = 2; -} - -message StartServerHandshakeReq { - // The application protocols supported by the server, e.g., "h2" (for http2), - // "grpc". - repeated string application_protocols = 1; - - // Handshake parameters (record protocols and local identities supported by - // the server) mapped by the handshake protocol. Each handshake security - // protocol (e.g., TLS or ALTS) has its own set of record protocols and local - // identities. Since protobuf does not support enum as key to the map, the key - // to handshake_parameters is the integer value of HandshakeProtocol enum. - map<int32, ServerHandshakeParameters> handshake_parameters = 2; - - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple HandshakReq messages. - bytes in_bytes = 3; - - // (Optional) Local endpoint information of the connection to the client, - // such as local IP address, port number, and network protocol. - Endpoint local_endpoint = 4; - - // (Optional) Endpoint information of the remote client, such as IP address, - // port number, and network protocol. - Endpoint remote_endpoint = 5; - - // (Optional) RPC protocol versions supported by the server. - RpcProtocolVersions rpc_versions = 6; - - // (Optional) Maximum frame size supported by the server. - uint32 max_frame_size = 7; -} - -message NextHandshakeMessageReq { - // Bytes in out_frames returned from the peer's HandshakerResp. It is possible - // that the peer's out_frames are split into multiple NextHandshakerMessageReq - // messages. - bytes in_bytes = 1; -} - -message HandshakerReq { - oneof req_oneof { - // The start client handshake request message. - StartClientHandshakeReq client_start = 1; - - // The start server handshake request message. - StartServerHandshakeReq server_start = 2; - - // The next handshake request message. - NextHandshakeMessageReq next = 3; - } -} - -message HandshakerResult { - // The application protocol negotiated for this connection. - string application_protocol = 1; - - // The record protocol negotiated for this connection. - string record_protocol = 2; - - // Cryptographic key data. The key data may be more than the key length - // required for the record protocol, thus the client of the handshaker - // service needs to truncate the key data into the right key length. - bytes key_data = 3; - - // The authenticated identity of the peer. - Identity peer_identity = 4; - - // The local identity used in the handshake. - Identity local_identity = 5; - - // Indicate whether the handshaker service client should keep the channel - // between the handshaker service open, e.g., in order to handle - // post-handshake messages in the future. - bool keep_channel_open = 6; - - // The RPC protocol versions supported by the peer. - RpcProtocolVersions peer_rpc_versions = 7; - - // The maximum frame size of the peer. - uint32 max_frame_size = 8; -} - -message HandshakerStatus { - // The status code. This could be the gRPC status code. - uint32 code = 1; - - // The status details. - string details = 2; -} - -message HandshakerResp { - // Frames to be given to the peer for the NextHandshakeMessageReq. May be - // empty if no out_frames have to be sent to the peer or if in_bytes in the - // HandshakerReq are incomplete. All the non-empty out frames must be sent to - // the peer even if the handshaker status is not OK as these frames may - // contain the alert frames. - bytes out_frames = 1; - - // Number of bytes in the in_bytes consumed by the handshaker. It is possible - // that part of in_bytes in HandshakerReq was unrelated to the handshake - // process. - uint32 bytes_consumed = 2; - - // This is set iff the handshake was successful. out_frames may still be set - // to frames that needs to be forwarded to the peer. - HandshakerResult result = 3; - - // Status of the handshaker. - HandshakerStatus status = 4; -} - -service HandshakerService { - // Handshaker service accepts a stream of handshaker request, returning a - // stream of handshaker response. Client is expected to send exactly one - // message with either client_start or server_start followed by one or more - // messages with next. Each time client sends a request, the handshaker - // service expects to respond. Client does not have to wait for service's - // response before sending next request. - rpc DoHandshake(stream HandshakerReq) - returns (stream HandshakerResp) { - } -} diff --git a/contrib/libs/grpc/src/proto/grpc/gcp/transport_security_common.proto b/contrib/libs/grpc/src/proto/grpc/gcp/transport_security_common.proto deleted file mode 100644 index 8f01be79e3..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/gcp/transport_security_common.proto +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2018 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. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/gcp/transport_security_common.proto - -syntax = "proto3"; - -package grpc.gcp; - -option go_package = "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"; -option java_multiple_files = true; -option java_outer_classname = "TransportSecurityCommonProto"; -option java_package = "io.grpc.alts.internal"; - -// The security level of the created channel. The list is sorted in increasing -// level of security. This order must always be maintained. -enum SecurityLevel { - SECURITY_NONE = 0; - INTEGRITY_ONLY = 1; - INTEGRITY_AND_PRIVACY = 2; -} - -// Max and min supported RPC protocol versions. -message RpcProtocolVersions { - // RPC version contains a major version and a minor version. - message Version { - uint32 major = 1; - uint32 minor = 2; - } - // Maximum supported RPC version. - Version max_rpc_version = 1; - // Minimum supported RPC version. - Version min_rpc_version = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/health/v1/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/health/v1/.yandex_meta/licenses.list.txt deleted file mode 100644 index d841cd39fb..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/health/v1/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2015 The gRPC Authors diff --git a/contrib/libs/grpc/src/proto/grpc/lb/v1/load_balancer.proto b/contrib/libs/grpc/src/proto/grpc/lb/v1/load_balancer.proto deleted file mode 100644 index 00fc7096c9..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/lb/v1/load_balancer.proto +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2015 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. - -// This file defines the GRPCLB LoadBalancing protocol. -// -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/lb/v1/load_balancer.proto -syntax = "proto3"; - -package grpc.lb.v1; - -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1"; -option java_multiple_files = true; -option java_outer_classname = "LoadBalancerProto"; -option java_package = "io.grpc.lb.v1"; - -service LoadBalancer { - // Bidirectional rpc to get a list of servers. - rpc BalanceLoad(stream LoadBalanceRequest) returns (stream LoadBalanceResponse); -} - -message LoadBalanceRequest { - oneof load_balance_request_type { - // This message should be sent on the first request to the load balancer. - InitialLoadBalanceRequest initial_request = 1; - - // The client stats should be periodically reported to the load balancer - // based on the duration defined in the InitialLoadBalanceResponse. - ClientStats client_stats = 2; - } -} - -message InitialLoadBalanceRequest { - // The name of the load balanced service (e.g., service.googleapis.com). Its - // length should be less than 256 bytes. - // The name might include a port number. How to handle the port number is up - // to the balancer. - string name = 1; -} - -// Contains the number of calls finished for a particular load balance token. -message ClientStatsPerToken { - // See Server.load_balance_token. - string load_balance_token = 1; - - // The total number of RPCs that finished associated with the token. - int64 num_calls = 2; -} - -// Contains client level statistics that are useful to load balancing. Each -// count except the timestamp should be reset to zero after reporting the stats. -message ClientStats { - // The timestamp of generating the report. - google.protobuf.Timestamp timestamp = 1; - - // The total number of RPCs that started. - int64 num_calls_started = 2; - - // The total number of RPCs that finished. - int64 num_calls_finished = 3; - - // The total number of RPCs that failed to reach a server except dropped RPCs. - int64 num_calls_finished_with_client_failed_to_send = 6; - - // The total number of RPCs that finished and are known to have been received - // by a server. - int64 num_calls_finished_known_received = 7; - - // The list of dropped calls. - repeated ClientStatsPerToken calls_finished_with_drop = 8; - - reserved 4, 5; -} - -message LoadBalanceResponse { - oneof load_balance_response_type { - // This message should be sent on the first response to the client. - InitialLoadBalanceResponse initial_response = 1; - - // Contains the list of servers selected by the load balancer. The client - // should send requests to these servers in the specified order. - ServerList server_list = 2; - - // If this field is set, then the client should eagerly enter fallback - // mode (even if there are existing, healthy connections to backends). - FallbackResponse fallback_response = 3; - } -} - -message FallbackResponse {} - -message InitialLoadBalanceResponse { - reserved 1; // never-used load_balancer_delegate - - // This interval defines how often the client should send the client stats - // to the load balancer. Stats should only be reported when the duration is - // positive. - google.protobuf.Duration client_stats_report_interval = 2; -} - -message ServerList { - // Contains a list of servers selected by the load balancer. The list will - // be updated when server resolutions change or as needed to balance load - // across more servers. The client should consume the server list in order - // unless instructed otherwise via the client_config. - repeated Server servers = 1; - - // Was google.protobuf.Duration expiration_interval. - reserved 3; -} - -// Contains server information. When the drop field is not true, use the other -// fields. -message Server { - // A resolved address for the server, serialized in network-byte-order. It may - // either be an IPv4 or IPv6 address. - bytes ip_address = 1; - - // A resolved port number for the server. - int32 port = 2; - - // An opaque but printable token for load reporting. The client must include - // the token of the picked server into the initial metadata when it starts a - // call to that server. The token is used by the server to verify the request - // and to allow the server to report load to the gRPC LB system. The token is - // also used in client stats for reporting dropped calls. - // - // Its length can be variable but must be less than 50 bytes. - string load_balance_token = 3; - - // Indicates whether this particular request should be dropped by the client. - // If the request is dropped, there will be a corresponding entry in - // ClientStats.calls_finished_with_drop. - bool drop = 4; - - reserved 5; -} diff --git a/contrib/libs/grpc/src/proto/grpc/lb/v1/load_reporter.proto b/contrib/libs/grpc/src/proto/grpc/lb/v1/load_reporter.proto deleted file mode 100644 index d57a37fed7..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/lb/v1/load_reporter.proto +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package grpc.lb.v1; - -import "google/protobuf/duration.proto"; - -// The LoadReporter service. -service LoadReporter { - // Report load from server to lb. - rpc ReportLoad(stream LoadReportRequest) - returns (stream LoadReportResponse) { - }; -} - -message LoadReportRequest { - // This message should be sent on the first request to the gRPC server. - InitialLoadReportRequest initial_request = 1; -} - -message InitialLoadReportRequest { - // The hostname this load reporter client is requesting load for. - string load_balanced_hostname = 1; - - // Additional information to disambiguate orphaned load: load that should have - // gone to this load reporter client, but was not able to be sent since the - // load reporter client has disconnected. load_key is sent in orphaned load - // reports; see Load.load_key. - bytes load_key = 2; - - // This interval defines how often the server should send load reports to - // the load balancer. - google.protobuf.Duration load_report_interval = 3; -} - -message LoadReportResponse { - // This message should be sent on the first response to the load balancer. - InitialLoadReportResponse initial_response = 1; - - // Reports server-wide statistics for load balancing. - // This should be reported with every response. - LoadBalancingFeedback load_balancing_feedback = 2; - - // A load report for each <tag, user_id> tuple. This could be considered to be - // a multimap indexed by <tag, user_id>. It is not strictly necessary to - // aggregate all entries into one entry per <tag, user_id> tuple, although it - // is preferred to do so. - repeated Load load = 3; -} - -message InitialLoadReportResponse { - // Initial response returns the Load balancer ID. This must be plain text - // (printable ASCII). - string load_balancer_id = 1; - - enum ImplementationIdentifier { - IMPL_UNSPECIFIED = 0; - CPP = 1; // Standard Google C++ implementation. - JAVA = 2; // Standard Google Java implementation. - GO = 3; // Standard Google Go implementation. - } - // Optional identifier of this implementation of the load reporting server. - ImplementationIdentifier implementation_id = 2; - - // Optional server_version should be a value that is modified (and - // monotonically increased) when changes are made to the server - // implementation. - int64 server_version = 3; -} - -message LoadBalancingFeedback { - // Reports the current utilization of the server (typical range [0.0 - 1.0]). - float server_utilization = 1; - - // The total rate of calls handled by this server (including errors). - float calls_per_second = 2; - - // The total rate of error responses sent by this server. - float errors_per_second = 3; -} - -message Load { - // The (plain text) tag used by the calls covered by this load report. The - // tag is that part of the load balancer token after removing the load - // balancer id. Empty is equivalent to non-existent tag. - string load_balance_tag = 1; - - // The user identity authenticated by the calls covered by this load - // report. Empty is equivalent to no known user_id. - string user_id = 3; - - // IP address of the client that sent these requests, serialized in - // network-byte-order. It may either be an IPv4 or IPv6 address. - bytes client_ip_address = 15; - - // The number of calls started (since the last report) with the given tag and - // user_id. - int64 num_calls_started = 4; - - // Indicates whether this load report is an in-progress load report in which - // num_calls_in_progress is the only valid entry. If in_progress_report is not - // set, num_calls_in_progress will be ignored. If in_progress_report is set, - // fields other than num_calls_in_progress and orphaned_load will be ignored. - // TODO(juanlishen): A Load is either an in_progress_report or not. We should - // make this explicit in hierarchy. From the log, I see in_progress_report_ - // has a random num_calls_in_progress_ when not set, which might lead to bug - // when the balancer process the load report. - oneof in_progress_report { - // The number of calls in progress (instantaneously) per load balancer id. - int64 num_calls_in_progress = 5; - } - - // The following values are counts or totals of call statistics that finished - // with the given tag and user_id. - int64 num_calls_finished_without_error = 6; // Calls with status OK. - int64 num_calls_finished_with_error = 7; // Calls with status non-OK. - // Calls that finished with a status that maps to HTTP 5XX (see - // googleapis/google/rpc/code.proto). Note that this is a subset of - // num_calls_finished_with_error. - int64 num_calls_finished_with_server_error = 16; - - // Totals are from calls that with _and_ without error. - int64 total_bytes_sent = 8; - int64 total_bytes_received = 9; - google.protobuf.Duration total_latency = 10; - - // Optional metrics reported for the call(s). Requires that metric_name is - // unique. - repeated CallMetricData metric_data = 11; - - // The following two fields are used for reporting orphaned load: load that - // could not be reported to the originating balancer either since the balancer - // is no longer connected or because the frontend sent an invalid token. These - // fields must not be set with normal (unorphaned) load reports. - oneof orphaned_load { - // Load_key is the load_key from the initial_request from the originating - // balancer. - bytes load_key = 12 [deprecated=true]; - - // If true then this load report is for calls that had an invalid token; the - // user is probably abusing the gRPC protocol. - // TODO(yankaiz): Rename load_key_unknown. - bool load_key_unknown = 13; - - // load_key and balancer_id are included in order to identify orphaned load - // from different origins. - OrphanedLoadIdentifier orphaned_load_identifier = 14; - } - - reserved 2; -} - -message CallMetricData { - // Name of the metric; may be empty. - string metric_name = 1; - - // Number of calls that finished and included this metric. - int64 num_calls_finished_with_metric = 2; - - // Sum of metric values across all calls that finished with this metric. - double total_metric_value = 3; -} - -message OrphanedLoadIdentifier { - // The load_key from the initial_request from the originating balancer. - bytes load_key = 1; - - // The unique ID generated by LoadReporter to identify balancers. Here it - // distinguishes orphaned load with a same load_key. - string load_balancer_id = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls.proto b/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls.proto deleted file mode 100644 index 7d1735289d..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls.proto +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package grpc.lookup.v1; - -option go_package = "google.golang.org/grpc/lookup/grpc_lookup_v1"; -option java_multiple_files = true; -option java_package = "io.grpc.lookup.v1"; -option java_outer_classname = "RlsProto"; - -message RouteLookupRequest { - // Target type allows the client to specify what kind of target format it - // would like from RLS to allow it to find the regional server, e.g. "grpc". - string target_type = 3; - // Possible reasons for making a request. - enum Reason { - REASON_UNKNOWN = 0; // Unused - REASON_MISS = 1; // No data available in local cache - REASON_STALE = 2; // Data in local cache is stale - } - // Reason for making this request. - Reason reason = 5; - // For REASON_STALE, the header_data from the stale response, if any. - string stale_header_data = 6; - // Map of key values extracted via key builders for the gRPC or HTTP request. - map<string, string> key_map = 4; - - reserved 1, 2; - reserved "server", "path"; -} - -message RouteLookupResponse { - // Prioritized list (best one first) of addressable entities to use - // for routing, using syntax requested by the request target_type. - // The targets will be tried in order until a healthy one is found. - repeated string targets = 3; - // Optional header value to pass along to AFE in the X-Google-RLS-Data header. - // Cached with "target" and sent with all requests that match the request key. - // Allows the RLS to pass its work product to the eventual target. - string header_data = 2; - - reserved 1; - reserved "target"; -} - -service RouteLookupService { - // Lookup returns a target for a single key. - rpc RouteLookup(RouteLookupRequest) returns (RouteLookupResponse) {} -} diff --git a/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls_config.proto b/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls_config.proto deleted file mode 100644 index 9d2b6c54cf..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/lookup/v1/rls_config.proto +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package grpc.lookup.v1; - -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/grpc/lookup/grpc_lookup_v1"; -option java_multiple_files = true; -option java_package = "io.grpc.lookup.v1"; -option java_outer_classname = "RlsConfigProto"; - -// Extract a key based on a given name (e.g. header name or query parameter -// name). The name must match one of the names listed in the "name" field. If -// the "required_match" field is true, one of the specified names must be -// present for the keybuilder to match. -message NameMatcher { - // The name that will be used in the RLS key_map to refer to this value. - // If required_match is true, you may omit this field or set it to an empty - // string, in which case the matcher will require a match, but won't update - // the key_map. - string key = 1; - - // Ordered list of names (headers or query parameter names) that can supply - // this value; the first one with a non-empty value is used. - repeated string names = 2; - - // If true, make this extraction required; the key builder will not match - // if no value is found. - bool required_match = 3; -} - -// A GrpcKeyBuilder applies to a given gRPC service, name, and headers. -message GrpcKeyBuilder { - // To match, one of the given Name fields must match; the service and method - // fields are specified as fixed strings. The service name is required and - // includes the proto package name. The method name may be omitted, in - // which case any method on the given service is matched. - message Name { - string service = 1; - string method = 2; - } - repeated Name names = 1; - - // If you wish to include the host, service, or method names as keys in the - // generated RouteLookupRequest, specify key names to use in the extra_keys - // submessage. If a key name is empty, no key will be set for that value. - // If this submessage is specified, the normal host/path fields will be left - // unset in the RouteLookupRequest. We are deprecating host/path in the - // RouteLookupRequest, so services should migrate to the ExtraKeys approach. - message ExtraKeys { - string host = 1; - string service = 2; - string method = 3; - } - ExtraKeys extra_keys = 3; - - // Extract keys from all listed headers. - // For gRPC, it is an error to specify "required_match" on the NameMatcher - // protos. - repeated NameMatcher headers = 2; - - // You can optionally set one or more specific key/value pairs to be added to - // the key_map. This can be useful to identify which builder built the key, - // for example if you are suppressing the actual method, but need to - // separately cache and request all the matched methods. - map<string, string> constant_keys = 4; -} - -// An HttpKeyBuilder applies to a given HTTP URL and headers. -// -// Path and host patterns use the matching syntax from gRPC transcoding to -// extract named key/value pairs from the path and host components of the URL: -// https://github.com/googleapis/googleapis/blob/master/google/api/http.proto -// -// It is invalid to specify the same key name in multiple places in a pattern. -// -// For a service where the project id can be expressed either as a subdomain or -// in the path, separate HttpKeyBuilders must be used: -// host_pattern: 'example.com' path_pattern: '/{id}/{object}/**' -// host_pattern: '{id}.example.com' path_pattern: '/{object}/**' -// If the host is exactly 'example.com', the first path segment will be used as -// the id and the second segment as the object. If the host has a subdomain, the -// subdomain will be used as the id and the first segment as the object. If -// neither pattern matches, no keys will be extracted. -message HttpKeyBuilder { - // host_pattern is an ordered list of host template patterns for the desired - // value. If any host_pattern values are specified, then at least one must - // match, and the last one wins and sets any specified variables. A host - // consists of labels separated by dots. Each label is matched against the - // label in the pattern as follows: - // - "*": Matches any single label. - // - "**": Matches zero or more labels (first or last part of host only). - // - "{<name>=...}": One or more label capture, where "..." can be any - // template that does not include a capture. - // - "{<name>}": A single label capture. Identical to {<name>=*}. - // - // Examples: - // - "example.com": Only applies to the exact host example.com. - // - "*.example.com": Matches subdomains of example.com. - // - "**.example.com": matches example.com, and all levels of subdomains. - // - "{project}.example.com": Extracts the third level subdomain. - // - "{project=**}.example.com": Extracts the third level+ subdomains. - // - "{project=**}": Extracts the entire host. - repeated string host_patterns = 1; - - // path_pattern is an ordered list of path template patterns for the desired - // value. If any path_pattern values are specified, then at least one must - // match, and the last one wins and sets any specified variables. A path - // consists of segments separated by slashes. Each segment is matched against - // the segment in the pattern as follows: - // - "*": Matches any single segment. - // - "**": Matches zero or more segments (first or last part of path only). - // - "{<name>=...}": One or more segment capture, where "..." can be any - // template that does not include a capture. - // - "{<name>}": A single segment capture. Identical to {<name>=*}. - // A custom method may also be specified by appending ":" and the custom - // method name or "*" to indicate any custom method (including no custom - // method). For example, "/*/projects/{project_id}/**:*" extracts - // `{project_id}` for any version, resource and custom method that includes - // it. By default, any custom method will be matched. - // - // Examples: - // - "/v1/{name=messages/*}": extracts a name like "messages/12345". - // - "/v1/messages/{message_id}": extracts a message_id like "12345". - // - "/v1/users/{user_id}/messages/{message_id}": extracts two key values. - repeated string path_patterns = 2; - - // List of query parameter names to try to match. - // For example: ["parent", "name", "resource.name"] - // We extract all the specified query_parameters (case-sensitively). If any - // are marked as "required_match" and are not present, this keybuilder fails - // to match. If a given parameter appears multiple times (?foo=a&foo=b) we - // will report it as a comma-separated string (foo=a,b). - repeated NameMatcher query_parameters = 3; - - // List of headers to try to match. - // We extract all the specified header values (case-insensitively). If any - // are marked as "required_match" and are not present, this keybuilder fails - // to match. If a given header appears multiple times in the request we will - // report it as a comma-separated string, in standard HTTP fashion. - repeated NameMatcher headers = 4; - - // You can optionally set one or more specific key/value pairs to be added to - // the key_map. This can be useful to identify which builder built the key, - // for example if you are suppressing a lot of information from the URL, but - // need to separately cache and request URLs with that content. - map<string, string> constant_keys = 5; -} - -message RouteLookupConfig { - // Ordered specifications for constructing keys for HTTP requests. Last - // match wins. If no HttpKeyBuilder matches, an empty key_map will be sent to - // the lookup service; it should likely reply with a global default route - // and raise an alert. - repeated HttpKeyBuilder http_keybuilders = 1; - - // Unordered specifications for constructing keys for gRPC requests. All - // GrpcKeyBuilders on this list must have unique "name" fields so that the - // client is free to prebuild a hash map keyed by name. If no GrpcKeyBuilder - // matches, an empty key_map will be sent to the lookup service; it should - // likely reply with a global default route and raise an alert. - repeated GrpcKeyBuilder grpc_keybuilders = 2; - - // The name of the lookup service as a gRPC URI. Typically, this will be - // a subdomain of the target, such as "lookup.datastore.googleapis.com". - string lookup_service = 3; - - // Configure a timeout value for lookup service requests. - // Defaults to 10 seconds if not specified. - google.protobuf.Duration lookup_service_timeout = 4; - - // How long are responses valid for (like HTTP Cache-Control). - // If omitted or zero, the longest valid cache time is used. - // This value is clamped to 5 minutes to avoid unflushable bad responses. - google.protobuf.Duration max_age = 5; - - // After a response has been in the client cache for this amount of time - // and is re-requested, start an asynchronous RPC to re-validate it. - // This value should be less than max_age by at least the length of a - // typical RTT to the Route Lookup Service to fully mask the RTT latency. - // If omitted, keys are only re-requested after they have expired. - google.protobuf.Duration stale_age = 6; - - // Rough indicator of amount of memory to use for the client cache. Some of - // the data structure overhead is not accounted for, so actual memory consumed - // will be somewhat greater than this value. If this field is omitted or set - // to zero, a client default will be used. The value may be capped to a lower - // amount based on client configuration. - int64 cache_size_bytes = 7; - - // This is a list of all the possible targets that can be returned by the - // lookup service. If a target not on this list is returned, it will be - // treated the same as an unhealthy target. - repeated string valid_targets = 8; - - // This value provides a default target to use if needed. If set, it will be - // used if RLS returns an error, times out, or returns an invalid response. - // Note that requests can be routed only to a subdomain of the original - // target, e.g. "us_east_1.cloudbigtable.googleapis.com". - string default_target = 9; - - reserved 10; - reserved "request_processing_strategy"; -} - -// RouteLookupClusterSpecifier is used in xDS to represent a cluster specifier -// plugin for RLS. -message RouteLookupClusterSpecifier { - // The RLS config for this cluster specifier plugin instance. - RouteLookupConfig route_lookup_config = 1; -} diff --git a/contrib/libs/grpc/src/proto/grpc/reflection/v1/reflection.proto b/contrib/libs/grpc/src/proto/grpc/reflection/v1/reflection.proto deleted file mode 100644 index 1a2ceedc3d..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/reflection/v1/reflection.proto +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2016 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. - -// Service exported by server reflection. A more complete description of how -// server reflection works can be found at -// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md -// -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto - -syntax = "proto3"; - -package grpc.reflection.v1; - -option go_package = "google.golang.org/grpc/reflection/grpc_reflection_v1"; -option java_multiple_files = true; -option java_package = "io.grpc.reflection.v1"; -option java_outer_classname = "ServerReflectionProto"; - -service ServerReflection { - // The reflection service is structured as a bidirectional stream, ensuring - // all related requests go to a single server. - rpc ServerReflectionInfo(stream ServerReflectionRequest) - returns (stream ServerReflectionResponse); -} - -// The message sent by the client when calling ServerReflectionInfo method. -message ServerReflectionRequest { - string host = 1; - // To use reflection service, the client should set one of the following - // fields in message_request. The server distinguishes requests by their - // defined field and then handles them using corresponding methods. - oneof message_request { - // Find a proto file by the file name. - string file_by_filename = 3; - - // Find the proto file that declares the given fully-qualified symbol name. - // This field should be a fully-qualified symbol name - // (e.g. <package>.<service>[.<method>] or <package>.<type>). - string file_containing_symbol = 4; - - // Find the proto file which defines an extension extending the given - // message type with the given field number. - ExtensionRequest file_containing_extension = 5; - - // Finds the tag numbers used by all known extensions of the given message - // type, and appends them to ExtensionNumberResponse in an undefined order. - // Its corresponding method is best-effort: it's not guaranteed that the - // reflection service will implement this method, and it's not guaranteed - // that this method will provide all extensions. Returns - // StatusCode::UNIMPLEMENTED if it's not implemented. - // This field should be a fully-qualified type name. The format is - // <package>.<type> - string all_extension_numbers_of_type = 6; - - // List the full names of registered services. The content will not be - // checked. - string list_services = 7; - } -} - -// The type name and extension number sent by the client when requesting -// file_containing_extension. -message ExtensionRequest { - // Fully-qualified type name. The format should be <package>.<type> - string containing_type = 1; - int32 extension_number = 2; -} - -// The message sent by the server to answer ServerReflectionInfo method. -message ServerReflectionResponse { - string valid_host = 1; - ServerReflectionRequest original_request = 2; - // The server sets one of the following fields according to the message_request - // in the request. - oneof message_response { - // This message is used to answer file_by_filename, file_containing_symbol, - // file_containing_extension requests with transitive dependencies. - // As the repeated label is not allowed in oneof fields, we use a - // FileDescriptorResponse message to encapsulate the repeated fields. - // The reflection service is allowed to avoid sending FileDescriptorProtos - // that were previously sent in response to earlier requests in the stream. - FileDescriptorResponse file_descriptor_response = 4; - - // This message is used to answer all_extension_numbers_of_type requests. - ExtensionNumberResponse all_extension_numbers_response = 5; - - // This message is used to answer list_services requests. - ListServiceResponse list_services_response = 6; - - // This message is used when an error occurs. - ErrorResponse error_response = 7; - } -} - -// Serialized FileDescriptorProto messages sent by the server answering -// a file_by_filename, file_containing_symbol, or file_containing_extension -// request. -message FileDescriptorResponse { - // Serialized FileDescriptorProto messages. We avoid taking a dependency on - // descriptor.proto, which uses proto2 only features, by making them opaque - // bytes instead. - repeated bytes file_descriptor_proto = 1; -} - -// A list of extension numbers sent by the server answering -// all_extension_numbers_of_type request. -message ExtensionNumberResponse { - // Full name of the base type, including the package name. The format - // is <package>.<type> - string base_type_name = 1; - repeated int32 extension_number = 2; -} - -// A list of ServiceResponse sent by the server answering list_services request. -message ListServiceResponse { - // The information of each service may be expanded in the future, so we use - // ServiceResponse message to encapsulate it. - repeated ServiceResponse service = 1; -} - -// The information of a single service used by ListServiceResponse to answer -// list_services request. -message ServiceResponse { - // Full name of a registered service, including its package name. The format - // is <package>.<service> - string name = 1; -} - -// The error code and error message sent by the server when an error occurs. -message ErrorResponse { - // This field uses the error codes defined in grpc::StatusCode. - int32 error_code = 1; - string error_message = 2; -} - diff --git a/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/.yandex_meta/licenses.list.txt deleted file mode 100644 index 3b9a2903ee..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/reflection/v1alpha/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. diff --git a/contrib/libs/grpc/src/proto/grpc/status/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/status/.yandex_meta/licenses.list.txt deleted file mode 100644 index 724b968ab0..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/status/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2016 Google Inc. diff --git a/contrib/libs/grpc/src/proto/grpc/testing/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/testing/.yandex_meta/licenses.list.txt deleted file mode 100644 index e71f54ae94..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,32 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. diff --git a/contrib/libs/grpc/src/proto/grpc/testing/duplicate/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/testing/duplicate/.yandex_meta/licenses.list.txt deleted file mode 100644 index 4a6b5dd2d6..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/duplicate/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. diff --git a/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2.proto b/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2.proto deleted file mode 100644 index 666862e6c2..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2.proto +++ /dev/null @@ -1,22 +0,0 @@ - -// Copyright 2016 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -package grpc.testing.proto2; - -message EmptyWithExtensions { - extensions 100 to 999; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2_extensions.proto b/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2_extensions.proto deleted file mode 100644 index fca59f68c9..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/proto2/empty2_extensions.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -import "src/proto/grpc/testing/proto2/empty2.proto"; - -package grpc.testing.proto2; - -// Fill emptiness with music. -extend grpc.testing.proto2.EmptyWithExtensions { - optional int64 Deadmau5 = 124; - optional float Madeon = 125; - optional string AboveAndBeyond = 126; - optional bool Tycho = 127; - optional fixed64 Pendulum = 128; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/proto/grpc/testing/xds/.yandex_meta/licenses.list.txt deleted file mode 100644 index a8fd056f8c..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,24 +0,0 @@ -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2019 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 The gRPC Authors diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/address.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/address.proto deleted file mode 100644 index 47efbed8e0..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/address.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.core.v3; - -import "google/protobuf/wrappers.proto"; - -// [#protodoc-title: Network addresses] - -// [#next-free-field: 7] -message SocketAddress { - // The address for this socket. :ref:`Listeners <config_listeners>` will bind - // to the address. An empty address is not allowed. Specify ``0.0.0.0`` or ``::`` - // to bind to any address. [#comment:TODO(zuercher) reinstate when implemented: - // It is possible to distinguish a Listener address via the prefix/suffix matching - // in :ref:`FilterChainMatch <envoy_api_msg_config.listener.v3.FilterChainMatch>`.] When used - // within an upstream :ref:`BindConfig <envoy_api_msg_config.core.v3.BindConfig>`, the address - // controls the source address of outbound connections. For :ref:`clusters - // <envoy_api_msg_config.cluster.v3.Cluster>`, the cluster type determines whether the - // address must be an IP (*STATIC* or *EDS* clusters) or a hostname resolved by DNS - // (*STRICT_DNS* or *LOGICAL_DNS* clusters). Address resolution can be customized - // via :ref:`resolver_name <envoy_api_field_config.core.v3.SocketAddress.resolver_name>`. - string address = 2; - - oneof port_specifier { - uint32 port_value = 3; - } - - // The name of the custom resolver. This must have been registered with Envoy. If - // this is empty, a context dependent default applies. If the address is a concrete - // IP address, no resolution will occur. If address is a hostname this - // should be set for resolution other than DNS. Specifying a custom resolver with - // *STRICT_DNS* or *LOGICAL_DNS* will generate an error at runtime. - string resolver_name = 5; -} - -// Addresses specify either a logical or physical address and port, which are -// used to tell Envoy where to bind/listen, connect to upstream and find -// management servers. -message Address { - oneof address { - SocketAddress socket_address = 1; - } -} - -// CidrRange specifies an IP Address and a prefix length to construct -// the subnet mask for a `CIDR <https://tools.ietf.org/html/rfc4632>`_ range. -message CidrRange { - // IPv4 or IPv6 address, e.g. ``192.0.0.0`` or ``2001:db8::``. - string address_prefix = 1; - - // Length of prefix, e.g. 0, 32. - google.protobuf.UInt32Value prefix_len = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/ads.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/ads.proto deleted file mode 100644 index 4688aeedb2..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/ads.proto +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.service.discovery.v3; - -import "src/proto/grpc/testing/xds/v3/discovery.proto"; - -// [#protodoc-title: Aggregated Discovery Service (ADS)] - -// [#not-implemented-hide:] Discovery services for endpoints, clusters, routes, -// and listeners are retained in the package `envoy.api.v2` for backwards -// compatibility with existing management servers. New development in discovery -// services should proceed in the package `envoy.service.discovery.v2`. - -// See https://github.com/lyft/envoy-api#apis for a description of the role of -// ADS and how it is intended to be used by a management server. ADS requests -// have the same structure as their singleton xDS counterparts, but can -// multiplex many resource types on a single stream. The type_url in the -// DiscoveryRequest/DiscoveryResponse provides sufficient information to recover -// the multiplexed singleton APIs at the Envoy instance and management server. -service AggregatedDiscoveryService { - // This is a gRPC-only API. - rpc StreamAggregatedResources(stream DiscoveryRequest) returns (stream DiscoveryResponse) { - } -} - -// [#not-implemented-hide:] Not configuration. Workaround c++ protobuf issue with importing -// services: https://github.com/protocolbuffers/protobuf/issues/4221 -message AdsPhony { -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/aggregate_cluster.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/aggregate_cluster.proto deleted file mode 100644 index d14ad350ba..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/aggregate_cluster.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.clusters.aggregate.v3; - -// Configuration for the aggregate cluster. See the :ref:`architecture overview -// <arch_overview_aggregate_cluster>` for more information. -// [#extension: envoy.clusters.aggregate] -message ClusterConfig { - // Load balancing clusters in aggregate cluster. Clusters are prioritized based on the order they - // appear in this list. - repeated string clusters = 1; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/base.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/base.proto deleted file mode 100644 index 33719f687c..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/base.proto +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.core.v3; - -import "src/proto/grpc/testing/xds/v3/percent.proto"; - -import "google/protobuf/any.proto"; -import "google/protobuf/struct.proto"; - -// Identifies location of where either Envoy runs or where upstream hosts run. -message Locality { - // Region this :ref:`zone <envoy_api_field_config.core.v3.Locality.zone>` belongs to. - string region = 1; - - // Defines the local service zone where Envoy is running. Though optional, it - // should be set if discovery service routing is used and the discovery - // service exposes :ref:`zone data <envoy_api_field_config.endpoint.v3.LocalityLbEndpoints.locality>`, - // either in this message or via :option:`--service-zone`. The meaning of zone - // is context dependent, e.g. `Availability Zone (AZ) - // <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html>`_ - // on AWS, `Zone <https://cloud.google.com/compute/docs/regions-zones/>`_ on - // GCP, etc. - string zone = 2; - - // When used for locality of upstream hosts, this field further splits zone - // into smaller chunks of sub-zones so they can be load balanced - // independently. - string sub_zone = 3; -} - -// Identifies a specific Envoy instance. The node identifier is presented to the -// management server, which may use this identifier to distinguish per Envoy -// configuration for serving. -// [#next-free-field: 12] -message Node { - // An opaque node identifier for the Envoy node. This also provides the local - // service node name. It should be set if any of the following features are - // used: :ref:`statsd <arch_overview_statistics>`, :ref:`CDS - // <config_cluster_manager_cds>`, and :ref:`HTTP tracing - // <arch_overview_tracing>`, either in this message or via - // :option:`--service-node`. - string id = 1; - - // Defines the local service cluster name where Envoy is running. Though - // optional, it should be set if any of the following features are used: - // :ref:`statsd <arch_overview_statistics>`, :ref:`health check cluster - // verification - // <envoy_api_field_config.core.v3.HealthCheck.HttpHealthCheck.service_name_matcher>`, - // :ref:`runtime override directory <envoy_api_msg_config.bootstrap.v3.Runtime>`, - // :ref:`user agent addition - // <envoy_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.add_user_agent>`, - // :ref:`HTTP global rate limiting <config_http_filters_rate_limit>`, - // :ref:`CDS <config_cluster_manager_cds>`, and :ref:`HTTP tracing - // <arch_overview_tracing>`, either in this message or via - // :option:`--service-cluster`. - string cluster = 2; - - // Opaque metadata extending the node identifier. Envoy will pass this - // directly to the management server. - google.protobuf.Struct metadata = 3; - - // Locality specifying where the Envoy instance is running. - Locality locality = 4; - - // Free-form string that identifies the entity requesting config. - // E.g. "envoy" or "grpc" - string user_agent_name = 6; - - oneof user_agent_version_type { - // Free-form string that identifies the version of the entity requesting config. - // E.g. "1.12.2" or "abcd1234", or "SpecialEnvoyBuild" - string user_agent_version = 7; - } - - // Client feature support list. These are well known features described - // in the Envoy API repository for a given major version of an API. Client features - // use reverse DNS naming scheme, for example `com.acme.feature`. - // See :ref:`the list of features <client_features>` that xDS client may - // support. - repeated string client_features = 10; -} - -// Data source consisting of either a file or an inline value. -message DataSource {} - -// Runtime derived FractionalPercent with defaults for when the numerator or denominator is not -// specified via a runtime key. -// -// .. note:: -// -// Parsing of the runtime key's data is implemented such that it may be represented as a -// :ref:`FractionalPercent <envoy_api_msg_type.v3.FractionalPercent>` proto represented as JSON/YAML -// and may also be represented as an integer with the assumption that the value is an integral -// percentage out of 100. For instance, a runtime key lookup returning the value "42" would parse -// as a `FractionalPercent` whose numerator is 42 and denominator is HUNDRED. -message RuntimeFractionalPercent { - // Default value if the runtime value's for the numerator/denominator keys are not available. - type.v3.FractionalPercent default_value = 1; -} - -// Configuration for transport socket in :ref:`listeners <config_listeners>` and -// :ref:`clusters <envoy_api_msg_config.cluster.v3.Cluster>`. If the configuration is -// empty, a default transport socket implementation and configuration will be -// chosen based on the platform and existence of tls_context. -message TransportSocket { - // The name of the transport socket to instantiate. The name must match a supported transport - // socket implementation. - string name = 1; - - // Implementation specific configuration which depends on the implementation being instantiated. - // See the supported transport socket implementations for further documentation. - oneof config_type { - google.protobuf.Any typed_config = 3; - } -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/cluster.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/cluster.proto deleted file mode 100644 index 1bc2d51b50..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/cluster.proto +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.cluster.v3; - -import "src/proto/grpc/testing/xds/v3/base.proto"; -import "src/proto/grpc/testing/xds/v3/config_source.proto"; -import "src/proto/grpc/testing/xds/v3/endpoint.proto"; - -import "google/protobuf/any.proto"; -import "google/protobuf/wrappers.proto"; - -enum RoutingPriority { - DEFAULT = 0; - HIGH = 1; -} - -message CircuitBreakers { - message Thresholds { - RoutingPriority priority = 1; - google.protobuf.UInt32Value max_requests = 4; - } - repeated Thresholds thresholds = 1; -} - -// Extended cluster type. -message CustomClusterType { - // The type of the cluster to instantiate. The name must match a supported cluster type. - string name = 1; - - // Cluster specific configuration which depends on the cluster being instantiated. - // See the supported cluster for further documentation. - google.protobuf.Any typed_config = 2; -} - -// [#protodoc-title: Cluster configuration] - -// Configuration for a single upstream cluster. -// [#next-free-field: 48] -message Cluster { - // Refer to :ref:`service discovery type <arch_overview_service_discovery_types>` - // for an explanation on each type. - enum DiscoveryType { - // Refer to the :ref:`static discovery type<arch_overview_service_discovery_types_static>` - // for an explanation. - STATIC = 0; - - // Refer to the :ref:`strict DNS discovery - // type<arch_overview_service_discovery_types_strict_dns>` - // for an explanation. - STRICT_DNS = 1; - - // Refer to the :ref:`logical DNS discovery - // type<arch_overview_service_discovery_types_logical_dns>` - // for an explanation. - LOGICAL_DNS = 2; - - // Refer to the :ref:`service discovery type<arch_overview_service_discovery_types_eds>` - // for an explanation. - EDS = 3; - - // Refer to the :ref:`original destination discovery - // type<arch_overview_service_discovery_types_original_destination>` - // for an explanation. - ORIGINAL_DST = 4; - } - - // Refer to :ref:`load balancer type <arch_overview_load_balancing_types>` architecture - // overview section for information on each type. - enum LbPolicy { - reserved 4; - - reserved "ORIGINAL_DST_LB"; - - // Refer to the :ref:`round robin load balancing - // policy<arch_overview_load_balancing_types_round_robin>` - // for an explanation. - ROUND_ROBIN = 0; - - // Refer to the :ref:`least request load balancing - // policy<arch_overview_load_balancing_types_least_request>` - // for an explanation. - LEAST_REQUEST = 1; - - // Refer to the :ref:`ring hash load balancing - // policy<arch_overview_load_balancing_types_ring_hash>` - // for an explanation. - RING_HASH = 2; - - // Refer to the :ref:`random load balancing - // policy<arch_overview_load_balancing_types_random>` - // for an explanation. - RANDOM = 3; - - // Refer to the :ref:`Maglev load balancing policy<arch_overview_load_balancing_types_maglev>` - // for an explanation. - MAGLEV = 5; - - // This load balancer type must be specified if the configured cluster provides a cluster - // specific load balancer. Consult the configured cluster's documentation for whether to set - // this option or not. - CLUSTER_PROVIDED = 6; - - // [#not-implemented-hide:] Use the new :ref:`load_balancing_policy - // <envoy_api_field_config.cluster.v3.Cluster.load_balancing_policy>` field to determine the LB policy. - // [#next-major-version: In the v3 API, we should consider deprecating the lb_policy field - // and instead using the new load_balancing_policy field as the one and only mechanism for - // configuring this.] - LOAD_BALANCING_POLICY_CONFIG = 7; - } - - // Only valid when discovery type is EDS. - message EdsClusterConfig { - // Configuration for the source of EDS updates for this Cluster. - core.v3.ConfigSource eds_config = 1; - - // Optional alternative to cluster name to present to EDS. This does not - // have the same restrictions as cluster name, i.e. it may be arbitrary - // length. - string service_name = 2; - } - - // Supplies the name of the cluster which must be unique across all clusters. - // The cluster name is used when emitting - // :ref:`statistics <config_cluster_manager_cluster_stats>` if :ref:`alt_stat_name - // <envoy_api_field_config.cluster.v3.Cluster.alt_stat_name>` is not provided. - // Any ``:`` in the cluster name will be converted to ``_`` when emitting statistics. - string name = 1; - - oneof cluster_discovery_type { - // The :ref:`service discovery type <arch_overview_service_discovery_types>` - // to use for resolving the cluster. - DiscoveryType type = 2; - - // The custom cluster type. - CustomClusterType cluster_type = 38; - } - - // Configuration to use for EDS updates for the Cluster. - EdsClusterConfig eds_cluster_config = 3; - - // Specific configuration for the :ref:`RingHash<arch_overview_load_balancing_types_ring_hash>` - // load balancing policy. - message RingHashLbConfig { - // The hash function used to hash hosts onto the ketama ring. - enum HashFunction { - // Use `xxHash <https://github.com/Cyan4973/xxHash>`_, this is the default hash function. - XX_HASH = 0; - MURMUR_HASH_2 = 1; - } - - reserved 2; - - // Minimum hash ring size. The larger the ring is (that is, the more hashes there are for each - // provided host) the better the request distribution will reflect the desired weights. Defaults - // to 1024 entries, and limited to 8M entries. See also - // :ref:`maximum_ring_size<envoy_api_field_config.cluster.v3.Cluster.RingHashLbConfig.maximum_ring_size>`. - google.protobuf.UInt64Value minimum_ring_size = 1; - - // The hash function used to hash hosts onto the ketama ring. The value defaults to - // :ref:`XX_HASH<envoy_api_enum_value_config.cluster.v3.Cluster.RingHashLbConfig.HashFunction.XX_HASH>`. - HashFunction hash_function = 3; - - // Maximum hash ring size. Defaults to 8M entries, and limited to 8M entries, but can be lowered - // to further constrain resource use. See also - // :ref:`minimum_ring_size<envoy_api_field_config.cluster.v3.Cluster.RingHashLbConfig.minimum_ring_size>`. - google.protobuf.UInt64Value maximum_ring_size = 4; - } - - // The :ref:`load balancer type <arch_overview_load_balancing_types>` to use - // when picking a host in the cluster. - LbPolicy lb_policy = 6; - - // Setting this is required for specifying members of - // :ref:`STATIC<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.STATIC>`, - // :ref:`STRICT_DNS<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.STRICT_DNS>` - // or :ref:`LOGICAL_DNS<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.LOGICAL_DNS>` clusters. - // This field supersedes the *hosts* field in the v2 API. - // - // .. attention:: - // - // Setting this allows non-EDS cluster types to contain embedded EDS equivalent - // :ref:`endpoint assignments<envoy_api_msg_config.endpoint.v3.ClusterLoadAssignment>`. - // - endpoint.v3.ClusterLoadAssignment load_assignment = 33; - - CircuitBreakers circuit_breakers = 10; - - // Optional configuration for the load balancing algorithm selected by - // LbPolicy. Currently only - // :ref:`RING_HASH<envoy_api_enum_value_config.cluster.v3.Cluster.LbPolicy.RING_HASH>`, - // Specifying ring_hash_lb_config without setting the corresponding - // LbPolicy will generate an error at runtime. - oneof lb_config { - // Optional configuration for the Ring Hash load balancing policy. - RingHashLbConfig ring_hash_lb_config = 23; - } - - // Optional custom transport socket implementation to use for upstream connections. - // To setup TLS, set a transport socket with name `tls` and - // :ref:`UpstreamTlsContexts <envoy_api_msg_extensions.transport_sockets.tls.v3.UpstreamTlsContext>` in the `typed_config`. - // If no transport socket configuration is specified, new connections - // will be set up with plaintext. - core.v3.TransportSocket transport_socket = 24; - - // [#not-implemented-hide:] - // If present, tells the client where to send load reports via LRS. If not present, the - // client will fall back to a client-side default, which may be either (a) don't send any - // load reports or (b) send load reports for all clusters to a single default server - // (which may be configured in the bootstrap file). - // - // Note that if multiple clusters point to the same LRS server, the client may choose to - // create a separate stream for each cluster or it may choose to coalesce the data for - // multiple clusters onto a single stream. Either way, the client must make sure to send - // the data for any given cluster on no more than one stream. - // - // [#next-major-version: In the v3 API, we should consider restructuring this somehow, - // maybe by allowing LRS to go on the ADS stream, or maybe by moving some of the negotiation - // from the LRS stream here.] - core.v3.ConfigSource lrs_server = 42; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_dump.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_dump.proto deleted file mode 100644 index d69b3109aa..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_dump.proto +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright 2021 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.admin.v3; - -import "google/protobuf/any.proto"; -import "google/protobuf/timestamp.proto"; - -// Resource status from the view of a xDS client, which tells the synchronization -// status between the xDS client and the xDS server. -enum ClientResourceStatus { - // Resource status is not available/unknown. - UNKNOWN = 0; - - // Client requested this resource but hasn't received any update from management - // server. The client will not fail requests, but will queue them until update - // arrives or the client times out waiting for the resource. - REQUESTED = 1; - - // This resource has been requested by the client but has either not been - // delivered by the server or was previously delivered by the server and then - // subsequently removed from resources provided by the server. For more - // information, please refer to the :ref:`"Knowing When a Requested Resource - // Does Not Exist" <xds_protocol_resource_not_existed>` section. - DOES_NOT_EXIST = 2; - - // Client received this resource and replied with ACK. - ACKED = 3; - - // Client received this resource and replied with NACK. - NACKED = 4; -} - -message UpdateFailureState { - // What the component configuration would have been if the update had succeeded. - // This field may not be populated by xDS clients due to storage overhead. - google.protobuf.Any failed_configuration = 1; - - // Time of the latest failed update attempt. - google.protobuf.Timestamp last_update_attempt = 2; - - // Details about the last failed update attempt. - string details = 3; - - // This is the version of the rejected resource. - // [#not-implemented-hide:] - string version_info = 4; -} - -// Envoy's listener manager fills this message with all currently known listeners. Listener -// configuration information can be used to recreate an Envoy configuration by populating all -// listeners as static listeners or by returning them in a LDS response. -message ListenersConfigDump { - // Describes a statically loaded listener. - message StaticListener { - // The listener config. - google.protobuf.Any listener = 1; - - // The timestamp when the Listener was last successfully updated. - google.protobuf.Timestamp last_updated = 2; - } - - message DynamicListenerState { - // This is the per-resource version information. This version is currently taken from the - // :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time - // that the listener was loaded. In the future, discrete per-listener versions may be supported - // by the API. - string version_info = 1; - - // The listener config. - google.protobuf.Any listener = 2; - - // The timestamp when the Listener was last successfully updated. - google.protobuf.Timestamp last_updated = 3; - } - - // Describes a dynamically loaded listener via the LDS API. - // [#next-free-field: 7] - message DynamicListener { - // The name or unique id of this listener, pulled from the DynamicListenerState config. - string name = 1; - - // The listener state for any active listener by this name. - // These are listeners that are available to service data plane traffic. - DynamicListenerState active_state = 2; - - // The listener state for any warming listener by this name. - // These are listeners that are currently undergoing warming in preparation to service data - // plane traffic. Note that if attempting to recreate an Envoy configuration from a - // configuration dump, the warming listeners should generally be discarded. - DynamicListenerState warming_state = 3; - - // The listener state for any draining listener by this name. - // These are listeners that are currently undergoing draining in preparation to stop servicing - // data plane traffic. Note that if attempting to recreate an Envoy configuration from a - // configuration dump, the draining listeners should generally be discarded. - DynamicListenerState draining_state = 4; - - // Set if the last update failed, cleared after the next successful update. - // The *error_state* field contains the rejected version of this particular - // resource along with the reason and timestamp. For successfully updated or - // acknowledged resource, this field should be empty. - UpdateFailureState error_state = 5; - - // The client status of this resource. - // [#not-implemented-hide:] - ClientResourceStatus client_status = 6; - } - - // This is the :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` in the - // last processed LDS discovery response. If there are only static bootstrap listeners, this field - // will be "". - string version_info = 1; - - // The statically loaded listener configs. - repeated StaticListener static_listeners = 2; - - // State for any warming, active, or draining listeners. - repeated DynamicListener dynamic_listeners = 3; -} - -// Envoy's cluster manager fills this message with all currently known clusters. Cluster -// configuration information can be used to recreate an Envoy configuration by populating all -// clusters as static clusters or by returning them in a CDS response. -message ClustersConfigDump { - // Describes a statically loaded cluster. - message StaticCluster { - // The cluster config. - google.protobuf.Any cluster = 1; - - // The timestamp when the Cluster was last updated. - google.protobuf.Timestamp last_updated = 2; - } - - // Describes a dynamically loaded cluster via the CDS API. - // [#next-free-field: 6] - message DynamicCluster { - // This is the per-resource version information. This version is currently taken from the - // :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time - // that the cluster was loaded. In the future, discrete per-cluster versions may be supported by - // the API. - string version_info = 1; - - // The cluster config. - google.protobuf.Any cluster = 2; - - // The timestamp when the Cluster was last updated. - google.protobuf.Timestamp last_updated = 3; - - // Set if the last update failed, cleared after the next successful update. - // The *error_state* field contains the rejected version of this particular - // resource along with the reason and timestamp. For successfully updated or - // acknowledged resource, this field should be empty. - // [#not-implemented-hide:] - UpdateFailureState error_state = 4; - - // The client status of this resource. - // [#not-implemented-hide:] - ClientResourceStatus client_status = 5; - } - - // This is the :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` in the - // last processed CDS discovery response. If there are only static bootstrap clusters, this field - // will be "". - string version_info = 1; - - // The statically loaded cluster configs. - repeated StaticCluster static_clusters = 2; - - // The dynamically loaded active clusters. These are clusters that are available to service - // data plane traffic. - repeated DynamicCluster dynamic_active_clusters = 3; - - // The dynamically loaded warming clusters. These are clusters that are currently undergoing - // warming in preparation to service data plane traffic. Note that if attempting to recreate an - // Envoy configuration from a configuration dump, the warming clusters should generally be - // discarded. - repeated DynamicCluster dynamic_warming_clusters = 4; -} - -// Envoy's RDS implementation fills this message with all currently loaded routes, as described by -// their RouteConfiguration objects. Static routes that are either defined in the bootstrap configuration -// or defined inline while configuring listeners are separated from those configured dynamically via RDS. -// Route configuration information can be used to recreate an Envoy configuration by populating all routes -// as static routes or by returning them in RDS responses. -message RoutesConfigDump { - message StaticRouteConfig { - // The route config. - google.protobuf.Any route_config = 1; - - // The timestamp when the Route was last updated. - google.protobuf.Timestamp last_updated = 2; - } - - // [#next-free-field: 6] - message DynamicRouteConfig { - // This is the per-resource version information. This version is currently taken from the - // :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time that - // the route configuration was loaded. - string version_info = 1; - - // The route config. - google.protobuf.Any route_config = 2; - - // The timestamp when the Route was last updated. - google.protobuf.Timestamp last_updated = 3; - - // Set if the last update failed, cleared after the next successful update. - // The *error_state* field contains the rejected version of this particular - // resource along with the reason and timestamp. For successfully updated or - // acknowledged resource, this field should be empty. - // [#not-implemented-hide:] - UpdateFailureState error_state = 4; - - // The client status of this resource. - // [#not-implemented-hide:] - ClientResourceStatus client_status = 5; - } - - // The statically loaded route configs. - repeated StaticRouteConfig static_route_configs = 2; - - // The dynamically loaded route configs. - repeated DynamicRouteConfig dynamic_route_configs = 3; -} - -// Envoy's admin fill this message with all currently known endpoints. Endpoint -// configuration information can be used to recreate an Envoy configuration by populating all -// endpoints as static endpoints or by returning them in an EDS response. -message EndpointsConfigDump { - message StaticEndpointConfig { - // The endpoint config. - google.protobuf.Any endpoint_config = 1; - - // [#not-implemented-hide:] The timestamp when the Endpoint was last updated. - google.protobuf.Timestamp last_updated = 2; - } - - // [#next-free-field: 6] - message DynamicEndpointConfig { - // [#not-implemented-hide:] This is the per-resource version information. This version is currently taken from the - // :ref:`version_info <envoy_api_field_service.discovery.v3.DiscoveryResponse.version_info>` field at the time that - // the endpoint configuration was loaded. - string version_info = 1; - - // The endpoint config. - google.protobuf.Any endpoint_config = 2; - - // [#not-implemented-hide:] The timestamp when the Endpoint was last updated. - google.protobuf.Timestamp last_updated = 3; - - // Set if the last update failed, cleared after the next successful update. - // The *error_state* field contains the rejected version of this particular - // resource along with the reason and timestamp. For successfully updated or - // acknowledged resource, this field should be empty. - // [#not-implemented-hide:] - UpdateFailureState error_state = 4; - - // The client status of this resource. - // [#not-implemented-hide:] - ClientResourceStatus client_status = 5; - } - - // The statically loaded endpoint configs. - repeated StaticEndpointConfig static_endpoint_configs = 2; - - // The dynamically loaded endpoint configs. - repeated DynamicEndpointConfig dynamic_endpoint_configs = 3; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_source.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_source.proto deleted file mode 100644 index 487b79c00a..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/config_source.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.core.v3; - -// [#protodoc-title: Configuration sources] - -// Aggregated Discovery Service (ADS) options. This is currently empty, but when -// set in :ref:`ConfigSource <envoy_api_msg_config.core.v3.ConfigSource>` can be used to -// specify that ADS is to be used. -message AggregatedConfigSource { -} - -// [#not-implemented-hide:] -// Self-referencing config source options. This is currently empty, but when -// set in :ref:`ConfigSource <envoy_api_msg_config.core.v3.ConfigSource>` can be used to -// specify that other data can be obtained from the same server. -message SelfConfigSource { -} - -// Configuration for :ref:`listeners <config_listeners>`, :ref:`clusters -// <config_cluster_manager>`, :ref:`routes -// <envoy_api_msg_config.route.v3.RouteConfiguration>`, :ref:`endpoints -// <arch_overview_service_discovery>` etc. may either be sourced from the -// filesystem or from an xDS API source. Filesystem configs are watched with -// inotify for updates. -// [#next-free-field: 7] -message ConfigSource { - oneof config_source_specifier { - // Path on the filesystem to source and watch for configuration updates. - // When sourcing configuration for :ref:`secret <envoy_api_msg_extensions.transport_sockets.tls.v3.Secret>`, - // the certificate and key files are also watched for updates. - // - // .. note:: - // - // The path to the source must exist at config load time. - // - // .. note:: - // - // Envoy will only watch the file path for *moves.* This is because in general only moves - // are atomic. The same method of swapping files as is demonstrated in the - // :ref:`runtime documentation <config_runtime_symbolic_link_swap>` can be used here also. - string path = 1; - - // When set, ADS will be used to fetch resources. The ADS API configuration - // source in the bootstrap configuration is used. - AggregatedConfigSource ads = 3; - - // [#not-implemented-hide:] - // When set, the client will access the resources from the same server it got the - // ConfigSource from, although not necessarily from the same stream. This is similar to the - // :ref:`ads<envoy_api_field.ConfigSource.ads>` field, except that the client may use a - // different stream to the same server. As a result, this field can be used for things - // like LRS that cannot be sent on an ADS stream. It can also be used to link from (e.g.) - // LDS to RDS on the same server without requiring the management server to know its name - // or required credentials. - // [#next-major-version: In xDS v3, consider replacing the ads field with this one, since - // this field can implicitly mean to use the same stream in the case where the ConfigSource - // is provided via ADS and the specified data can also be obtained via ADS.] - SelfConfigSource self = 5; - } -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/csds.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/csds.proto deleted file mode 100644 index 79b8bc8b64..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/csds.proto +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2021 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.service.status.v3; - -import "src/proto/grpc/testing/xds/v3/config_dump.proto"; -import "src/proto/grpc/testing/xds/v3/base.proto"; - -import "google/protobuf/any.proto"; -import "google/protobuf/timestamp.proto"; - - -// CSDS is Client Status Discovery Service. It can be used to get the status of -// an xDS-compliant client from the management server's point of view. It can -// also be used to get the current xDS states directly from the client. -service ClientStatusDiscoveryService { - rpc StreamClientStatus(stream ClientStatusRequest) returns (stream ClientStatusResponse) {} - rpc FetchClientStatus(ClientStatusRequest) returns (ClientStatusResponse) {} -} - -// Status of a config from a management server view. -enum ConfigStatus { - // Status info is not available/unknown. - UNKNOWN = 0; - - // Management server has sent the config to client and received ACK. - SYNCED = 1; - - // Config is not sent. - NOT_SENT = 2; - - // Management server has sent the config to client but hasn’t received - // ACK/NACK. - STALE = 3; - - // Management server has sent the config to client but received NACK. The - // attached config dump will be the latest config (the rejected one), since - // it is the persisted version in the management server. - ERROR = 4; -} - -// Request for client status of clients identified by a list of NodeMatchers. -message ClientStatusRequest { - // The node making the csds request. - config.core.v3.Node node = 2; -} - -// Detailed config (per xDS) with status. -// [#next-free-field: 8] -message PerXdsConfig { - // Config status generated by management servers. Will not be present if the - // CSDS server is an xDS client. - ConfigStatus status = 1; - - oneof per_xds_config { - admin.v3.ListenersConfigDump listener_config = 2; - - admin.v3.ClustersConfigDump cluster_config = 3; - - admin.v3.RoutesConfigDump route_config = 4; - - admin.v3.EndpointsConfigDump endpoint_config = 6; - } -} - -// All xds configs for a particular client. -message ClientConfig { - // GenericXdsConfig is used to specify the config status and the dump - // of any xDS resource identified by their type URL. It is the generalized - // version of the now deprecated ListenersConfigDump, ClustersConfigDump etc - // [#next-free-field: 10] - message GenericXdsConfig { - // Type_url represents the fully qualified name of xDS resource type - // like envoy.v3.Cluster, envoy.v3.ClusterLoadAssignment etc. - string type_url = 1; - - // Name of the xDS resource - string name = 2; - - // This is the :ref:`version_info <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>` - // in the last processed xDS discovery response. If there are only - // static bootstrap listeners, this field will be "" - string version_info = 3; - - // The xDS resource config. Actual content depends on the type - google.protobuf.Any xds_config = 4; - - // Timestamp when the xDS resource was last updated - google.protobuf.Timestamp last_updated = 5; - - // Per xDS resource config status. It is generated by management servers. - // It will not be present if the CSDS server is an xDS client. - ConfigStatus config_status = 6; - - // Per xDS resource status from the view of a xDS client - admin.v3.ClientResourceStatus client_status = 7; - - // Set if the last update failed, cleared after the next successful - // update. The *error_state* field contains the rejected version of - // this particular resource along with the reason and timestamp. For - // successfully updated or acknowledged resource, this field should - // be empty. - admin.v3.UpdateFailureState error_state = 8; - - // Is static resource is true if it is specified in the config supplied - // through the file at the startup. - bool is_static_resource = 9; - } - - // Node for a particular client. - config.core.v3.Node node = 1; - - // This field is deprecated in favor of generic_xds_configs which is - // much simpler and uniform in structure. - repeated PerXdsConfig xds_config = 2 [deprecated = true]; - - // Represents generic xDS config and the exact config structure depends on - // the type URL (like Cluster if it is CDS) - repeated GenericXdsConfig generic_xds_configs = 3; -} - -message ClientStatusResponse { - // Client configs for the clients specified in the ClientStatusRequest. - repeated ClientConfig config = 1; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/discovery.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/discovery.proto deleted file mode 100644 index 2a697d9648..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/discovery.proto +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.service.discovery.v3; - -import "src/proto/grpc/testing/xds/v3/base.proto"; - -import "google/protobuf/any.proto"; - -message Status { - // The status code, which should be an enum value of [google.rpc.Code][]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][] field, or localized by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} - -// [#protodoc-title: Common discovery API components] - -// A DiscoveryRequest requests a set of versioned resources of the same type for -// a given Envoy node on some API. -// [#next-free-field: 7] -message DiscoveryRequest { - // The version_info provided in the request messages will be the version_info - // received with the most recent successfully processed response or empty on - // the first request. It is expected that no new request is sent after a - // response is received until the Envoy instance is ready to ACK/NACK the new - // configuration. ACK/NACK takes place by returning the new API config version - // as applied or the previous API config version respectively. Each type_url - // (see below) has an independent version associated with it. - string version_info = 1; - - // The node making the request. - config.core.v3.Node node = 2; - - // List of resources to subscribe to, e.g. list of cluster names or a route - // configuration name. If this is empty, all resources for the API are - // returned. LDS/CDS may have empty resource_names, which will cause all - // resources for the Envoy instance to be returned. The LDS and CDS responses - // will then imply a number of resources that need to be fetched via EDS/RDS, - // which will be explicitly enumerated in resource_names. - repeated string resource_names = 3; - - // Type of the resource that is being requested, e.g. - // "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment". This is implicit - // in requests made via singleton xDS APIs such as CDS, LDS, etc. but is - // required for ADS. - string type_url = 4; - - // nonce corresponding to DiscoveryResponse being ACK/NACKed. See above - // discussion on version_info and the DiscoveryResponse nonce comment. This - // may be empty only if 1) this is a non-persistent-stream xDS such as HTTP, - // or 2) the client has not yet accepted an update in this xDS stream (unlike - // delta, where it is populated only for new explicit ACKs). - string response_nonce = 5; - - // This is populated when the previous :ref:`DiscoveryResponse <envoy_api_msg_service.discovery.v3.DiscoveryResponse>` - // failed to update configuration. The *message* field in *error_details* provides the Envoy - // internal exception related to the failure. It is only intended for consumption during manual - // debugging, the string provided is not guaranteed to be stable across Envoy versions. - Status error_detail = 6; -} - -// [#next-free-field: 7] -message DiscoveryResponse { - // The version of the response data. - string version_info = 1; - - // The response resources. These resources are typed and depend on the API being called. - repeated google.protobuf.Any resources = 2; - - // [#not-implemented-hide:] - // Canary is used to support two Envoy command line flags: - // - // * --terminate-on-canary-transition-failure. When set, Envoy is able to - // terminate if it detects that configuration is stuck at canary. Consider - // this example sequence of updates: - // - Management server applies a canary config successfully. - // - Management server rolls back to a production config. - // - Envoy rejects the new production config. - // Since there is no sensible way to continue receiving configuration - // updates, Envoy will then terminate and apply production config from a - // clean slate. - // * --dry-run-canary. When set, a canary response will never be applied, only - // validated via a dry run. - bool canary = 3; - - // Type URL for resources. Identifies the xDS API when muxing over ADS. - // Must be consistent with the type_url in the 'resources' repeated Any (if non-empty). - string type_url = 4; - - // For gRPC based subscriptions, the nonce provides a way to explicitly ack a - // specific DiscoveryResponse in a following DiscoveryRequest. Additional - // messages may have been sent by Envoy to the management server for the - // previous version on the stream prior to this DiscoveryResponse, that were - // unprocessed at response send time. The nonce allows the management server - // to ignore any further DiscoveryRequests for the previous version until a - // DiscoveryRequest bearing the nonce. The nonce is optional and is not - // required for non-stream based xDS implementations. - string nonce = 5; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/endpoint.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/endpoint.proto deleted file mode 100644 index 7cbea7f443..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/endpoint.proto +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.endpoint.v3; - -import "src/proto/grpc/testing/xds/v3/address.proto"; -import "src/proto/grpc/testing/xds/v3/base.proto"; -import "src/proto/grpc/testing/xds/v3/percent.proto"; - -import "google/protobuf/wrappers.proto"; - -// [#protodoc-title: Endpoints] - -// Endpoint health status. -enum HealthStatus { - // The health status is not known. This is interpreted by Envoy as *HEALTHY*. - UNKNOWN = 0; - - // Healthy. - HEALTHY = 1; - - // Unhealthy. - UNHEALTHY = 2; - - // Connection draining in progress. E.g., - // `<https://aws.amazon.com/blogs/aws/elb-connection-draining-remove-instances-from-service-with-care/>`_ - // or - // `<https://cloud.google.com/compute/docs/load-balancing/enabling-connection-draining>`_. - // This is interpreted by Envoy as *UNHEALTHY*. - DRAINING = 3; - - // Health check timed out. This is part of HDS and is interpreted by Envoy as - // *UNHEALTHY*. - TIMEOUT = 4; - - // Degraded. - DEGRADED = 5; -} - -// Upstream host identifier. -message Endpoint { - // The upstream host address. - // - // .. attention:: - // - // The form of host address depends on the given cluster type. For STATIC or EDS, - // it is expected to be a direct IP address (or something resolvable by the - // specified :ref:`resolver <envoy_api_field_config.core.v3.SocketAddress.resolver_name>` - // in the Address). For LOGICAL or STRICT DNS, it is expected to be hostname, - // and will be resolved via DNS. - core.v3.Address address = 1; -} - -// An Endpoint that Envoy can route traffic to. -// [#next-free-field: 6] -message LbEndpoint { - // Upstream host identifier or a named reference. - oneof host_identifier { - Endpoint endpoint = 1; - } - - // Optional health status when known and supplied by EDS server. - HealthStatus health_status = 2; - - // The optional load balancing weight of the upstream host; at least 1. - // Envoy uses the load balancing weight in some of the built in load - // balancers. The load balancing weight for an endpoint is divided by the sum - // of the weights of all endpoints in the endpoint's locality to produce a - // percentage of traffic for the endpoint. This percentage is then further - // weighted by the endpoint's locality's load balancing weight from - // LocalityLbEndpoints. If unspecified, each host is presumed to have equal - // weight in a locality. The sum of the weights of all endpoints in the - // endpoint's locality must not exceed uint32_t maximal value (4294967295). - google.protobuf.UInt32Value load_balancing_weight = 4; -} - -// A group of endpoints belonging to a Locality. -// One can have multiple LocalityLbEndpoints for a locality, but this is -// generally only done if the different groups need to have different load -// balancing weights or different priorities. -// [#next-free-field: 7] -message LocalityLbEndpoints { - // Identifies location of where the upstream hosts run. - core.v3.Locality locality = 1; - - // The group of endpoints belonging to the locality specified. - repeated LbEndpoint lb_endpoints = 2; - - // Optional: Per priority/region/zone/sub_zone weight; at least 1. The load - // balancing weight for a locality is divided by the sum of the weights of all - // localities at the same priority level to produce the effective percentage - // of traffic for the locality. The sum of the weights of all localities at - // the same priority level must not exceed uint32_t maximal value (4294967295). - // - // Locality weights are only considered when :ref:`locality weighted load - // balancing <arch_overview_load_balancing_locality_weighted_lb>` is - // configured. These weights are ignored otherwise. If no weights are - // specified when locality weighted load balancing is enabled, the locality is - // assigned no load. - google.protobuf.UInt32Value load_balancing_weight = 3; - - // Optional: the priority for this LocalityLbEndpoints. If unspecified this will - // default to the highest priority (0). - // - // Under usual circumstances, Envoy will only select endpoints for the highest - // priority (0). In the event all endpoints for a particular priority are - // unavailable/unhealthy, Envoy will fail over to selecting endpoints for the - // next highest priority group. - // - // Priorities should range from 0 (highest) to N (lowest) without skipping. - uint32 priority = 5; -} - -// [#protodoc-title: Endpoint configuration] -// Endpoint discovery :ref:`architecture overview <arch_overview_service_discovery_types_eds>` - -// Each route from RDS will map to a single cluster or traffic split across -// clusters using weights expressed in the RDS WeightedCluster. -// -// With EDS, each cluster is treated independently from a LB perspective, with -// LB taking place between the Localities within a cluster and at a finer -// granularity between the hosts within a locality. The percentage of traffic -// for each endpoint is determined by both its load_balancing_weight, and the -// load_balancing_weight of its locality. First, a locality will be selected, -// then an endpoint within that locality will be chose based on its weight. -// [#next-free-field: 6] -message ClusterLoadAssignment { - // Load balancing policy settings. - // [#next-free-field: 6] - message Policy { - message DropOverload { - // Identifier for the policy specifying the drop. - string category = 1; - - // Percentage of traffic that should be dropped for the category. - type.v3.FractionalPercent drop_percentage = 2; - } - - // Action to trim the overall incoming traffic to protect the upstream - // hosts. This action allows protection in case the hosts are unable to - // recover from an outage, or unable to autoscale or unable to handle - // incoming traffic volume for any reason. - // - // At the client each category is applied one after the other to generate - // the 'actual' drop percentage on all outgoing traffic. For example: - // - // .. code-block:: json - // - // { "drop_overloads": [ - // { "category": "throttle", "drop_percentage": 60 } - // { "category": "lb", "drop_percentage": 50 } - // ]} - // - // The actual drop percentages applied to the traffic at the clients will be - // "throttle"_drop = 60% - // "lb"_drop = 20% // 50% of the remaining 'actual' load, which is 40%. - // actual_outgoing_load = 20% // remaining after applying all categories. - repeated DropOverload drop_overloads = 2; - } - - // Name of the cluster. This will be the :ref:`service_name - // <envoy_api_field_config.cluster.v3.Cluster.EdsClusterConfig.service_name>` value if specified - // in the cluster :ref:`EdsClusterConfig - // <envoy_api_msg_config.cluster.v3.Cluster.EdsClusterConfig>`. - string cluster_name = 1; - - // List of endpoints to load balance to. - repeated LocalityLbEndpoints endpoints = 2; - - // Load balancing policy settings. - Policy policy = 4; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/extension.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/extension.proto deleted file mode 100644 index 10f4b00208..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/extension.proto +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2021 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.core.v3; - -import "google/protobuf/any.proto"; - -// [#protodoc-title: Extension configuration] - -// Message type for extension configuration. -// [#next-major-version: revisit all existing typed_config that doesn't use this wrapper.]. -message TypedExtensionConfig { - // The name of an extension. This is not used to select the extension, instead - // it serves the role of an opaque identifier. - string name = 1; - - // The typed config for the extension. The type URL will be used to identify - // the extension. In the case that the type URL is *udpa.type.v1.TypedStruct*, - // the inner type URL of *TypedStruct* will be utilized. See the - // :ref:`extension configuration overview - // <config_overview_extension_configuration>` for further details. - google.protobuf.Any typed_config = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault.proto deleted file mode 100644 index 05ec641d0e..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault.proto +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.filters.http.fault.v3; - -import "src/proto/grpc/testing/xds/v3/fault_common.proto"; -import "src/proto/grpc/testing/xds/v3/route.proto"; -import "src/proto/grpc/testing/xds/v3/percent.proto"; - -import "google/protobuf/wrappers.proto"; - -// [#protodoc-title: Fault Injection] -// Fault Injection :ref:`configuration overview <config_http_filters_fault_injection>`. -// [#extension: envoy.filters.http.fault] - -// [#next-free-field: 6] -message FaultAbort { - // Fault aborts are controlled via an HTTP header (if applicable). See the - // :ref:`HTTP fault filter <config_http_filters_fault_injection_http_header>` documentation for - // more information. - message HeaderAbort { - } - - reserved 1; - - oneof error_type { - // HTTP status code to use to abort the HTTP request. - uint32 http_status = 2; - - // gRPC status code to use to abort the gRPC request. - uint32 grpc_status = 5; - - // Fault aborts are controlled via an HTTP header (if applicable). - HeaderAbort header_abort = 4; - } - - // The percentage of requests/operations/connections that will be aborted with the error code - // provided. - type.v3.FractionalPercent percentage = 3; -} - -// [#next-free-field: 15] -message HTTPFault { - // If specified, the filter will inject delays based on the values in the - // object. - common.fault.v3.FaultDelay delay = 1; - - // If specified, the filter will abort requests based on the values in - // the object. At least *abort* or *delay* must be specified. - FaultAbort abort = 2; - - // Specifies a set of headers that the filter should match on. The fault - // injection filter can be applied selectively to requests that match a set of - // headers specified in the fault filter config. The chances of actual fault - // injection further depend on the value of the :ref:`percentage - // <envoy_api_field_extensions.filters.http.fault.v3.FaultAbort.percentage>` field. - // The filter will check the request's headers against all the specified - // headers in the filter config. A match will happen if all the headers in the - // config are present in the request with the same values (or based on - // presence if the *value* field is not in the config). - repeated config.route.v3.HeaderMatcher headers = 4; - - // The maximum number of faults that can be active at a single time via the configured fault - // filter. Note that because this setting can be overridden at the route level, it's possible - // for the number of active faults to be greater than this value (if injected via a different - // route). If not specified, defaults to unlimited. This setting can be overridden via - // `runtime <config_http_filters_fault_injection_runtime>` and any faults that are not injected - // due to overflow will be indicated via the `faults_overflow - // <config_http_filters_fault_injection_stats>` stat. - // - // .. attention:: - // Like other :ref:`circuit breakers <arch_overview_circuit_break>` in Envoy, this is a fuzzy - // limit. It's possible for the number of active faults to rise slightly above the configured - // amount due to the implementation details. - google.protobuf.UInt32Value max_active_faults = 6; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault_common.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault_common.proto deleted file mode 100644 index 2c2aedc789..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/fault_common.proto +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.filters.common.fault.v3; - -import "src/proto/grpc/testing/xds/v3/percent.proto"; - -import "google/protobuf/duration.proto"; - -// Delay specification is used to inject latency into the -// HTTP/gRPC/Mongo/Redis operation or delay proxying of TCP connections. -message FaultDelay { - // Fault delays are controlled via an HTTP header (if applicable). See the - // :ref:`HTTP fault filter <config_http_filters_fault_injection_http_header>` - // documentation for more information. - message HeaderDelay {} - - oneof fault_delay_secifier { - // Add a fixed delay before forwarding the operation upstream. See - // https://developers.google.com/protocol-buffers/docs/proto3#json for - // the JSON/YAML Duration mapping. For HTTP/Mongo/Redis, the specified - // delay will be injected before a new request/operation. For TCP - // connections, the proxying of the connection upstream will be delayed - // for the specified period. This is required if type is FIXED. - google.protobuf.Duration fixed_delay = 3; - - // Fault delays are controlled via an HTTP header (if applicable). - HeaderDelay header_delay = 5; - } - - // The percentage of operations/connections/requests on which the delay will - // be injected. - type.v3.FractionalPercent percentage = 4; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/http_connection_manager.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/http_connection_manager.proto deleted file mode 100644 index 74477073c7..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/http_connection_manager.proto +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.filters.network.http_connection_manager.v3; - -import "google/protobuf/any.proto"; - -import "src/proto/grpc/testing/xds/v3/config_source.proto"; -import "src/proto/grpc/testing/xds/v3/protocol.proto"; -import "src/proto/grpc/testing/xds/v3/route.proto"; - -// [#protodoc-title: HTTP connection manager] -// HTTP connection manager :ref:`configuration overview <config_http_conn_man>`. -// [#extension: envoy.filters.network.http_connection_manager] - -message HttpConnectionManager { - oneof route_specifier { - // The connection manager’s route table will be dynamically loaded via the RDS API. - Rds rds = 3; - - // The route table for the connection manager is static and is specified in this property. - config.route.v3.RouteConfiguration route_config = 4; - - // A route table will be dynamically assigned to each request based on request attributes - // (e.g., the value of a header). The "routing scopes" (i.e., route tables) and "scope keys" are - // specified in this message. - ScopedRoutes scoped_routes = 31; - } - - // A list of individual HTTP filters that make up the filter chain for - // requests made to the connection manager. :ref:`Order matters <arch_overview_http_filters_ordering>` - // as the filters are processed sequentially as request events happen. - repeated HttpFilter http_filters = 5; - - // Additional settings for HTTP requests handled by the connection manager. These will be - // applicable to both HTTP1 and HTTP2 requests. - config.core.v3.HttpProtocolOptions common_http_protocol_options = 35; -} - -message Rds { - // Configuration source specifier for RDS. - config.core.v3.ConfigSource config_source = 1; - - // The name of the route configuration. This name will be passed to the RDS - // API. This allows an Envoy configuration with multiple HTTP listeners (and - // associated HTTP connection manager filters) to use different route - // configurations. - string route_config_name = 2; -} - -message ScopedRoutes { -} - -message HttpFilter { - // The name of the filter configuration. The name is used as a fallback to - // select an extension if the type of the configuration proto is not - // sufficient. It also serves as a resource name in ExtensionConfigDS. - string name = 1; - - oneof config_type { - // Filter specific configuration which depends on the filter being instantiated. See the supported - // filters for further documentation. - google.protobuf.Any typed_config = 4; - } - - bool is_optional = 6; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/listener.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/listener.proto deleted file mode 100644 index df9ee71e72..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/listener.proto +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.listener.v3; - -import "src/proto/grpc/testing/xds/v3/address.proto"; -import "src/proto/grpc/testing/xds/v3/base.proto"; - -import "google/protobuf/any.proto"; -import "google/protobuf/wrappers.proto"; - -// [#protodoc-title: Listener configuration] -// Listener :ref:`configuration overview <config_listeners>` - -// Describes a type of API listener, which is used in non-proxy clients. The type of API -// exposed to the non-proxy application depends on the type of API listener. -message ApiListener { - // The type in this field determines the type of API listener. At present, the following - // types are supported: - // envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager (HTTP) - // [#next-major-version: In the v3 API, replace this Any field with a oneof containing the - // specific config message for each type of API listener. We could not do this in v2 because - // it would have caused circular dependencies for go protos: lds.proto depends on this file, - // and http_connection_manager.proto depends on rds.proto, which is in the same directory as - // lds.proto, so lds.proto cannot depend on this file.] - google.protobuf.Any api_listener = 1; -} - -message Filter { - reserved 3; - - // The name of the filter to instantiate. The name must match a - // :ref:`supported filter <config_network_filters>`. - string name = 1; - - // [#extension-category: envoy.filters.network] - oneof config_type { - // Filter specific configuration which depends on the filter being - // instantiated. See the supported filters for further documentation. - google.protobuf.Any typed_config = 4; - } -} - -message FilterChainMatch { - enum ConnectionSourceType { - // Any connection source matches. - ANY = 0; - - // Match a connection originating from the same host. - SAME_IP_OR_LOOPBACK = 1; - - // Match a connection originating from a different host. - EXTERNAL = 2; - } - - reserved 1; - - // Optional destination port to consider when use_original_dst is set on the - // listener in determining a filter chain match. - google.protobuf.UInt32Value destination_port = 8; - - // If non-empty, an IP address and prefix length to match addresses when the - // listener is bound to 0.0.0.0/:: or when use_original_dst is specified. - repeated core.v3.CidrRange prefix_ranges = 3; - - // Specifies the connection source IP match type. Can be any, local or external network. - ConnectionSourceType source_type = 12; - - // The criteria is satisfied if the source IP address of the downstream - // connection is contained in at least one of the specified subnets. If the - // parameter is not specified or the list is empty, the source IP address is - // ignored. - repeated core.v3.CidrRange source_prefix_ranges = 6; - - // The criteria is satisfied if the source port of the downstream connection - // is contained in at least one of the specified ports. If the parameter is - // not specified, the source port is ignored. - repeated uint32 source_ports = 7; - - // If non-empty, a list of server names (e.g. SNI for TLS protocol) to consider when determining - // a filter chain match. Those values will be compared against the server names of a new - // connection, when detected by one of the listener filters. - // - // The server name will be matched against all wildcard domains, i.e. ``www.example.com`` - // will be first matched against ``www.example.com``, then ``*.example.com``, then ``*.com``. - // - // Note that partial wildcards are not supported, and values like ``*w.example.com`` are invalid. - // - // .. attention:: - // - // See the :ref:`FAQ entry <faq_how_to_setup_sni>` on how to configure SNI for more - // information. - repeated string server_names = 11; - - // If non-empty, a transport protocol to consider when determining a filter chain match. - // This value will be compared against the transport protocol of a new connection, when - // it's detected by one of the listener filters. - // - // Suggested values include: - // - // * ``raw_buffer`` - default, used when no transport protocol is detected, - // * ``tls`` - set by :ref:`envoy.filters.listener.tls_inspector <config_listener_filters_tls_inspector>` - // when TLS protocol is detected. - string transport_protocol = 9; - - // If non-empty, a list of application protocols (e.g. ALPN for TLS protocol) to consider when - // determining a filter chain match. Those values will be compared against the application - // protocols of a new connection, when detected by one of the listener filters. - // - // Suggested values include: - // - // * ``http/1.1`` - set by :ref:`envoy.filters.listener.tls_inspector - // <config_listener_filters_tls_inspector>`, - // * ``h2`` - set by :ref:`envoy.filters.listener.tls_inspector <config_listener_filters_tls_inspector>` - // - // .. attention:: - // - // Currently, only :ref:`TLS Inspector <config_listener_filters_tls_inspector>` provides - // application protocol detection based on the requested - // `ALPN <https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation>`_ values. - // - // However, the use of ALPN is pretty much limited to the HTTP/2 traffic on the Internet, - // and matching on values other than ``h2`` is going to lead to a lot of false negatives, - // unless all connecting clients are known to use ALPN. - repeated string application_protocols = 10; -} - -// A filter chain wraps a set of match criteria, an option TLS context, a set of filters, and -// various other parameters. -// [#next-free-field: 10] -message FilterChain { - // The criteria to use when matching a connection to this filter chain. - FilterChainMatch filter_chain_match = 1; - - // A list of individual network filters that make up the filter chain for - // connections established with the listener. Order matters as the filters are - // processed sequentially as connection events happen. Note: If the filter - // list is empty, the connection will close by default. - repeated Filter filters = 3; - - // Optional custom transport socket implementation to use for downstream connections. - // To setup TLS, set a transport socket with name `tls` and - // :ref:`DownstreamTlsContext <envoy_api_msg_extensions.transport_sockets.tls.v3.DownstreamTlsContext>` in the `typed_config`. - // If no transport socket configuration is specified, new connections - // will be set up with plaintext. - core.v3.TransportSocket transport_socket = 6; -} - -// [#next-free-field: 23] -message Listener { - // The unique name by which this listener is known. If no name is provided, - // Envoy will allocate an internal UUID for the listener. If the listener is to be dynamically - // updated or removed via :ref:`LDS <config_listeners_lds>` a unique name must be provided. - string name = 1; - - // The address that the listener should listen on. In general, the address must be unique, though - // that is governed by the bind rules of the OS. E.g., multiple listeners can listen on port 0 on - // Linux as the actual port will be allocated by the OS. - core.v3.Address address = 2; - - // A list of filter chains to consider for this listener. The - // :ref:`FilterChain <envoy_api_msg_config.listener.v3.FilterChain>` with the most specific - // :ref:`FilterChainMatch <envoy_api_msg_config.listener.v3.FilterChainMatch>` criteria is used on a - // connection. - // - // Example using SNI for filter chain selection can be found in the - // :ref:`FAQ entry <faq_how_to_setup_sni>`. - repeated FilterChain filter_chains = 3; - - // If a connection is redirected using *iptables*, the port on which the proxy - // receives it might be different from the original destination address. When this flag is set to - // true, the listener hands off redirected connections to the listener associated with the - // original destination address. If there is no listener associated with the original destination - // address, the connection is handled by the listener that receives it. Defaults to false. - google.protobuf.BoolValue use_original_dst = 4; - - // The default filter chain if none of the filter chain matches. If no default filter chain is supplied, - // the connection will be closed. The filter chain match is ignored in this field. - FilterChain default_filter_chain = 25; - - // Used to represent an API listener, which is used in non-proxy clients. The type of API - // exposed to the non-proxy application depends on the type of API listener. - // When this field is set, no other field except for :ref:`name<envoy_api_field_config.listener.v3.Listener.name>` - // should be set. - // - // .. note:: - // - // Currently only one ApiListener can be installed; and it can only be done via bootstrap config, - // not LDS. - // - // [#next-major-version: In the v3 API, instead of this messy approach where the socket - // listener fields are directly in the top-level Listener message and the API listener types - // are in the ApiListener message, the socket listener messages should be in their own message, - // and the top-level Listener should essentially be a oneof that selects between the - // socket listener and the various types of API listener. That way, a given Listener message - // can structurally only contain the fields of the relevant type.] - ApiListener api_listener = 19; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/load_report.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/load_report.proto deleted file mode 100644 index b8ee86fb48..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/load_report.proto +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.endpoint.v3; - -import "src/proto/grpc/testing/xds/v3/address.proto"; -import "src/proto/grpc/testing/xds/v3/base.proto"; - -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; - -// These are stats Envoy reports to GLB every so often. Report frequency is -// defined by -// :ref:`LoadStatsResponse.load_reporting_interval<envoy_api_field_service.load_stats.v3.LoadStatsResponse.load_reporting_interval>`. -// Stats per upstream region/zone and optionally per subzone. -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -// [#next-free-field: 9] -message UpstreamLocalityStats { - // Name of zone, region and optionally endpoint group these metrics were - // collected from. Zone and region names could be empty if unknown. - core.v3.Locality locality = 1; - - // The total number of requests successfully completed by the endpoints in the - // locality. - uint64 total_successful_requests = 2; - - // The total number of unfinished requests - uint64 total_requests_in_progress = 3; - - // The total number of requests that failed due to errors at the endpoint, - // aggregated over all endpoints in the locality. - uint64 total_error_requests = 4; - - // The total number of requests that were issued by this Envoy since - // the last report. This information is aggregated over all the - // upstream endpoints in the locality. - uint64 total_issued_requests = 8; - - // Stats for multi-dimensional load balancing. - repeated EndpointLoadMetricStats load_metric_stats = 5; - - // Endpoint granularity stats information for this locality. This information - // is populated if the Server requests it by setting - // :ref:`LoadStatsResponse.report_endpoint_granularity<envoy_api_field_service.load_stats.v3.LoadStatsResponse.report_endpoint_granularity>`. - repeated UpstreamEndpointStats upstream_endpoint_stats = 7; - - // [#not-implemented-hide:] The priority of the endpoint group these metrics - // were collected from. - uint32 priority = 6; -} - -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -// [#next-free-field: 8] -message UpstreamEndpointStats { - // Upstream host address. - core.v3.Address address = 1; - - // Opaque and implementation dependent metadata of the - // endpoint. Envoy will pass this directly to the management server. - google.protobuf.Struct metadata = 6; - - // The total number of requests successfully completed by the endpoints in the - // locality. These include non-5xx responses for HTTP, where errors - // originate at the client and the endpoint responded successfully. For gRPC, - // the grpc-status values are those not covered by total_error_requests below. - uint64 total_successful_requests = 2; - - // The total number of unfinished requests for this endpoint. - uint64 total_requests_in_progress = 3; - - // The total number of requests that failed due to errors at the endpoint. - // For HTTP these are responses with 5xx status codes and for gRPC the - // grpc-status values: - // - // - DeadlineExceeded - // - Unimplemented - // - Internal - // - Unavailable - // - Unknown - // - DataLoss - uint64 total_error_requests = 4; - - // The total number of requests that were issued to this endpoint - // since the last report. A single TCP connection, HTTP or gRPC - // request or stream is counted as one request. - uint64 total_issued_requests = 7; - - // Stats for multi-dimensional load balancing. - repeated EndpointLoadMetricStats load_metric_stats = 5; -} - -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -message EndpointLoadMetricStats { - // Name of the metric; may be empty. - string metric_name = 1; - - // Number of calls that finished and included this metric. - uint64 num_requests_finished_with_metric = 2; - - // Sum of metric values across all calls that finished with this metric for - // load_reporting_interval. - double total_metric_value = 3; -} - -// Per cluster load stats. Envoy reports these stats a management server in a -// :ref:`LoadStatsRequest<envoy_api_msg_service.load_stats.v3.LoadStatsRequest>` -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -// Next ID: 7 -// [#next-free-field: 7] -message ClusterStats { - message DroppedRequests { - // Identifier for the policy specifying the drop. - string category = 1; - - // Total number of deliberately dropped requests for the category. - uint64 dropped_count = 2; - } - - // The name of the cluster. - string cluster_name = 1; - - // The eds_cluster_config service_name of the cluster. - // It's possible that two clusters send the same service_name to EDS, - // in that case, the management server is supposed to do aggregation on the load reports. - string cluster_service_name = 6; - - // Need at least one. - repeated UpstreamLocalityStats upstream_locality_stats = 2; - - // Cluster-level stats such as total_successful_requests may be computed by - // summing upstream_locality_stats. In addition, below there are additional - // cluster-wide stats. - // - // The total number of dropped requests. This covers requests - // deliberately dropped by the drop_overload policy and circuit breaking. - uint64 total_dropped_requests = 3; - - // Information about deliberately dropped requests for each category specified - // in the DropOverload policy. - repeated DroppedRequests dropped_requests = 5; - - // Period over which the actual load report occurred. This will be guaranteed to include every - // request reported. Due to system load and delays between the *LoadStatsRequest* sent from Envoy - // and the *LoadStatsResponse* message sent from the management server, this may be longer than - // the requested load reporting interval in the *LoadStatsResponse*. - google.protobuf.Duration load_report_interval = 4; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/lrs.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/lrs.proto deleted file mode 100644 index e118b7f957..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/lrs.proto +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.service.load_stats.v3; - -import "src/proto/grpc/testing/xds/v3/base.proto"; -import "src/proto/grpc/testing/xds/v3/load_report.proto"; - -import "google/protobuf/duration.proto"; - -// [#protodoc-title: Load reporting service] - -service LoadReportingService { - // Advanced API to allow for multi-dimensional load balancing by remote - // server. For receiving LB assignments, the steps are: - // 1, The management server is configured with per cluster/zone/load metric - // capacity configuration. The capacity configuration definition is - // outside of the scope of this document. - // 2. Envoy issues a standard {Stream,Fetch}Endpoints request for the clusters - // to balance. - // - // Independently, Envoy will initiate a StreamLoadStats bidi stream with a - // management server: - // 1. Once a connection establishes, the management server publishes a - // LoadStatsResponse for all clusters it is interested in learning load - // stats about. - // 2. For each cluster, Envoy load balances incoming traffic to upstream hosts - // based on per-zone weights and/or per-instance weights (if specified) - // based on intra-zone LbPolicy. This information comes from the above - // {Stream,Fetch}Endpoints. - // 3. When upstream hosts reply, they optionally add header <define header - // name> with ASCII representation of EndpointLoadMetricStats. - // 4. Envoy aggregates load reports over the period of time given to it in - // LoadStatsResponse.load_reporting_interval. This includes aggregation - // stats Envoy maintains by itself (total_requests, rpc_errors etc.) as - // well as load metrics from upstream hosts. - // 5. When the timer of load_reporting_interval expires, Envoy sends new - // LoadStatsRequest filled with load reports for each cluster. - // 6. The management server uses the load reports from all reported Envoys - // from around the world, computes global assignment and prepares traffic - // assignment destined for each zone Envoys are located in. Goto 2. - rpc StreamLoadStats(stream LoadStatsRequest) returns (stream LoadStatsResponse) { - } -} - -// A load report Envoy sends to the management server. -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -message LoadStatsRequest { - // Node identifier for Envoy instance. - config.core.v3.Node node = 1; - - // A list of load stats to report. - repeated config.endpoint.v3.ClusterStats cluster_stats = 2; -} - -// The management server sends envoy a LoadStatsResponse with all clusters it -// is interested in learning load stats about. -// [#not-implemented-hide:] Not configuration. TBD how to doc proto APIs. -message LoadStatsResponse { - // Clusters to report stats for. - // Not populated if *send_all_clusters* is true. - repeated string clusters = 1; - - // If true, the client should send all clusters it knows about. - // Only clients that advertise the "envoy.lrs.supports_send_all_clusters" capability in their - // :ref:`client_features<envoy_api_field_config.core.v3.Node.client_features>` field will honor this field. - bool send_all_clusters = 4; - - // The minimum interval of time to collect stats over. This is only a minimum for two reasons: - // 1. There may be some delay from when the timer fires until stats sampling occurs. - // 2. For clusters that were already feature in the previous *LoadStatsResponse*, any traffic - // that is observed in between the corresponding previous *LoadStatsRequest* and this - // *LoadStatsResponse* will also be accumulated and billed to the cluster. This avoids a period - // of inobservability that might otherwise exists between the messages. New clusters are not - // subject to this consideration. - google.protobuf.Duration load_reporting_interval = 2; - - // Set to *true* if the management server supports endpoint granularity - // report. - bool report_endpoint_granularity = 3; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/orca_load_report.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/orca_load_report.proto deleted file mode 100644 index 033e64ba49..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/orca_load_report.proto +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package xds.data.orca.v3; - -// See section `ORCA load report format` of the design document in -// :ref:`https://github.com/envoyproxy/envoy/issues/6614`. - -message OrcaLoadReport { - // CPU utilization expressed as a fraction of available CPU resources. This - // should be derived from the latest sample or measurement. - double cpu_utilization = 1; - - // Memory utilization expressed as a fraction of available memory - // resources. This should be derived from the latest sample or measurement. - double mem_utilization = 2; - - // Total RPS being served by an endpoint. This should cover all services that an endpoint is - // responsible for. - uint64 rps = 3; - - // Application specific requests costs. Each value is an absolute cost (e.g. 3487 bytes of - // storage) associated with the request. - map<string, double> request_cost = 4; - - // Resource utilization values. Each value is expressed as a fraction of total resources - // available, derived from the latest sample or measurement. - map<string, double> utilization = 5; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/percent.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/percent.proto deleted file mode 100644 index dacc97496e..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/percent.proto +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.type.v3; - -// A fractional percentage is used in cases in which for performance reasons performing floating -// point to integer conversions during randomness calculations is undesirable. The message includes -// both a numerator and denominator that together determine the final fractional value. -// -// * **Example**: 1/100 = 1%. -// * **Example**: 3/10000 = 0.03%. -message FractionalPercent { - // Fraction percentages support several fixed denominator values. - enum DenominatorType { - // 100. - // - // **Example**: 1/100 = 1%. - HUNDRED = 0; - - // 10,000. - // - // **Example**: 1/10000 = 0.01%. - TEN_THOUSAND = 1; - - // 1,000,000. - // - // **Example**: 1/1000000 = 0.0001%. - MILLION = 2; - } - - // Specifies the numerator. Defaults to 0. - uint32 numerator = 1; - - // Specifies the denominator. If the denominator specified is less than the numerator, the final - // fractional percentage is capped at 1 (100%). - DenominatorType denominator = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/protocol.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/protocol.proto deleted file mode 100644 index 886cc11ddf..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/protocol.proto +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.core.v3; - -import "google/protobuf/duration.proto"; - -// [#next-free-field: 5] -message HttpProtocolOptions { - // The maximum duration of a connection. - google.protobuf.Duration max_stream_duration = 4; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/range.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/range.proto deleted file mode 100644 index 5fe5530ee6..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/range.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.type.v3; - -// [#protodoc-title: Range] - -// Specifies the int64 start and end of the range using half-open interval semantics [start, -// end). -message Int64Range { - // start of the range (inclusive) - int64 start = 1; - - // end of the range (exclusive) - int64 end = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/regex.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/regex.proto deleted file mode 100644 index 9039ed4644..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/regex.proto +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.type.matcher.v3; - -// [#protodoc-title: Regex matcher] - -// A regex matcher designed for safety when used with untrusted input. -message RegexMatcher { - // Google's `RE2 <https://github.com/google/re2>`_ regex engine. The regex string must adhere to - // the documented `syntax <https://github.com/google/re2/wiki/Syntax>`_. The engine is designed - // to complete execution in linear time as well as limit the amount of memory used. - message GoogleRE2 { - } - - oneof engine_type { - // Google's RE2 regex engine. - GoogleRE2 google_re2 = 1; - } - - // The regex match string. The string must be supported by the configured engine. - string regex = 2; -} - -message RegexMatchAndSubstitute { - RegexMatcher pattern = 1; - string substitution = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/route.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/route.proto deleted file mode 100644 index 7109fe21db..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/route.proto +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.config.route.v3; - -import "src/proto/grpc/testing/xds/v3/base.proto"; -import "src/proto/grpc/testing/xds/v3/regex.proto"; -import "src/proto/grpc/testing/xds/v3/percent.proto"; -import "src/proto/grpc/testing/xds/v3/range.proto"; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/wrappers.proto"; - -// [#protodoc-title: HTTP route components] -// * Routing :ref:`architecture overview <arch_overview_http_routing>` -// * HTTP :ref:`router filter <config_http_filters_router>` - -message RetryPolicy { - string retry_on = 1; - google.protobuf.UInt32Value num_retries = 2; - - message RetryBackOff { - google.protobuf.Duration base_interval = 1; - google.protobuf.Duration max_interval = 2; - } - - RetryBackOff retry_back_off = 8; -} - -// The top level element in the routing configuration is a virtual host. Each virtual host has -// a logical name as well as a set of domains that get routed to it based on the incoming request's -// host header. This allows a single listener to service multiple top level domain path trees. Once -// a virtual host is selected based on the domain, the routes are processed in order to see which -// upstream cluster to route to or whether to perform a redirect. -// [#next-free-field: 21] -message VirtualHost { - // The logical name of the virtual host. This is used when emitting certain - // statistics but is not relevant for routing. - string name = 1; - - // A list of domains (host/authority header) that will be matched to this - // virtual host. Wildcard hosts are supported in the suffix or prefix form. - // - // Domain search order: - // 1. Exact domain names: ``www.foo.com``. - // 2. Suffix domain wildcards: ``*.foo.com`` or ``*-bar.foo.com``. - // 3. Prefix domain wildcards: ``foo.*`` or ``foo-*``. - // 4. Special wildcard ``*`` matching any domain. - // - // .. note:: - // - // The wildcard will not match the empty string. - // e.g. ``*-bar.foo.com`` will match ``baz-bar.foo.com`` but not ``-bar.foo.com``. - // The longest wildcards match first. - // Only a single virtual host in the entire route configuration can match on ``*``. A domain - // must be unique across all virtual hosts or the config will fail to load. - // - // Domains cannot contain control characters. This is validated by the well_known_regex HTTP_HEADER_VALUE. - repeated string domains = 2; - - // The list of routes that will be matched, in order, for incoming requests. - // The first route that matches will be used. - repeated Route routes = 3; - - // The per_filter_config field can be used to provide virtual host-specific - // configurations for filters. The key should match the filter name, such as - // *envoy.filters.http.buffer* for the HTTP buffer filter. Use of this field is filter - // specific; see the :ref:`HTTP filter documentation <config_http_filters>` - // for if and how it is utilized. - map<string, google.protobuf.Any> typed_per_filter_config = 15; - - RetryPolicy retry_policy = 16; -} - -// A route is both a specification of how to match a request as well as an indication of what to do -// next (e.g., redirect, forward, rewrite, etc.). -// -// .. attention:: -// -// Envoy supports routing on HTTP method via :ref:`header matching -// <envoy_api_msg_config.route.v3.HeaderMatcher>`. -// [#next-free-field: 18] -message Route { - // Name for the route. - string name = 14; - - // Route matching parameters. - RouteMatch match = 1; - - message NonForwardingAction { - } - - oneof action { - // Route request to some upstream cluster. - RouteAction route = 2; - - // Return a redirect. - RedirectAction redirect = 3; - - // An action used when the route will generate a response directly, - // without forwarding to an upstream host. This will be used in non-proxy - // xDS clients like the gRPC server. It could also be used in the future - // in Envoy for a filter that directly generates responses for requests. - NonForwardingAction non_forwarding_action = 18; - } - - // The typed_per_filter_config field can be used to provide route-specific - // configurations for filters. The key should match the filter name, such as - // *envoy.filters.http.buffer* for the HTTP buffer filter. Use of this field is filter - // specific; see the :ref:`HTTP filter documentation <config_http_filters>` for - // if and how it is utilized. - map<string, google.protobuf.Any> typed_per_filter_config = 13; -} - -// Compared to the :ref:`cluster <envoy_api_field_config.route.v3.RouteAction.cluster>` field that specifies a -// single upstream cluster as the target of a request, the :ref:`weighted_clusters -// <envoy_api_field_config.route.v3.RouteAction.weighted_clusters>` option allows for specification of -// multiple upstream clusters along with weights that indicate the percentage of -// traffic to be forwarded to each cluster. The router selects an upstream cluster based on the -// weights. -message WeightedCluster { - // [#next-free-field: 11] - message ClusterWeight { - // Name of the upstream cluster. The cluster must exist in the - // :ref:`cluster manager configuration <config_cluster_manager>`. - string name = 1; - - // An integer between 0 and :ref:`total_weight - // <envoy_api_field_config.route.v3.WeightedCluster.total_weight>`. When a request matches the route, - // the choice of an upstream cluster is determined by its weight. The sum of weights across all - // entries in the clusters array must add up to the total_weight, which defaults to 100. - google.protobuf.UInt32Value weight = 2; - - // The per_filter_config field can be used to provide weighted cluster-specific - // configurations for filters. The key should match the filter name, such as - // *envoy.filters.http.buffer* for the HTTP buffer filter. Use of this field is filter - // specific; see the :ref:`HTTP filter documentation <config_http_filters>` - // for if and how it is utilized. - map<string, google.protobuf.Any> typed_per_filter_config = 10; - } - - // Specifies one or more upstream clusters associated with the route. - repeated ClusterWeight clusters = 1; - - // Specifies the total weight across all clusters. The sum of all cluster weights must equal this - // value, which must be greater than 0. Defaults to 100. - google.protobuf.UInt32Value total_weight = 3; -} - -// [#next-free-field: 13] -message RouteMatch { - oneof path_specifier { - // If specified, the route is a prefix rule meaning that the prefix must - // match the beginning of the *:path* header. - string prefix = 1; - - // If specified, the route is an exact path rule meaning that the path must - // exactly match the *:path* header once the query string is removed. - string path = 2; - - // If specified, the route is a regular expression rule meaning that the - // regex must match the *:path* header once the query string is removed. The entire path - // (without the query string) must match the regex. The rule will not match if only a - // subsequence of the *:path* header matches the regex. - // - // [#next-major-version: In the v3 API we should redo how path specification works such - // that we utilize StringMatcher, and additionally have consistent options around whether we - // strip query strings, do a case sensitive match, etc. In the interim it will be too disruptive - // to deprecate the existing options. We should even consider whether we want to do away with - // path_specifier entirely and just rely on a set of header matchers which can already match - // on :path, etc. The issue with that is it is unclear how to generically deal with query string - // stripping. This needs more thought.] - type.matcher.v3.RegexMatcher safe_regex = 10; - } - - // Indicates that prefix/path matching should be case insensitive. The default - // is true. - google.protobuf.BoolValue case_sensitive = 4; - - // Indicates that the route should additionally match on a runtime key. Every time the route - // is considered for a match, it must also fall under the percentage of matches indicated by - // this field. For some fraction N/D, a random number in the range [0,D) is selected. If the - // number is <= the value of the numerator N, or if the key is not present, the default - // value, the router continues to evaluate the remaining match criteria. A runtime_fraction - // route configuration can be used to roll out route changes in a gradual manner without full - // code/config deploys. Refer to the :ref:`traffic shifting - // <config_http_conn_man_route_table_traffic_splitting_shift>` docs for additional documentation. - // - // .. note:: - // - // Parsing this field is implemented such that the runtime key's data may be represented - // as a FractionalPercent proto represented as JSON/YAML and may also be represented as an - // integer with the assumption that the value is an integral percentage out of 100. For - // instance, a runtime key lookup returning the value "42" would parse as a FractionalPercent - // whose numerator is 42 and denominator is HUNDRED. This preserves legacy semantics. - core.v3.RuntimeFractionalPercent runtime_fraction = 9; - - // Specifies a set of headers that the route should match on. The router will - // check the request’s headers against all the specified headers in the route - // config. A match will happen if all the headers in the route are present in - // the request with the same values (or based on presence if the value field - // is not in the config). - repeated HeaderMatcher headers = 6; - - // Specifies a set of URL query parameters on which the route should - // match. The router will check the query string from the *path* header - // against all the specified query parameters. If the number of specified - // query parameters is nonzero, they all must match the *path* header's - // query string for a match to occur. - repeated QueryParameterMatcher query_parameters = 7; -} - -message MaxStreamDuration { - // Specifies the maximum duration allowed for streams on the route. If not specified, the value - // from the :ref:`max_stream_duration - // <envoy_api_field_config.core.v3.HttpProtocolOptions.max_stream_duration>` field in - // :ref:`HttpConnectionManager.common_http_protocol_options - // <envoy_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.common_http_protocol_options>` - // is used. If this field is set explicitly to zero, any - // HttpConnectionManager max_stream_duration timeout will be disabled for - // this route. - google.protobuf.Duration max_stream_duration = 1; - - // If present, and the request contains a `grpc-timeout header - // <https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md>`_, use that value as the - // *max_stream_duration*, but limit the applied timeout to the maximum value specified here. - // If set to 0, the `grpc-timeout` header is used without modification. - google.protobuf.Duration grpc_timeout_header_max = 2; -} - -// [#next-free-field: 37] -message RouteAction { - oneof cluster_specifier { - // Indicates the upstream cluster to which the request should be routed - // to. - string cluster = 1; - - // Envoy will determine the cluster to route to by reading the value of the - // HTTP header named by cluster_header from the request headers. If the - // header is not found or the referenced cluster does not exist, Envoy will - // return a 404 response. - // - // .. attention:: - // - // Internally, Envoy always uses the HTTP/2 *:authority* header to represent the HTTP/1 - // *Host* header. Thus, if attempting to match on *Host*, match on *:authority* instead. - string cluster_header = 2; - - // Multiple upstream clusters can be specified for a given route. The - // request is routed to one of the upstream clusters based on weights - // assigned to each cluster. See - // :ref:`traffic splitting <config_http_conn_man_route_table_traffic_splitting_split>` - // for additional documentation. - WeightedCluster weighted_clusters = 3; - } - - message HashPolicy { - message Header { - // The name of the request header that will be used to obtain the hash - // key. If the request header is not present, no hash will be produced. - string header_name = 1; - - // If specified, the request header value will be rewritten and used - // to produce the hash key. - type.matcher.v3.RegexMatchAndSubstitute regex_rewrite = 2; - } - - message Cookie { - string name = 1; - } - - message ConnectionProperties { - bool source_ip = 1; - } - - message QueryParameter { - string name = 1; - } - - message FilterState { - // The name of the Object in the per-request filterState, which is an - // Envoy::Http::Hashable object. If there is no data associated with the key, - // or the stored object is not Envoy::Http::Hashable, no hash will be produced. - string key = 1; - } - - oneof policy_specifier { - // Header hash policy. - Header header = 1; - - // Cookie hash policy. - Cookie cookie = 2; - - // Connection properties hash policy. - ConnectionProperties connection_properties = 3; - - // Query parameter hash policy. - QueryParameter query_parameter = 5; - - // Filter state hash policy. - FilterState filter_state = 6; - } - - // The flag that short-circuits the hash computing. This field provides a - // 'fallback' style of configuration: "if a terminal policy doesn't work, - // fallback to rest of the policy list", it saves time when the terminal - // policy works. - // - // If true, and there is already a hash computed, ignore rest of the - // list of hash polices. - // For example, if the following hash methods are configured: - // - // ========= ======== - // specifier terminal - // ========= ======== - // Header A true - // Header B false - // Header C false - // ========= ======== - // - // The generateHash process ends if policy "header A" generates a hash, as - // it's a terminal policy. - bool terminal = 4; - } - - repeated HashPolicy hash_policy = 15; - - RetryPolicy retry_policy = 9; - - // Specifies the maximum stream duration for this route. - MaxStreamDuration max_stream_duration = 36; -} - -// .. attention:: -// -// Internally, Envoy always uses the HTTP/2 *:authority* header to represent the HTTP/1 *Host* -// header. Thus, if attempting to match on *Host*, match on *:authority* instead. -// -// .. attention:: -// -// To route on HTTP method, use the special HTTP/2 *:method* header. This works for both -// HTTP/1 and HTTP/2 as Envoy normalizes headers. E.g., -// -// .. code-block:: json -// -// { -// "name": ":method", -// "exact_match": "POST" -// } -// -// .. attention:: -// In the absence of any header match specifier, match will default to :ref:`present_match -// <envoy_api_field_config.route.v3.HeaderMatcher.present_match>`. i.e, a request that has the :ref:`name -// <envoy_api_field_config.route.v3.HeaderMatcher.name>` header will match, regardless of the header's -// value. -// -// [#next-major-version: HeaderMatcher should be refactored to use StringMatcher.] -// [#next-free-field: 12] -message HeaderMatcher { - // Specifies the name of the header in the request. - string name = 1; - - // Specifies how the header match will be performed to route the request. - oneof header_match_specifier { - // If specified, header match will be performed based on the value of the header. - string exact_match = 4; - - // If specified, this regex string is a regular expression rule which implies the entire request - // header value must match the regex. The rule will not match if only a subsequence of the - // request header value matches the regex. - type.matcher.v3.RegexMatcher safe_regex_match = 11; - - // If specified, header match will be performed based on range. - // The rule will match if the request header value is within this range. - // The entire request header value must represent an integer in base 10 notation: consisting of - // an optional plus or minus sign followed by a sequence of digits. The rule will not match if - // the header value does not represent an integer. Match will fail for empty values, floating - // point numbers or if only a subsequence of the header value is an integer. - // - // Examples: - // - // * For range [-10,0), route will match for header value -1, but not for 0, "somestring", 10.9, - // "-1somestring" - type.v3.Int64Range range_match = 6; - - // If specified, header match will be performed based on whether the header is in the - // request. - bool present_match = 7; - - // If specified, header match will be performed based on the prefix of the header value. - // Note: empty prefix is not allowed, please use present_match instead. - // - // Examples: - // - // * The prefix *abcd* matches the value *abcdxyz*, but not for *abcxyz*. - string prefix_match = 9; - - // If specified, header match will be performed based on the suffix of the header value. - // Note: empty suffix is not allowed, please use present_match instead. - // - // Examples: - // - // * The suffix *abcd* matches the value *xyzabcd*, but not for *xyzbcd*. - string suffix_match = 10; - } - - // If specified, the match result will be inverted before checking. Defaults to false. - // - // Examples: - // - // * The regex ``\d{3}`` does not match the value *1234*, so it will match when inverted. - // * The range [-10,0) will match the value -1, so it will not match when inverted. - bool invert_match = 8; -} - -// Query parameter matching treats the query string of a request's :path header -// as an ampersand-separated list of keys and/or key=value elements. -// [#next-free-field: 7] -message QueryParameterMatcher { -} - -// [#protodoc-title: HTTP route configuration] -// * Routing :ref:`architecture overview <arch_overview_http_routing>` -// * HTTP :ref:`router filter <config_http_filters_router>` - -// [#next-free-field: 11] -message RouteConfiguration { - // The name of the route configuration. For example, it might match - // :ref:`route_config_name - // <envoy_api_field_extensions.filters.network.http_connection_manager.v3.Rds.route_config_name>` in - // :ref:`envoy_api_msg_extensions.filters.network.http_connection_manager.v3.Rds`. - string name = 1; - - // An array of virtual hosts that make up the route table. - repeated VirtualHost virtual_hosts = 2; -} - -message RedirectAction { -} - -message FilterConfig { - // The filter config. - google.protobuf.Any config = 1; - - // If true, the filter is optional, meaning that if the client does - // not support the specified filter, it may ignore the map entry rather - // than rejecting the config. - bool is_optional = 2; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/router.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/router.proto deleted file mode 100644 index 00b11b3712..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/router.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2021 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.filters.http.router.v3; - -// [#protodoc-title: Router] -// Router :ref:`configuration overview <config_http_filters_router>`. -// [#extension: envoy.filters.http.router] - -// We don't actually use any of the fields in this message, but we need -// the message itself to signify which filter to use. -message Router { -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/string.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/string.proto deleted file mode 100644 index d7e773089d..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/string.proto +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.type.matcher.v3; - -import "src/proto/grpc/testing/xds/v3/regex.proto"; - -message StringMatcher { - oneof match_pattern { - // The input string must match exactly the string specified here. - // - // Examples: - // - // * *abc* only matches the value *abc*. - string exact = 1; - - // The input string must have the prefix specified here. - // Note: empty prefix is not allowed, please use regex instead. - // - // Examples: - // - // * *abc* matches the value *abc.xyz* - string prefix = 2; - - // The input string must have the suffix specified here. - // Note: empty prefix is not allowed, please use regex instead. - // - // Examples: - // - // * *abc* matches the value *xyz.abc* - string suffix = 3; - - // The input string must match the regular expression specified here. - RegexMatcher safe_regex = 5; - - // The input string must have the substring specified here. - // Note: empty contains match is not allowed, please use regex instead. - // - // Examples: - // - // * *abc* matches the value *xyz.abc.def* - string contains = 7; - } - - // If true, indicates the exact/prefix/suffix matching should be case insensitive. This has no - // effect for the safe_regex match. - // For example, the matcher *data* will match both input string *Data* and *data* if set to true. - bool ignore_case = 6; -} diff --git a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/tls.proto b/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/tls.proto deleted file mode 100644 index b2fc4532d8..0000000000 --- a/contrib/libs/grpc/src/proto/grpc/testing/xds/v3/tls.proto +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright 2020 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Local copy of Envoy xDS proto file, used for testing only. - -syntax = "proto3"; - -package envoy.extensions.transport_sockets.tls.v3; - -import "src/proto/grpc/testing/xds/v3/base.proto"; -import "src/proto/grpc/testing/xds/v3/extension.proto"; -import "src/proto/grpc/testing/xds/v3/string.proto"; - -import "google/protobuf/wrappers.proto"; - -// Indicates a certificate to be obtained from a named CertificateProvider plugin instance. -// The plugin instances are defined in the client's bootstrap file. -// The plugin allows certificates to be fetched/refreshed over the network asynchronously with -// respect to the TLS handshake. -// [#not-implemented-hide:] -message CertificateProviderPluginInstance { - // Provider instance name. If not present, defaults to "default". - // - // Instance names should generally be defined not in terms of the underlying provider - // implementation (e.g., "file_watcher") but rather in terms of the function of the - // certificates (e.g., "foo_deployment_identity"). - string instance_name = 1; - - // Opaque name used to specify certificate instances or types. For example, "ROOTCA" to specify - // a root-certificate (validation context) or "example.com" to specify a certificate for a - // particular domain. Not all provider instances will actually use this field, so the value - // defaults to the empty string. - string certificate_name = 2; -} - -message CertificateValidationContext { - // Certificate provider instance for fetching TLS certificates. - // - // Only one of *trusted_ca* and *ca_certificate_provider_instance* may be specified. - // [#not-implemented-hide:] - CertificateProviderPluginInstance ca_certificate_provider_instance = 13; - - // An optional list of base64-encoded SHA-256 hashes. If specified, Envoy will verify that the - // SHA-256 of the DER-encoded Subject Public Key Information (SPKI) of the presented certificate - // matches one of the specified values. - // - // A base64-encoded SHA-256 of the Subject Public Key Information (SPKI) of the certificate - // can be generated with the following command: - // - // .. code-block:: bash - // - // $ openssl x509 -in path/to/client.crt -noout -pubkey - // | openssl pkey -pubin -outform DER - // | openssl dgst -sha256 -binary - // | openssl enc -base64 - // NvqYIYSbgK2vCJpQhObf77vv+bQWtc5ek5RIOwPiC9A= - // - // This is the format used in HTTP Public Key Pinning. - // - // When both: - // :ref:`verify_certificate_hash - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.verify_certificate_hash>` and - // :ref:`verify_certificate_spki - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.verify_certificate_spki>` are specified, - // a hash matching value from either of the lists will result in the certificate being accepted. - // - // .. attention:: - // - // This option is preferred over :ref:`verify_certificate_hash - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.verify_certificate_hash>`, - // because SPKI is tied to a private key, so it doesn't change when the certificate - // is renewed using the same private key. - repeated string verify_certificate_spki = 3; - - // An optional list of hex-encoded SHA-256 hashes. If specified, Envoy will verify that - // the SHA-256 of the DER-encoded presented certificate matches one of the specified values. - // - // A hex-encoded SHA-256 of the certificate can be generated with the following command: - // - // .. code-block:: bash - // - // $ openssl x509 -in path/to/client.crt -outform DER | openssl dgst -sha256 | cut -d" " -f2 - // df6ff72fe9116521268f6f2dd4966f51df479883fe7037b39f75916ac3049d1a - // - // A long hex-encoded and colon-separated SHA-256 (a.k.a. "fingerprint") of the certificate - // can be generated with the following command: - // - // .. code-block:: bash - // - // $ openssl x509 -in path/to/client.crt -noout -fingerprint -sha256 | cut -d"=" -f2 - // DF:6F:F7:2F:E9:11:65:21:26:8F:6F:2D:D4:96:6F:51:DF:47:98:83:FE:70:37:B3:9F:75:91:6A:C3:04:9D:1A - // - // Both of those formats are acceptable. - // - // When both: - // :ref:`verify_certificate_hash - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.verify_certificate_hash>` and - // :ref:`verify_certificate_spki - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.verify_certificate_spki>` are specified, - // a hash matching value from either of the lists will result in the certificate being accepted. - repeated string verify_certificate_hash = 2; - - // An optional list of Subject Alternative name matchers. If specified, Envoy will verify that the - // Subject Alternative Name of the presented certificate matches one of the specified matchers. - // - // When a certificate has wildcard DNS SAN entries, to match a specific client, it should be - // configured with exact match type in the :ref:`string matcher <envoy_v3_api_msg_type.matcher.v3.StringMatcher>`. - // For example if the certificate has "\*.example.com" as DNS SAN entry, to allow only "api.example.com", - // it should be configured as shown below. - // - // .. code-block:: yaml - // - // match_subject_alt_names: - // exact: "api.example.com" - // - // .. attention:: - // - // Subject Alternative Names are easily spoofable and verifying only them is insecure, - // therefore this option must be used together with :ref:`trusted_ca - // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.trusted_ca>`. - repeated type.matcher.v3.StringMatcher match_subject_alt_names = 9; - - // [#not-implemented-hide:] Must present signed certificate time-stamp. - google.protobuf.BoolValue require_signed_certificate_timestamp = 6; - - // An optional `certificate revocation list - // <https://en.wikipedia.org/wiki/Certificate_revocation_list>`_ - // (in PEM format). If specified, Envoy will verify that the presented peer - // certificate has not been revoked by this CRL. If this DataSource contains - // multiple CRLs, all of them will be used. Note that if a CRL is provided - // for any certificate authority in a trust chain, a CRL must be provided - // for all certificate authorities in that chain. Failure to do so will - // result in verification failure for both revoked and unrevoked certificates - // from that chain. - config.core.v3.DataSource crl = 7; - - // The configuration of an extension specific certificate validator. - // If specified, all validation is done by the specified validator, - // and the behavior of all other validation settings is defined by the specified validator (and may be entirely ignored, unused, and unvalidated). - // Refer to the documentation for the specified validator. If you do not want a custom validation algorithm, do not set this field. - // [#extension-category: envoy.tls.cert_validator] - config.core.v3.TypedExtensionConfig custom_validator_config = 12; -} - -message UpstreamTlsContext { - // Common TLS context settings. - // - // .. attention:: - // - // Server certificate verification is not enabled by default. Configure - // :ref:`trusted_ca<envoy_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.trusted_ca>` to enable - // verification. - CommonTlsContext common_tls_context = 1; -} - -message DownstreamTlsContext { - enum OcspStaplePolicy { - // OCSP responses are optional. If an OCSP response is absent - // or expired, the associated certificate will be used for - // connections without an OCSP staple. - LENIENT_STAPLING = 0; - - // OCSP responses are optional. If an OCSP response is absent, - // the associated certificate will be used without an - // OCSP staple. If a response is provided but is expired, - // the associated certificate will not be used for - // subsequent connections. If no suitable certificate is found, - // the connection is rejected. - STRICT_STAPLING = 1; - - // OCSP responses are required. Configuration will fail if - // a certificate is provided without an OCSP response. If a - // response expires, the associated certificate will not be - // used connections. If no suitable certificate is found, the - // connection is rejected. - MUST_STAPLE = 2; - } - - // Common TLS context settings. - CommonTlsContext common_tls_context = 1; - - // If specified, Envoy will reject connections without a valid client - // certificate. - google.protobuf.BoolValue require_client_certificate = 2; - - // If specified, Envoy will reject connections without a valid and matching SNI. - // [#not-implemented-hide:] - google.protobuf.BoolValue require_sni = 3; - - // Config for whether to use certificates if they do not have - // an accompanying OCSP response or if the response expires at runtime. - // Defaults to LENIENT_STAPLING - OcspStaplePolicy ocsp_staple_policy = 8; -} - - -// TLS context shared by both client and server TLS contexts. -// [#next-free-field: 14] -message CommonTlsContext { - // Similar to CertificateProvider above, but allows the provider instances to be configured on - // the client side instead of being sent from the control plane. - message CertificateProviderInstance { - // Provider instance name. This name must be defined in the client's configuration (e.g., a - // bootstrap file) to correspond to a provider instance (i.e., the same data in the typed_config - // field that would be sent in the CertificateProvider message if the config was sent by the - // control plane). If not present, defaults to "default". - // - // Instance names should generally be defined not in terms of the underlying provider - // implementation (e.g., "file_watcher") but rather in terms of the function of the - // certificates (e.g., "foo_deployment_identity"). - string instance_name = 1; - - // Opaque name used to specify certificate instances or types. For example, "ROOTCA" to specify - // a root-certificate (validation context) or "example.com" to specify a certificate for a - // particular domain. Not all provider instances will actually use this field, so the value - // defaults to the empty string. - string certificate_name = 2; - } - - message CombinedCertificateValidationContext { - // How to validate peer certificates. - CertificateValidationContext default_validation_context = 1; - - // Certificate provider instance for fetching validation context. - // Only one of validation_context_sds_secret_config, validation_context_certificate_provider, - // or validation_context_certificate_provider_instance may be used. - CertificateProviderInstance validation_context_certificate_provider_instance = 4; - } - - message TlsParameters {} - - // TLS protocol versions, cipher suites etc. - TlsParameters tls_params = 1; - - message TlsCertificate {} - - // :ref:`Multiple TLS certificates <arch_overview_ssl_cert_select>` can be associated with the - // same context to allow both RSA and ECDSA certificates. - // - // Only a single TLS certificate is supported in client contexts. In server contexts, the first - // RSA certificate is used for clients that only support RSA and the first ECDSA certificate is - // used for clients that support ECDSA. - // - // Only one of *tls_certificates*, *tls_certificate_sds_secret_configs*, - // and *tls_certificate_provider_instance* may be used. - // [#next-major-version: These mutually exclusive fields should ideally be in a oneof, but it's - // not legal to put a repeated field in a oneof. In the next major version, we should rework - // this to avoid this problem.] - repeated TlsCertificate tls_certificates = 2; - - message SdsSecretConfig {} - - // Configs for fetching TLS certificates via SDS API. Note SDS API allows certificates to be - // fetched/refreshed over the network asynchronously with respect to the TLS handshake. - // - // The same number and types of certificates as :ref:`tls_certificates <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CommonTlsContext.tls_certificates>` - // are valid in the the certificates fetched through this setting. - // - // Only one of *tls_certificates*, *tls_certificate_sds_secret_configs*, - // and *tls_certificate_provider_instance* may be used. - // [#next-major-version: These mutually exclusive fields should ideally be in a oneof, but it's - // not legal to put a repeated field in a oneof. In the next major version, we should rework - // this to avoid this problem.] - repeated SdsSecretConfig tls_certificate_sds_secret_configs = 6; - - // Certificate provider instance for fetching TLS certs. - // - // Only one of *tls_certificates*, *tls_certificate_sds_secret_configs*, - // and *tls_certificate_provider_instance* may be used. - // [#not-implemented-hide:] - CertificateProviderPluginInstance tls_certificate_provider_instance = 14; - - // Certificate provider instance for fetching TLS certificates. - CertificateProviderInstance tls_certificate_certificate_provider_instance = 11; - - oneof validation_context_type { - // How to validate peer certificates. - CertificateValidationContext validation_context = 3; - - // Config for fetching validation context via SDS API. Note SDS API allows certificates to be - // fetched/refreshed over the network asynchronously with respect to the TLS handshake. - SdsSecretConfig validation_context_sds_secret_config = 7; - - // Combined certificate validation context holds a default CertificateValidationContext - // and SDS config. When SDS server returns dynamic CertificateValidationContext, both dynamic - // and default CertificateValidationContext are merged into a new CertificateValidationContext - // for validation. This merge is done by Message::MergeFrom(), so dynamic - // CertificateValidationContext overwrites singular fields in default - // CertificateValidationContext, and concatenates repeated fields to default - // CertificateValidationContext, and logical OR is applied to boolean fields. - CombinedCertificateValidationContext combined_validation_context = 8; - } - - // Custom TLS handshaker. If empty, defaults to native TLS handshaking - // behavior. - config.core.v3.TypedExtensionConfig custom_handshaker = 13; -} diff --git a/contrib/libs/grpc/src/proto/math/math.proto b/contrib/libs/grpc/src/proto/math/math.proto deleted file mode 100644 index e60ba0d7cd..0000000000 --- a/contrib/libs/grpc/src/proto/math/math.proto +++ /dev/null @@ -1,65 +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. - -syntax = "proto3"; - -package math; - -message DivArgs { - int64 dividend = 1; - int64 divisor = 2; -} - -message DivReply { - int64 quotient = 1; - int64 remainder = 2; -} - -message FibArgs { - int64 limit = 1; -} - -message Num { - int64 num = 1; -} - -message FibReply { - int64 count = 1; -} - -service Math { - // Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient - // and remainder. - rpc Div (DivArgs) returns (DivReply) { - } - - // DivMany accepts an arbitrary number of division args from the client stream - // and sends back the results in the reply stream. The stream continues until - // the client closes its end; the server does the same after sending all the - // replies. The stream ends immediately if either end aborts. - rpc DivMany (stream DivArgs) returns (stream DivReply) { - } - - // Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib - // generates up to limit numbers; otherwise it continues until the call is - // canceled. Unlike Fib above, Fib has no final FibReply. - rpc Fib (FibArgs) returns (stream Num) { - } - - // Sum sums a stream of numbers, returning the final result once the stream - // is closed. - rpc Sum (stream Num) returns (Num) { - } -} diff --git a/contrib/libs/grpc/src/python/grpcio/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio/.yandex_meta/licenses.list.txt deleted file mode 100644 index 94d1b32617..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,64 +0,0 @@ -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2019 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== -# Copyright 2019 The gRPC authors. - - -====================COPYRIGHT==================== -# Copyright 2020 The gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2018 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2019 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 The gRPC Authors diff --git a/contrib/libs/grpc/src/python/grpcio/_parallel_compile_patch.py b/contrib/libs/grpc/src/python/grpcio/_parallel_compile_patch.py deleted file mode 100644 index e4d50c3831..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/_parallel_compile_patch.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2018 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. -"""Patches the compile() to allow enable parallel compilation of C/C++. - -build_ext has lots of C/C++ files and normally them one by one. -Enabling parallel build helps a lot. -""" - -import distutils.ccompiler -import os - -try: - BUILD_EXT_COMPILER_JOBS = int( - os.environ['GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS']) -except KeyError: - import multiprocessing - BUILD_EXT_COMPILER_JOBS = multiprocessing.cpu_count() -except ValueError: - BUILD_EXT_COMPILER_JOBS = 1 - - -# monkey-patch for parallel compilation -def _parallel_compile(self, - sources, - output_dir=None, - macros=None, - include_dirs=None, - debug=0, - extra_preargs=None, - extra_postargs=None, - depends=None): - # setup the same way as distutils.ccompiler.CCompiler - # https://github.com/python/cpython/blob/31368a4f0e531c19affe2a1becd25fc316bc7501/Lib/distutils/ccompiler.py#L564 - macros, objects, extra_postargs, pp_opts, build = self._setup_compile( - str(output_dir), macros, include_dirs, sources, depends, extra_postargs) - cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) - - def _compile_single_file(obj): - try: - src, ext = build[obj] - except KeyError: - return - self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) - - # run compilation of individual files in parallel - import multiprocessing.pool - multiprocessing.pool.ThreadPool(BUILD_EXT_COMPILER_JOBS).map( - _compile_single_file, objects) - return objects - - -def monkeypatch_compile_maybe(): - """Monkeypatching is dumb, but the build speed gain is worth it.""" - if BUILD_EXT_COMPILER_JOBS > 1: - distutils.ccompiler.CCompiler.compile = _parallel_compile diff --git a/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py b/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py deleted file mode 100644 index 377cc7a9f3..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2016 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. -"""Patches the spawn() command for windows compilers. - -Windows has an 8191 character command line limit, but some compilers -support an @command_file directive where command_file is a file -containing the full command line. -""" - -from distutils import ccompiler -import os -import os.path -import shutil -import sys -import tempfile - -MAX_COMMAND_LENGTH = 8191 - -_classic_spawn = ccompiler.CCompiler.spawn - - -def _commandfile_spawn(self, command): - command_length = sum([len(arg) for arg in command]) - if os.name == 'nt' and command_length > MAX_COMMAND_LENGTH: - # Even if this command doesn't support the @command_file, it will - # fail as is so we try blindly - print('Command line length exceeded, using command file') - print(' '.join(command)) - temporary_directory = tempfile.mkdtemp() - command_filename = os.path.abspath( - os.path.join(temporary_directory, 'command')) - with open(command_filename, 'w') as command_file: - escaped_args = [ - '"' + arg.replace('\\', '\\\\') + '"' for arg in command[1:] - ] - command_file.write(' '.join(escaped_args)) - modified_command = command[:1] + ['@{}'.format(command_filename)] - try: - _classic_spawn(self, modified_command) - finally: - shutil.rmtree(temporary_directory) - else: - _classic_spawn(self, command) - - -def monkeypatch_spawn(): - """Monkeypatching is dumb, but it's either that or we become maintainers of - something much, much bigger.""" - ccompiler.CCompiler.spawn = _commandfile_spawn diff --git a/contrib/libs/grpc/src/python/grpcio/commands.py b/contrib/libs/grpc/src/python/grpcio/commands.py deleted file mode 100644 index d1a756e185..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/commands.py +++ /dev/null @@ -1,350 +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. -"""Provides distutils command classes for the GRPC Python setup process.""" - -# NOTE(https://github.com/grpc/grpc/issues/24028): allow setuptools to monkey -# patch distutils -import setuptools # isort:skip - -import glob -import os -import os.path -import shutil -import subprocess -import sys -import sysconfig -import traceback - -from setuptools.command import build_ext -from setuptools.command import build_py -import support - -PYTHON_STEM = os.path.dirname(os.path.abspath(__file__)) -GRPC_STEM = os.path.abspath(PYTHON_STEM + '../../../../') -PROTO_STEM = os.path.join(GRPC_STEM, 'src', 'proto') -PROTO_GEN_STEM = os.path.join(GRPC_STEM, 'src', 'python', 'gens') -CYTHON_STEM = os.path.join(PYTHON_STEM, 'grpc', '_cython') - - -class CommandError(Exception): - """Simple exception class for GRPC custom commands.""" - - -# TODO(atash): Remove this once PyPI has better Linux bdist support. See -# https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported -def _get_grpc_custom_bdist(decorated_basename, target_bdist_basename): - """Returns a string path to a bdist file for Linux to install. - - If we can retrieve a pre-compiled bdist from online, uses it. Else, emits a - warning and builds from source. - """ - # TODO(atash): somehow the name that's returned from `wheel` is different - # between different versions of 'wheel' (but from a compatibility standpoint, - # the names are compatible); we should have some way of determining name - # compatibility in the same way `wheel` does to avoid having to rename all of - # the custom wheels that we build/upload to GCS. - - # Break import style to ensure that setup.py has had a chance to install the - # relevant package. - from six.moves.urllib import request - decorated_path = decorated_basename + GRPC_CUSTOM_BDIST_EXT - try: - url = BINARIES_REPOSITORY + '/{target}'.format(target=decorated_path) - bdist_data = request.urlopen(url).read() - except IOError as error: - raise CommandError('{}\n\nCould not find the bdist {}: {}'.format( - traceback.format_exc(), decorated_path, error.message)) - # Our chosen local bdist path. - bdist_path = target_bdist_basename + GRPC_CUSTOM_BDIST_EXT - try: - with open(bdist_path, 'w') as bdist_file: - bdist_file.write(bdist_data) - except IOError as error: - raise CommandError('{}\n\nCould not write grpcio bdist: {}'.format( - traceback.format_exc(), error.message)) - return bdist_path - - -class SphinxDocumentation(setuptools.Command): - """Command to generate documentation via sphinx.""" - - description = 'generate sphinx documentation' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - # We import here to ensure that setup.py has had a chance to install the - # relevant package eggs first. - import sphinx.cmd.build - source_dir = os.path.join(GRPC_STEM, 'doc', 'python', 'sphinx') - target_dir = os.path.join(GRPC_STEM, 'doc', 'build') - exit_code = sphinx.cmd.build.build_main( - ['-b', 'html', '-W', '--keep-going', source_dir, target_dir]) - if exit_code != 0: - raise CommandError( - "Documentation generation has warnings or errors") - - -class BuildProjectMetadata(setuptools.Command): - """Command to generate project metadata in a module.""" - - description = 'build grpcio project metadata files' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - with open(os.path.join(PYTHON_STEM, 'grpc/_grpcio_metadata.py'), - 'w') as module_file: - module_file.write('__version__ = """{}"""'.format( - self.distribution.get_version())) - - -class BuildPy(build_py.build_py): - """Custom project build command.""" - - def run(self): - self.run_command('build_project_metadata') - build_py.build_py.run(self) - - -def _poison_extensions(extensions, message): - """Includes a file that will always fail to compile in all extensions.""" - poison_filename = os.path.join(PYTHON_STEM, 'poison.c') - with open(poison_filename, 'w') as poison: - poison.write('#error {}'.format(message)) - for extension in extensions: - extension.sources = [poison_filename] - - -def check_and_update_cythonization(extensions): - """Replace .pyx files with their generated counterparts and return whether or - not cythonization still needs to occur.""" - for extension in extensions: - generated_pyx_sources = [] - other_sources = [] - for source in extension.sources: - base, file_ext = os.path.splitext(source) - if file_ext == '.pyx': - generated_pyx_source = next((base + gen_ext for gen_ext in ( - '.c', - '.cpp', - ) if os.path.isfile(base + gen_ext)), None) - if generated_pyx_source: - generated_pyx_sources.append(generated_pyx_source) - else: - sys.stderr.write('Cython-generated files are missing...\n') - return False - else: - other_sources.append(source) - extension.sources = generated_pyx_sources + other_sources - sys.stderr.write('Found cython-generated files...\n') - return True - - -def try_cythonize(extensions, linetracing=False, mandatory=True): - """Attempt to cythonize the extensions. - - Args: - extensions: A list of `distutils.extension.Extension`. - linetracing: A bool indicating whether or not to enable linetracing. - mandatory: Whether or not having Cython-generated files is mandatory. If it - is, extensions will be poisoned when they can't be fully generated. - """ - try: - # Break import style to ensure we have access to Cython post-setup_requires - import Cython.Build - except ImportError: - if mandatory: - sys.stderr.write( - "This package needs to generate C files with Cython but it cannot. " - "Poisoning extension sources to disallow extension commands...") - _poison_extensions( - extensions, - "Extensions have been poisoned due to missing Cython-generated code." - ) - return extensions - cython_compiler_directives = {} - if linetracing: - additional_define_macros = [('CYTHON_TRACE_NOGIL', '1')] - cython_compiler_directives['linetrace'] = True - return Cython.Build.cythonize( - extensions, - include_path=[ - include_dir for extension in extensions - for include_dir in extension.include_dirs - ] + [CYTHON_STEM], - compiler_directives=cython_compiler_directives) - - -class BuildExt(build_ext.build_ext): - """Custom build_ext command to enable compiler-specific flags.""" - - C_OPTIONS = { - 'unix': ('-pthread',), - 'msvc': (), - } - LINK_OPTIONS = {} - - def get_ext_filename(self, ext_name): - # since python3.5, python extensions' shared libraries use a suffix that corresponds to the value - # of sysconfig.get_config_var('EXT_SUFFIX') and contains info about the architecture the library targets. - # E.g. on x64 linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so" - # When crosscompiling python wheels, we need to be able to override this suffix - # so that the resulting file name matches the target architecture and we end up with a well-formed - # wheel. - filename = build_ext.build_ext.get_ext_filename(self, ext_name) - orig_ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') - new_ext_suffix = os.getenv('GRPC_PYTHON_OVERRIDE_EXT_SUFFIX') - if new_ext_suffix and filename.endswith(orig_ext_suffix): - filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix - return filename - - def build_extensions(self): - - def compiler_ok_with_extra_std(): - """Test if default compiler is okay with specifying c++ version - when invoked in C mode. GCC is okay with this, while clang is not. - """ - try: - # TODO(lidiz) Remove the generated a.out for success tests. - cc_test = subprocess.Popen(['cc', '-x', 'c', '-std=c++11', '-'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - _, cc_err = cc_test.communicate(input=b'int main(){return 0;}') - return not 'invalid argument' in str(cc_err) - except: - sys.stderr.write('Non-fatal exception:' + - traceback.format_exc() + '\n') - return False - - # This special conditioning is here due to difference of compiler - # behavior in gcc and clang. The clang doesn't take --stdc++11 - # flags but gcc does. Since the setuptools of Python only support - # all C or all C++ compilation, the mix of C and C++ will crash. - # *By default*, macOS and FreBSD use clang and Linux use gcc - # - # If we are not using a permissive compiler that's OK with being - # passed wrong std flags, swap out compile function by adding a filter - # for it. - if not compiler_ok_with_extra_std(): - old_compile = self.compiler._compile - - def new_compile(obj, src, ext, cc_args, extra_postargs, pp_opts): - if src.endswith('.c'): - extra_postargs = [ - arg for arg in extra_postargs if not '-std=c++' in arg - ] - elif src.endswith('.cc') or src.endswith('.cpp'): - extra_postargs = [ - arg for arg in extra_postargs if not '-std=gnu99' in arg - ] - return old_compile(obj, src, ext, cc_args, extra_postargs, - pp_opts) - - self.compiler._compile = new_compile - - compiler = self.compiler.compiler_type - if compiler in BuildExt.C_OPTIONS: - for extension in self.extensions: - extension.extra_compile_args += list( - BuildExt.C_OPTIONS[compiler]) - if compiler in BuildExt.LINK_OPTIONS: - for extension in self.extensions: - extension.extra_link_args += list( - BuildExt.LINK_OPTIONS[compiler]) - if not check_and_update_cythonization(self.extensions): - self.extensions = try_cythonize(self.extensions) - try: - build_ext.build_ext.build_extensions(self) - except Exception as error: - formatted_exception = traceback.format_exc() - support.diagnose_build_ext_error(self, error, formatted_exception) - raise CommandError( - "Failed `build_ext` step:\n{}".format(formatted_exception)) - - -class Gather(setuptools.Command): - """Command to gather project dependencies.""" - - description = 'gather dependencies for grpcio' - user_options = [ - ('test', 't', 'flag indicating to gather test dependencies'), - ('install', 'i', 'flag indicating to gather install dependencies') - ] - - def initialize_options(self): - self.test = False - self.install = False - - def finalize_options(self): - # distutils requires this override. - pass - - def run(self): - if self.install and self.distribution.install_requires: - self.distribution.fetch_build_eggs( - self.distribution.install_requires) - if self.test and self.distribution.tests_require: - self.distribution.fetch_build_eggs(self.distribution.tests_require) - - -class Clean(setuptools.Command): - """Command to clean build artifacts.""" - - description = 'Clean build artifacts.' - user_options = [ - ('all', 'a', 'a phony flag to allow our script to continue'), - ] - - _FILE_PATTERNS = ( - 'python_build', - 'src/python/grpcio/__pycache__/', - 'src/python/grpcio/grpc/_cython/cygrpc.cpp', - 'src/python/grpcio/grpc/_cython/*.so', - 'src/python/grpcio/grpcio.egg-info/', - ) - _CURRENT_DIRECTORY = os.path.normpath( - os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../..")) - - def initialize_options(self): - self.all = False - - def finalize_options(self): - pass - - def run(self): - for path_spec in self._FILE_PATTERNS: - this_glob = os.path.normpath( - os.path.join(Clean._CURRENT_DIRECTORY, path_spec)) - abs_paths = glob.glob(this_glob) - for path in abs_paths: - if not str(path).startswith(Clean._CURRENT_DIRECTORY): - raise ValueError( - "Cowardly refusing to delete {}.".format(path)) - print("Removing {}".format(os.path.relpath(path))) - if os.path.isfile(path): - os.remove(str(path)) - else: - shutil.rmtree(str(path)) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py b/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py deleted file mode 100644 index 338b05b1ca..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py +++ /dev/null @@ -1,1292 +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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! - -CORE_SOURCE_FILES = [ - 'src/core/ext/filters/census/grpc_context.cc', - 'src/core/ext/filters/client_channel/backend_metric.cc', - 'src/core/ext/filters/client_channel/backup_poller.cc', - 'src/core/ext/filters/client_channel/channel_connectivity.cc', - 'src/core/ext/filters/client_channel/client_channel.cc', - 'src/core/ext/filters/client_channel/client_channel_channelz.cc', - 'src/core/ext/filters/client_channel/client_channel_factory.cc', - 'src/core/ext/filters/client_channel/client_channel_plugin.cc', - 'src/core/ext/filters/client_channel/config_selector.cc', - 'src/core/ext/filters/client_channel/dynamic_filters.cc', - 'src/core/ext/filters/client_channel/global_subchannel_pool.cc', - 'src/core/ext/filters/client_channel/health/health_check_client.cc', - 'src/core/ext/filters/client_channel/http_connect_handshaker.cc', - 'src/core/ext/filters/client_channel/http_proxy.cc', - 'src/core/ext/filters/client_channel/lb_policy.cc', - 'src/core/ext/filters/client_channel/lb_policy/address_filtering.cc', - 'src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', - 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', - 'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', - 'src/core/ext/filters/client_channel/lb_policy/priority/priority.cc', - 'src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc', - 'src/core/ext/filters/client_channel/lb_policy/rls/rls.cc', - 'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', - 'src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/cds.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc', - 'src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc', - 'src/core/ext/filters/client_channel/lb_policy_registry.cc', - 'src/core/ext/filters/client_channel/local_subchannel_pool.cc', - 'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', - 'src/core/ext/filters/client_channel/resolver.cc', - 'src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', - 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', - 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', - 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', - 'src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc', - 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', - 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc', - 'src/core/ext/filters/client_channel/resolver_registry.cc', - 'src/core/ext/filters/client_channel/resolver_result_parsing.cc', - 'src/core/ext/filters/client_channel/retry_filter.cc', - 'src/core/ext/filters/client_channel/retry_service_config.cc', - 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/server_address.cc', - 'src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc', - 'src/core/ext/filters/client_channel/subchannel.cc', - 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', - 'src/core/ext/filters/client_idle/client_idle_filter.cc', - 'src/core/ext/filters/client_idle/idle_filter_state.cc', - 'src/core/ext/filters/deadline/deadline_filter.cc', - 'src/core/ext/filters/fault_injection/fault_injection_filter.cc', - 'src/core/ext/filters/fault_injection/service_config_parser.cc', - 'src/core/ext/filters/http/client/http_client_filter.cc', - 'src/core/ext/filters/http/client_authority_filter.cc', - 'src/core/ext/filters/http/http_filters_plugin.cc', - 'src/core/ext/filters/http/message_compress/message_compress_filter.cc', - 'src/core/ext/filters/http/message_compress/message_decompress_filter.cc', - 'src/core/ext/filters/http/server/http_server_filter.cc', - 'src/core/ext/filters/max_age/max_age_filter.cc', - 'src/core/ext/filters/message_size/message_size_filter.cc', - 'src/core/ext/filters/server_config_selector/server_config_selector.cc', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.cc', - 'src/core/ext/service_config/service_config.cc', - 'src/core/ext/service_config/service_config_parser.cc', - 'src/core/ext/transport/chttp2/alpn/alpn.cc', - 'src/core/ext/transport/chttp2/client/chttp2_connector.cc', - 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', - 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', - 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc', - 'src/core/ext/transport/chttp2/server/chttp2_server.cc', - 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc', - 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc', - 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc', - 'src/core/ext/transport/chttp2/transport/bin_decoder.cc', - 'src/core/ext/transport/chttp2/transport/bin_encoder.cc', - 'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', - 'src/core/ext/transport/chttp2/transport/chttp2_transport.cc', - 'src/core/ext/transport/chttp2/transport/context_list.cc', - 'src/core/ext/transport/chttp2/transport/flow_control.cc', - 'src/core/ext/transport/chttp2/transport/frame_data.cc', - 'src/core/ext/transport/chttp2/transport/frame_goaway.cc', - 'src/core/ext/transport/chttp2/transport/frame_ping.cc', - 'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc', - 'src/core/ext/transport/chttp2/transport/frame_settings.cc', - 'src/core/ext/transport/chttp2/transport/frame_window_update.cc', - 'src/core/ext/transport/chttp2/transport/hpack_encoder.cc', - 'src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc', - 'src/core/ext/transport/chttp2/transport/hpack_parser.cc', - 'src/core/ext/transport/chttp2/transport/hpack_parser_table.cc', - 'src/core/ext/transport/chttp2/transport/hpack_utils.cc', - 'src/core/ext/transport/chttp2/transport/http2_settings.cc', - 'src/core/ext/transport/chttp2/transport/huffsyms.cc', - 'src/core/ext/transport/chttp2/transport/parsing.cc', - 'src/core/ext/transport/chttp2/transport/stream_lists.cc', - 'src/core/ext/transport/chttp2/transport/stream_map.cc', - 'src/core/ext/transport/chttp2/transport/varint.cc', - 'src/core/ext/transport/chttp2/transport/writing.cc', - 'src/core/ext/transport/inproc/inproc_plugin.cc', - 'src/core/ext/transport/inproc/inproc_transport.cc', - 'src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c', - 'src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c', - 'src/core/ext/upb-generated/envoy/annotations/resource.upb.c', - 'src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c', - 'src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c', - 'src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c', - 'src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c', - 'src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c', - 'src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c', - 'src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c', - 'src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c', - 'src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c', - 'src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c', - 'src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c', - 'src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c', - 'src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c', - 'src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c', - 'src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c', - 'src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c', - 'src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c', - 'src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c', - 'src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c', - 'src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c', - 'src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c', - 'src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c', - 'src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c', - 'src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c', - 'src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c', - 'src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c', - 'src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c', - 'src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c', - 'src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c', - 'src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c', - 'src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c', - 'src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c', - 'src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c', - 'src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c', - 'src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c', - 'src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c', - 'src/core/ext/upb-generated/envoy/type/v3/http.upb.c', - 'src/core/ext/upb-generated/envoy/type/v3/percent.upb.c', - 'src/core/ext/upb-generated/envoy/type/v3/range.upb.c', - 'src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c', - 'src/core/ext/upb-generated/google/api/annotations.upb.c', - 'src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c', - 'src/core/ext/upb-generated/google/api/expr/v1alpha1/eval.upb.c', - 'src/core/ext/upb-generated/google/api/expr/v1alpha1/explain.upb.c', - 'src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c', - 'src/core/ext/upb-generated/google/api/expr/v1alpha1/value.upb.c', - 'src/core/ext/upb-generated/google/api/http.upb.c', - 'src/core/ext/upb-generated/google/protobuf/any.upb.c', - 'src/core/ext/upb-generated/google/protobuf/descriptor.upb.c', - 'src/core/ext/upb-generated/google/protobuf/duration.upb.c', - 'src/core/ext/upb-generated/google/protobuf/empty.upb.c', - 'src/core/ext/upb-generated/google/protobuf/struct.upb.c', - 'src/core/ext/upb-generated/google/protobuf/timestamp.upb.c', - 'src/core/ext/upb-generated/google/protobuf/wrappers.upb.c', - 'src/core/ext/upb-generated/google/rpc/status.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c', - 'src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c', - 'src/core/ext/upb-generated/udpa/annotations/migrate.upb.c', - 'src/core/ext/upb-generated/udpa/annotations/security.upb.c', - 'src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c', - 'src/core/ext/upb-generated/udpa/annotations/status.upb.c', - 'src/core/ext/upb-generated/udpa/annotations/versioning.upb.c', - 'src/core/ext/upb-generated/validate/validate.upb.c', - 'src/core/ext/upb-generated/xds/annotations/v3/status.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/authority.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/context_params.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/resource.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c', - 'src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c', - 'src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c', - 'src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c', - 'src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c', - 'src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/api/http.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c', - 'src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c', - 'src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c', - 'src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c', - 'src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c', - 'src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c', - 'src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c', - 'src/core/ext/upbdefs-generated/validate/validate.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c', - 'src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c', - 'src/core/ext/xds/certificate_provider_registry.cc', - 'src/core/ext/xds/certificate_provider_store.cc', - 'src/core/ext/xds/file_watcher_certificate_provider_factory.cc', - 'src/core/ext/xds/xds_api.cc', - 'src/core/ext/xds/xds_bootstrap.cc', - 'src/core/ext/xds/xds_certificate_provider.cc', - 'src/core/ext/xds/xds_channel_stack_modifier.cc', - 'src/core/ext/xds/xds_client.cc', - 'src/core/ext/xds/xds_client_stats.cc', - 'src/core/ext/xds/xds_http_fault_filter.cc', - 'src/core/ext/xds/xds_http_filters.cc', - 'src/core/ext/xds/xds_routing.cc', - 'src/core/ext/xds/xds_server_config_fetcher.cc', - 'src/core/lib/address_utils/parse_address.cc', - 'src/core/lib/address_utils/sockaddr_utils.cc', - 'src/core/lib/backoff/backoff.cc', - 'src/core/lib/channel/channel_args.cc', - 'src/core/lib/channel/channel_args_preconditioning.cc', - 'src/core/lib/channel/channel_stack.cc', - 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channelz.cc', - 'src/core/lib/channel/channelz_registry.cc', - 'src/core/lib/channel/connected_channel.cc', - 'src/core/lib/channel/handshaker.cc', - 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', - 'src/core/lib/compression/compression.cc', - 'src/core/lib/compression/compression_args.cc', - 'src/core/lib/compression/compression_internal.cc', - 'src/core/lib/compression/message_compress.cc', - 'src/core/lib/compression/stream_compression.cc', - 'src/core/lib/compression/stream_compression_gzip.cc', - 'src/core/lib/compression/stream_compression_identity.cc', - 'src/core/lib/config/core_configuration.cc', - 'src/core/lib/debug/stats.cc', - 'src/core/lib/debug/stats_data.cc', - 'src/core/lib/debug/trace.cc', - 'src/core/lib/event_engine/channel_args_endpoint_config.cc', - 'src/core/lib/event_engine/event_engine.cc', - 'src/core/lib/event_engine/event_engine_factory.cc', - 'src/core/lib/event_engine/memory_allocator.cc', - 'src/core/lib/event_engine/sockaddr.cc', - 'src/core/lib/gpr/alloc.cc', - 'src/core/lib/gpr/atm.cc', - 'src/core/lib/gpr/cpu_iphone.cc', - 'src/core/lib/gpr/cpu_linux.cc', - 'src/core/lib/gpr/cpu_posix.cc', - 'src/core/lib/gpr/cpu_windows.cc', - 'src/core/lib/gpr/env_linux.cc', - 'src/core/lib/gpr/env_posix.cc', - 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/log.cc', - 'src/core/lib/gpr/log_android.cc', - 'src/core/lib/gpr/log_linux.cc', - 'src/core/lib/gpr/log_posix.cc', - 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/string.cc', - 'src/core/lib/gpr/string_posix.cc', - 'src/core/lib/gpr/string_util_windows.cc', - 'src/core/lib/gpr/string_windows.cc', - 'src/core/lib/gpr/sync.cc', - 'src/core/lib/gpr/sync_abseil.cc', - 'src/core/lib/gpr/sync_posix.cc', - 'src/core/lib/gpr/sync_windows.cc', - 'src/core/lib/gpr/time.cc', - 'src/core/lib/gpr/time_posix.cc', - 'src/core/lib/gpr/time_precise.cc', - 'src/core/lib/gpr/time_windows.cc', - 'src/core/lib/gpr/tmpfile_msys.cc', - 'src/core/lib/gpr/tmpfile_posix.cc', - 'src/core/lib/gpr/tmpfile_windows.cc', - 'src/core/lib/gpr/wrap_memcpy.cc', - 'src/core/lib/gprpp/arena.cc', - 'src/core/lib/gprpp/examine_stack.cc', - 'src/core/lib/gprpp/fork.cc', - 'src/core/lib/gprpp/global_config_env.cc', - 'src/core/lib/gprpp/host_port.cc', - 'src/core/lib/gprpp/mpscq.cc', - 'src/core/lib/gprpp/stat_posix.cc', - 'src/core/lib/gprpp/stat_windows.cc', - 'src/core/lib/gprpp/status_helper.cc', - 'src/core/lib/gprpp/thd_posix.cc', - 'src/core/lib/gprpp/thd_windows.cc', - 'src/core/lib/gprpp/time_util.cc', - 'src/core/lib/http/format_request.cc', - 'src/core/lib/http/httpcli.cc', - 'src/core/lib/http/httpcli_security_connector.cc', - 'src/core/lib/http/parser.cc', - 'src/core/lib/iomgr/buffer_list.cc', - 'src/core/lib/iomgr/call_combiner.cc', - 'src/core/lib/iomgr/cfstream_handle.cc', - 'src/core/lib/iomgr/combiner.cc', - 'src/core/lib/iomgr/dualstack_socket_posix.cc', - 'src/core/lib/iomgr/endpoint.cc', - 'src/core/lib/iomgr/endpoint_cfstream.cc', - 'src/core/lib/iomgr/endpoint_pair_event_engine.cc', - 'src/core/lib/iomgr/endpoint_pair_posix.cc', - 'src/core/lib/iomgr/endpoint_pair_windows.cc', - 'src/core/lib/iomgr/error.cc', - 'src/core/lib/iomgr/error_cfstream.cc', - 'src/core/lib/iomgr/ev_apple.cc', - 'src/core/lib/iomgr/ev_epoll1_linux.cc', - 'src/core/lib/iomgr/ev_epollex_linux.cc', - 'src/core/lib/iomgr/ev_poll_posix.cc', - 'src/core/lib/iomgr/ev_posix.cc', - 'src/core/lib/iomgr/ev_windows.cc', - 'src/core/lib/iomgr/event_engine/closure.cc', - 'src/core/lib/iomgr/event_engine/endpoint.cc', - 'src/core/lib/iomgr/event_engine/iomgr.cc', - 'src/core/lib/iomgr/event_engine/pollset.cc', - 'src/core/lib/iomgr/event_engine/resolved_address_internal.cc', - 'src/core/lib/iomgr/event_engine/resolver.cc', - 'src/core/lib/iomgr/event_engine/tcp.cc', - 'src/core/lib/iomgr/event_engine/timer.cc', - 'src/core/lib/iomgr/exec_ctx.cc', - 'src/core/lib/iomgr/executor.cc', - 'src/core/lib/iomgr/executor/mpmcqueue.cc', - 'src/core/lib/iomgr/executor/threadpool.cc', - 'src/core/lib/iomgr/fork_posix.cc', - 'src/core/lib/iomgr/fork_windows.cc', - 'src/core/lib/iomgr/gethostname_fallback.cc', - 'src/core/lib/iomgr/gethostname_host_name_max.cc', - 'src/core/lib/iomgr/gethostname_sysconf.cc', - 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc', - 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc', - 'src/core/lib/iomgr/internal_errqueue.cc', - 'src/core/lib/iomgr/iocp_windows.cc', - 'src/core/lib/iomgr/iomgr.cc', - 'src/core/lib/iomgr/iomgr_custom.cc', - 'src/core/lib/iomgr/iomgr_internal.cc', - 'src/core/lib/iomgr/iomgr_posix.cc', - 'src/core/lib/iomgr/iomgr_posix_cfstream.cc', - 'src/core/lib/iomgr/iomgr_windows.cc', - 'src/core/lib/iomgr/is_epollexclusive_available.cc', - 'src/core/lib/iomgr/load_file.cc', - 'src/core/lib/iomgr/lockfree_event.cc', - 'src/core/lib/iomgr/polling_entity.cc', - 'src/core/lib/iomgr/pollset.cc', - 'src/core/lib/iomgr/pollset_custom.cc', - 'src/core/lib/iomgr/pollset_set.cc', - 'src/core/lib/iomgr/pollset_set_custom.cc', - 'src/core/lib/iomgr/pollset_set_windows.cc', - 'src/core/lib/iomgr/pollset_windows.cc', - 'src/core/lib/iomgr/resolve_address.cc', - 'src/core/lib/iomgr/resolve_address_custom.cc', - 'src/core/lib/iomgr/resolve_address_posix.cc', - 'src/core/lib/iomgr/resolve_address_windows.cc', - 'src/core/lib/iomgr/socket_factory_posix.cc', - 'src/core/lib/iomgr/socket_mutator.cc', - 'src/core/lib/iomgr/socket_utils_common_posix.cc', - 'src/core/lib/iomgr/socket_utils_linux.cc', - 'src/core/lib/iomgr/socket_utils_posix.cc', - 'src/core/lib/iomgr/socket_utils_windows.cc', - 'src/core/lib/iomgr/socket_windows.cc', - 'src/core/lib/iomgr/tcp_client.cc', - 'src/core/lib/iomgr/tcp_client_cfstream.cc', - 'src/core/lib/iomgr/tcp_client_custom.cc', - 'src/core/lib/iomgr/tcp_client_posix.cc', - 'src/core/lib/iomgr/tcp_client_windows.cc', - 'src/core/lib/iomgr/tcp_custom.cc', - 'src/core/lib/iomgr/tcp_posix.cc', - 'src/core/lib/iomgr/tcp_server.cc', - 'src/core/lib/iomgr/tcp_server_custom.cc', - 'src/core/lib/iomgr/tcp_server_posix.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc', - 'src/core/lib/iomgr/tcp_server_windows.cc', - 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/time_averaged_stats.cc', - 'src/core/lib/iomgr/timer.cc', - 'src/core/lib/iomgr/timer_custom.cc', - 'src/core/lib/iomgr/timer_generic.cc', - 'src/core/lib/iomgr/timer_heap.cc', - 'src/core/lib/iomgr/timer_manager.cc', - 'src/core/lib/iomgr/unix_sockets_posix.cc', - 'src/core/lib/iomgr/unix_sockets_posix_noop.cc', - 'src/core/lib/iomgr/wakeup_fd_eventfd.cc', - 'src/core/lib/iomgr/wakeup_fd_nospecial.cc', - 'src/core/lib/iomgr/wakeup_fd_pipe.cc', - 'src/core/lib/iomgr/wakeup_fd_posix.cc', - 'src/core/lib/iomgr/work_serializer.cc', - 'src/core/lib/json/json_reader.cc', - 'src/core/lib/json/json_util.cc', - 'src/core/lib/json/json_writer.cc', - 'src/core/lib/matchers/matchers.cc', - 'src/core/lib/profiling/basic_timers.cc', - 'src/core/lib/profiling/stap_timers.cc', - 'src/core/lib/promise/activity.cc', - 'src/core/lib/resource_quota/api.cc', - 'src/core/lib/resource_quota/memory_quota.cc', - 'src/core/lib/resource_quota/resource_quota.cc', - 'src/core/lib/resource_quota/thread_quota.cc', - 'src/core/lib/resource_quota/trace.cc', - 'src/core/lib/security/authorization/authorization_policy_provider_vtable.cc', - 'src/core/lib/security/authorization/evaluate_args.cc', - 'src/core/lib/security/authorization/sdk_server_authz_filter.cc', - 'src/core/lib/security/context/security_context.cc', - 'src/core/lib/security/credentials/alts/alts_credentials.cc', - 'src/core/lib/security/credentials/alts/check_gcp_environment.cc', - 'src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc', - 'src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc', - 'src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc', - 'src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc', - 'src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc', - 'src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc', - 'src/core/lib/security/credentials/composite/composite_credentials.cc', - 'src/core/lib/security/credentials/credentials.cc', - 'src/core/lib/security/credentials/credentials_metadata.cc', - 'src/core/lib/security/credentials/external/aws_external_account_credentials.cc', - 'src/core/lib/security/credentials/external/aws_request_signer.cc', - 'src/core/lib/security/credentials/external/external_account_credentials.cc', - 'src/core/lib/security/credentials/external/file_external_account_credentials.cc', - 'src/core/lib/security/credentials/external/url_external_account_credentials.cc', - 'src/core/lib/security/credentials/fake/fake_credentials.cc', - 'src/core/lib/security/credentials/google_default/credentials_generic.cc', - 'src/core/lib/security/credentials/google_default/google_default_credentials.cc', - 'src/core/lib/security/credentials/iam/iam_credentials.cc', - 'src/core/lib/security/credentials/insecure/insecure_credentials.cc', - 'src/core/lib/security/credentials/jwt/json_token.cc', - 'src/core/lib/security/credentials/jwt/jwt_credentials.cc', - 'src/core/lib/security/credentials/jwt/jwt_verifier.cc', - 'src/core/lib/security/credentials/local/local_credentials.cc', - 'src/core/lib/security/credentials/oauth2/oauth2_credentials.cc', - 'src/core/lib/security/credentials/plugin/plugin_credentials.cc', - 'src/core/lib/security/credentials/ssl/ssl_credentials.cc', - 'src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc', - 'src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc', - 'src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc', - 'src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc', - 'src/core/lib/security/credentials/tls/tls_credentials.cc', - 'src/core/lib/security/credentials/tls/tls_utils.cc', - 'src/core/lib/security/credentials/xds/xds_credentials.cc', - 'src/core/lib/security/security_connector/alts/alts_security_connector.cc', - 'src/core/lib/security/security_connector/fake/fake_security_connector.cc', - 'src/core/lib/security/security_connector/insecure/insecure_security_connector.cc', - 'src/core/lib/security/security_connector/load_system_roots_fallback.cc', - 'src/core/lib/security/security_connector/load_system_roots_linux.cc', - 'src/core/lib/security/security_connector/local/local_security_connector.cc', - 'src/core/lib/security/security_connector/security_connector.cc', - 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', - 'src/core/lib/security/security_connector/ssl_utils.cc', - 'src/core/lib/security/security_connector/ssl_utils_config.cc', - 'src/core/lib/security/security_connector/tls/tls_security_connector.cc', - 'src/core/lib/security/transport/client_auth_filter.cc', - 'src/core/lib/security/transport/secure_endpoint.cc', - 'src/core/lib/security/transport/security_handshaker.cc', - 'src/core/lib/security/transport/server_auth_filter.cc', - 'src/core/lib/security/transport/tsi_error.cc', - 'src/core/lib/security/util/json_util.cc', - 'src/core/lib/slice/b64.cc', - 'src/core/lib/slice/percent_encoding.cc', - 'src/core/lib/slice/slice.cc', - 'src/core/lib/slice/slice_api.cc', - 'src/core/lib/slice/slice_buffer.cc', - 'src/core/lib/slice/slice_intern.cc', - 'src/core/lib/slice/slice_refcount.cc', - 'src/core/lib/slice/slice_split.cc', - 'src/core/lib/slice/slice_string_helpers.cc', - 'src/core/lib/slice/static_slice.cc', - 'src/core/lib/surface/api_trace.cc', - 'src/core/lib/surface/builtins.cc', - 'src/core/lib/surface/byte_buffer.cc', - 'src/core/lib/surface/byte_buffer_reader.cc', - 'src/core/lib/surface/call.cc', - 'src/core/lib/surface/call_details.cc', - 'src/core/lib/surface/call_log_batch.cc', - 'src/core/lib/surface/channel.cc', - 'src/core/lib/surface/channel_init.cc', - 'src/core/lib/surface/channel_ping.cc', - 'src/core/lib/surface/channel_stack_type.cc', - 'src/core/lib/surface/completion_queue.cc', - 'src/core/lib/surface/completion_queue_factory.cc', - 'src/core/lib/surface/event_string.cc', - 'src/core/lib/surface/init.cc', - 'src/core/lib/surface/init_secure.cc', - 'src/core/lib/surface/lame_client.cc', - 'src/core/lib/surface/metadata_array.cc', - 'src/core/lib/surface/server.cc', - 'src/core/lib/surface/validate_metadata.cc', - 'src/core/lib/surface/version.cc', - 'src/core/lib/transport/bdp_estimator.cc', - 'src/core/lib/transport/byte_stream.cc', - 'src/core/lib/transport/connectivity_state.cc', - 'src/core/lib/transport/error_utils.cc', - 'src/core/lib/transport/metadata.cc', - 'src/core/lib/transport/metadata_batch.cc', - 'src/core/lib/transport/parsed_metadata.cc', - 'src/core/lib/transport/pid_controller.cc', - 'src/core/lib/transport/static_metadata.cc', - 'src/core/lib/transport/status_conversion.cc', - 'src/core/lib/transport/status_metadata.cc', - 'src/core/lib/transport/timeout_encoding.cc', - 'src/core/lib/transport/transport.cc', - 'src/core/lib/transport/transport_op_string.cc', - 'src/core/lib/uri/uri_parser.cc', - 'src/core/plugin_registry/grpc_plugin_registry.cc', - 'src/core/tsi/alts/crypt/aes_gcm.cc', - 'src/core/tsi/alts/crypt/gsec.cc', - 'src/core/tsi/alts/frame_protector/alts_counter.cc', - 'src/core/tsi/alts/frame_protector/alts_crypter.cc', - 'src/core/tsi/alts/frame_protector/alts_frame_protector.cc', - 'src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc', - 'src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc', - 'src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc', - 'src/core/tsi/alts/frame_protector/frame_handler.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_client.cc', - 'src/core/tsi/alts/handshaker/alts_shared_resource.cc', - 'src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc', - 'src/core/tsi/alts/handshaker/alts_tsi_utils.cc', - 'src/core/tsi/alts/handshaker/transport_security_common_api.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc', - 'src/core/tsi/fake_transport_security.cc', - 'src/core/tsi/local_transport_security.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_cache.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_openssl.cc', - 'src/core/tsi/ssl_transport_security.cc', - 'src/core/tsi/transport_security.cc', - 'src/core/tsi/transport_security_grpc.cc', - 'third_party/abseil-cpp/y_absl/base/internal/cycleclock.cc', - 'third_party/abseil-cpp/y_absl/base/internal/low_level_alloc.cc', - 'third_party/abseil-cpp/y_absl/base/internal/raw_logging.cc', - 'third_party/abseil-cpp/y_absl/base/internal/spinlock.cc', - 'third_party/abseil-cpp/y_absl/base/internal/spinlock_wait.cc', - 'third_party/abseil-cpp/y_absl/base/internal/sysinfo.cc', - 'third_party/abseil-cpp/y_absl/base/internal/thread_identity.cc', - 'third_party/abseil-cpp/y_absl/base/internal/throw_delegate.cc', - 'third_party/abseil-cpp/y_absl/base/internal/unscaledcycleclock.cc', - 'third_party/abseil-cpp/y_absl/base/log_severity.cc', - 'third_party/abseil-cpp/y_absl/container/internal/hashtablez_sampler.cc', - 'third_party/abseil-cpp/y_absl/container/internal/hashtablez_sampler_force_weak_definition.cc', - 'third_party/abseil-cpp/y_absl/container/internal/raw_hash_set.cc', - 'third_party/abseil-cpp/y_absl/debugging/internal/address_is_readable.cc', - 'third_party/abseil-cpp/y_absl/debugging/internal/demangle.cc', - 'third_party/abseil-cpp/y_absl/debugging/internal/elf_mem_image.cc', - 'third_party/abseil-cpp/y_absl/debugging/internal/vdso_support.cc', - 'third_party/abseil-cpp/y_absl/debugging/stacktrace.cc', - 'third_party/abseil-cpp/y_absl/debugging/symbolize.cc', - 'third_party/abseil-cpp/y_absl/hash/internal/city.cc', - 'third_party/abseil-cpp/y_absl/hash/internal/hash.cc', - 'third_party/abseil-cpp/y_absl/hash/internal/low_level_hash.cc', - 'third_party/abseil-cpp/y_absl/numeric/int128.cc', - 'third_party/abseil-cpp/y_absl/profiling/internal/exponential_biased.cc', - 'third_party/abseil-cpp/y_absl/status/status.cc', - 'third_party/abseil-cpp/y_absl/status/status_payload_printer.cc', - 'third_party/abseil-cpp/y_absl/status/statusor.cc', - 'third_party/abseil-cpp/y_absl/strings/ascii.cc', - 'third_party/abseil-cpp/y_absl/strings/charconv.cc', - 'third_party/abseil-cpp/y_absl/strings/cord.cc', - 'third_party/abseil-cpp/y_absl/strings/escaping.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/charconv_bigint.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/charconv_parse.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_internal.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_rep_btree.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_rep_btree_navigator.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_rep_btree_reader.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_rep_consume.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cord_rep_ring.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cordz_functions.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cordz_handle.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/cordz_info.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/escaping.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/memutil.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/ostringstream.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/arg.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/bind.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/extension.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/float_conversion.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/output.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/str_format/parser.cc', - 'third_party/abseil-cpp/y_absl/strings/internal/utf8.cc', - 'third_party/abseil-cpp/y_absl/strings/match.cc', - 'third_party/abseil-cpp/y_absl/strings/numbers.cc', - 'third_party/abseil-cpp/y_absl/strings/str_cat.cc', - 'third_party/abseil-cpp/y_absl/strings/str_replace.cc', - 'third_party/abseil-cpp/y_absl/strings/str_split.cc', - 'third_party/abseil-cpp/y_absl/strings/string_view.cc', - 'third_party/abseil-cpp/y_absl/strings/substitute.cc', - 'third_party/abseil-cpp/y_absl/synchronization/barrier.cc', - 'third_party/abseil-cpp/y_absl/synchronization/blocking_counter.cc', - 'third_party/abseil-cpp/y_absl/synchronization/internal/create_thread_identity.cc', - 'third_party/abseil-cpp/y_absl/synchronization/internal/graphcycles.cc', - 'third_party/abseil-cpp/y_absl/synchronization/internal/per_thread_sem.cc', - 'third_party/abseil-cpp/y_absl/synchronization/internal/waiter.cc', - 'third_party/abseil-cpp/y_absl/synchronization/mutex.cc', - 'third_party/abseil-cpp/y_absl/synchronization/notification.cc', - 'third_party/abseil-cpp/y_absl/time/civil_time.cc', - 'third_party/abseil-cpp/y_absl/time/clock.cc', - 'third_party/abseil-cpp/y_absl/time/duration.cc', - 'third_party/abseil-cpp/y_absl/time/format.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/civil_time_detail.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_fixed.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_format.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_if.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_impl.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_info.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_libc.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_lookup.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/time_zone_posix.cc', - 'third_party/abseil-cpp/y_absl/time/internal/cctz/src/zone_info_source.cc', - 'third_party/abseil-cpp/y_absl/time/time.cc', - 'third_party/abseil-cpp/y_absl/types/bad_optional_access.cc', - 'third_party/abseil-cpp/y_absl/types/bad_variant_access.cc', - 'third_party/address_sorting/address_sorting.c', - 'third_party/address_sorting/address_sorting_posix.c', - 'third_party/address_sorting/address_sorting_windows.c', - 'third_party/boringssl-with-bazel/err_data.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c', - 'third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c', - 'third_party/boringssl-with-bazel/src/crypto/base64/base64.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/bio.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/connect.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/fd.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/file.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/hexdump.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/pair.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/printf.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/socket.c', - 'third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c', - 'third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c', - 'third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/bn_extra/convert.c', - 'third_party/boringssl-with-bazel/src/crypto/buf/buf.c', - 'third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c', - 'third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c', - 'third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c', - 'third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c', - 'third_party/boringssl-with-bazel/src/crypto/bytestring/unicode.c', - 'third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesccm.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesctrhmac.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesgcmsiv.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc2.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c', - 'third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c', - 'third_party/boringssl-with-bazel/src/crypto/cmac/cmac.c', - 'third_party/boringssl-with-bazel/src/crypto/conf/conf.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-fuchsia.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-linux.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-win.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-arm.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-intel.c', - 'third_party/boringssl-with-bazel/src/crypto/cpu-ppc64le.c', - 'third_party/boringssl-with-bazel/src/crypto/crypto.c', - 'third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c', - 'third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c', - 'third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c', - 'third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c', - 'third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c', - 'third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c', - 'third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c', - 'third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c', - 'third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/engine/engine.c', - 'third_party/boringssl-with-bazel/src/crypto/err/err.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/digestsign.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/evp.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/print.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c', - 'third_party/boringssl-with-bazel/src/crypto/evp/sign.c', - 'third_party/boringssl-with-bazel/src/crypto/ex_data.c', - 'third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c', - 'third_party/boringssl-with-bazel/src/crypto/fipsmodule/fips_shared_support.c', - 'third_party/boringssl-with-bazel/src/crypto/hkdf/hkdf.c', - 'third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c', - 'third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c', - 'third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c', - 'third_party/boringssl-with-bazel/src/crypto/mem.c', - 'third_party/boringssl-with-bazel/src/crypto/obj/obj.c', - 'third_party/boringssl-with-bazel/src/crypto/obj/obj_xref.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c', - 'third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c', - 'third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c', - 'third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c', - 'third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c', - 'third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c', - 'third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c', - 'third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c', - 'third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c', - 'third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c', - 'third_party/boringssl-with-bazel/src/crypto/pool/pool.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c', - 'third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c', - 'third_party/boringssl-with-bazel/src/crypto/rc4/rc4.c', - 'third_party/boringssl-with-bazel/src/crypto/refcount_c11.c', - 'third_party/boringssl-with-bazel/src/crypto/refcount_lock.c', - 'third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c', - 'third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_print.c', - 'third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c', - 'third_party/boringssl-with-bazel/src/crypto/stack/stack.c', - 'third_party/boringssl-with-bazel/src/crypto/thread.c', - 'third_party/boringssl-with-bazel/src/crypto/thread_none.c', - 'third_party/boringssl-with-bazel/src/crypto/thread_pthread.c', - 'third_party/boringssl-with-bazel/src/crypto/thread_win.c', - 'third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c', - 'third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c', - 'third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/by_file.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/name_print.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/t_req.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509name.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_all.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_info.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_name.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_req.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_val.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c', - 'third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akeya.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bcons.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_extku.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_int.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ocsp.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcia.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcons.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pmaps.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c', - 'third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c', - 'third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc', - 'third_party/boringssl-with-bazel/src/ssl/d1_both.cc', - 'third_party/boringssl-with-bazel/src/ssl/d1_lib.cc', - 'third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc', - 'third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc', - 'third_party/boringssl-with-bazel/src/ssl/dtls_method.cc', - 'third_party/boringssl-with-bazel/src/ssl/dtls_record.cc', - 'third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc', - 'third_party/boringssl-with-bazel/src/ssl/extensions.cc', - 'third_party/boringssl-with-bazel/src/ssl/handoff.cc', - 'third_party/boringssl-with-bazel/src/ssl/handshake.cc', - 'third_party/boringssl-with-bazel/src/ssl/handshake_client.cc', - 'third_party/boringssl-with-bazel/src/ssl/handshake_server.cc', - 'third_party/boringssl-with-bazel/src/ssl/s3_both.cc', - 'third_party/boringssl-with-bazel/src/ssl/s3_lib.cc', - 'third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_file.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_session.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc', - 'third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc', - 'third_party/boringssl-with-bazel/src/ssl/t1_enc.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls13_both.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls13_client.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls13_server.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls_method.cc', - 'third_party/boringssl-with-bazel/src/ssl/tls_record.cc', - 'third_party/cares/cares/ares__close_sockets.c', - 'third_party/cares/cares/ares__get_hostent.c', - 'third_party/cares/cares/ares__read_line.c', - 'third_party/cares/cares/ares__timeval.c', - 'third_party/cares/cares/ares_cancel.c', - 'third_party/cares/cares/ares_create_query.c', - 'third_party/cares/cares/ares_data.c', - 'third_party/cares/cares/ares_destroy.c', - 'third_party/cares/cares/ares_expand_name.c', - 'third_party/cares/cares/ares_expand_string.c', - 'third_party/cares/cares/ares_fds.c', - 'third_party/cares/cares/ares_free_hostent.c', - 'third_party/cares/cares/ares_free_string.c', - 'third_party/cares/cares/ares_getenv.c', - 'third_party/cares/cares/ares_gethostbyaddr.c', - 'third_party/cares/cares/ares_gethostbyname.c', - 'third_party/cares/cares/ares_getnameinfo.c', - 'third_party/cares/cares/ares_getopt.c', - 'third_party/cares/cares/ares_getsock.c', - 'third_party/cares/cares/ares_init.c', - 'third_party/cares/cares/ares_library_init.c', - 'third_party/cares/cares/ares_llist.c', - 'third_party/cares/cares/ares_mkquery.c', - 'third_party/cares/cares/ares_nowarn.c', - 'third_party/cares/cares/ares_options.c', - 'third_party/cares/cares/ares_parse_a_reply.c', - 'third_party/cares/cares/ares_parse_aaaa_reply.c', - 'third_party/cares/cares/ares_parse_mx_reply.c', - 'third_party/cares/cares/ares_parse_naptr_reply.c', - 'third_party/cares/cares/ares_parse_ns_reply.c', - 'third_party/cares/cares/ares_parse_ptr_reply.c', - 'third_party/cares/cares/ares_parse_soa_reply.c', - 'third_party/cares/cares/ares_parse_srv_reply.c', - 'third_party/cares/cares/ares_parse_txt_reply.c', - 'third_party/cares/cares/ares_platform.c', - 'third_party/cares/cares/ares_process.c', - 'third_party/cares/cares/ares_query.c', - 'third_party/cares/cares/ares_search.c', - 'third_party/cares/cares/ares_send.c', - 'third_party/cares/cares/ares_strcasecmp.c', - 'third_party/cares/cares/ares_strdup.c', - 'third_party/cares/cares/ares_strerror.c', - 'third_party/cares/cares/ares_strsplit.c', - 'third_party/cares/cares/ares_timeout.c', - 'third_party/cares/cares/ares_version.c', - 'third_party/cares/cares/ares_writev.c', - 'third_party/cares/cares/bitncmp.c', - 'third_party/cares/cares/inet_net_pton.c', - 'third_party/cares/cares/inet_ntop.c', - 'third_party/cares/cares/windows_port.c', - 'third_party/re2/re2/bitstate.cc', - 'third_party/re2/re2/compile.cc', - 'third_party/re2/re2/dfa.cc', - 'third_party/re2/re2/filtered_re2.cc', - 'third_party/re2/re2/mimics_pcre.cc', - 'third_party/re2/re2/nfa.cc', - 'third_party/re2/re2/onepass.cc', - 'third_party/re2/re2/parse.cc', - 'third_party/re2/re2/perl_groups.cc', - 'third_party/re2/re2/prefilter.cc', - 'third_party/re2/re2/prefilter_tree.cc', - 'third_party/re2/re2/prog.cc', - 'third_party/re2/re2/re2.cc', - 'third_party/re2/re2/regexp.cc', - 'third_party/re2/re2/set.cc', - 'third_party/re2/re2/simplify.cc', - 'third_party/re2/re2/stringpiece.cc', - 'third_party/re2/re2/tostring.cc', - 'third_party/re2/re2/unicode_casefold.cc', - 'third_party/re2/re2/unicode_groups.cc', - 'third_party/re2/util/pcre.cc', - 'third_party/re2/util/rune.cc', - 'third_party/re2/util/strutil.cc', - 'third_party/upb/upb/decode.c', - 'third_party/upb/upb/decode_fast.c', - 'third_party/upb/upb/def.c', - 'third_party/upb/upb/encode.c', - 'third_party/upb/upb/msg.c', - 'third_party/upb/upb/reflection.c', - 'third_party/upb/upb/table.c', - 'third_party/upb/upb/text_encode.c', - 'third_party/upb/upb/upb.c', - 'third_party/zlib/adler32.c', - 'third_party/zlib/compress.c', - 'third_party/zlib/crc32.c', - 'third_party/zlib/deflate.c', - 'third_party/zlib/gzclose.c', - 'third_party/zlib/gzlib.c', - 'third_party/zlib/gzread.c', - 'third_party/zlib/gzwrite.c', - 'third_party/zlib/infback.c', - 'third_party/zlib/inffast.c', - 'third_party/zlib/inflate.c', - 'third_party/zlib/inftrees.c', - 'third_party/zlib/trees.c', - 'third_party/zlib/uncompr.c', - 'third_party/zlib/zutil.c', -] - -ASM_SOURCE_FILES = { - 'crypto_ios_aarch64': [ - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/chacha/chacha-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/aesv8-armx64.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/armv8-mont.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/ghash-neon-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/ghashv8-armx64.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/sha1-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/sha256-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/sha512-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/fipsmodule/vpaes-armv8.S', - 'third_party/boringssl-with-bazel/ios-aarch64/crypto/test/trampoline-armv8.S', - ], - 'crypto_ios_arm': [ - 'third_party/boringssl-with-bazel/ios-arm/crypto/chacha/chacha-armv4.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/aesv8-armx32.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/armv4-mont.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/bsaes-armv7.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/ghash-armv4.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/ghashv8-armx32.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/sha1-armv4-large.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/sha256-armv4.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/sha512-armv4.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/fipsmodule/vpaes-armv7.S', - 'third_party/boringssl-with-bazel/ios-arm/crypto/test/trampoline-armv4.S', - ], - 'crypto_linux_aarch64': [ - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/chacha/chacha-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/aesv8-armx64.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/armv8-mont.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/ghash-neon-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/ghashv8-armx64.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/sha1-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/sha256-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/sha512-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/fipsmodule/vpaes-armv8.S', - 'third_party/boringssl-with-bazel/linux-aarch64/crypto/test/trampoline-armv8.S', - ], - 'crypto_linux_arm': [ - 'third_party/boringssl-with-bazel/linux-arm/crypto/chacha/chacha-armv4.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/aesv8-armx32.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/armv4-mont.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/bsaes-armv7.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/ghash-armv4.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/ghashv8-armx32.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/sha1-armv4-large.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/sha256-armv4.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/sha512-armv4.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/fipsmodule/vpaes-armv7.S', - 'third_party/boringssl-with-bazel/linux-arm/crypto/test/trampoline-armv4.S', - 'third_party/boringssl-with-bazel/src/crypto/curve25519/asm/x25519-asm-arm.S', - 'third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm_asm.S', - ], - 'crypto_linux_ppc64le': [ - 'third_party/boringssl-with-bazel/linux-ppc64le/crypto/fipsmodule/aesp8-ppc.S', - 'third_party/boringssl-with-bazel/linux-ppc64le/crypto/fipsmodule/ghashp8-ppc.S', - 'third_party/boringssl-with-bazel/linux-ppc64le/crypto/test/trampoline-ppc.S', - ], - 'crypto_linux_x86': [ - 'third_party/boringssl-with-bazel/linux-x86/crypto/chacha/chacha-x86.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/aesni-x86.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/bn-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/co-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/ghash-ssse3-x86.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/ghash-x86.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/md5-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/sha1-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/sha256-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/sha512-586.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/vpaes-x86.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/fipsmodule/x86-mont.S', - 'third_party/boringssl-with-bazel/linux-x86/crypto/test/trampoline-x86.S', - ], - 'crypto_linux_x86_64': [ - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/chacha/chacha-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/aesni-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/ghash-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/md5-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/p256-x86_64-asm.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/rdrand-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/rsaz-avx2.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/sha256-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/sha512-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/vpaes-x86_64.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/x86_64-mont.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/fipsmodule/x86_64-mont5.S', - 'third_party/boringssl-with-bazel/linux-x86_64/crypto/test/trampoline-x86_64.S', - 'third_party/boringssl-with-bazel/src/crypto/hrss/asm/poly_rq_mul.S', - ], - 'crypto_mac_x86': [ - 'third_party/boringssl-with-bazel/mac-x86/crypto/chacha/chacha-x86.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/aesni-x86.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/bn-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/co-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/ghash-ssse3-x86.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/ghash-x86.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/md5-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/sha1-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/sha256-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/sha512-586.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/vpaes-x86.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/fipsmodule/x86-mont.S', - 'third_party/boringssl-with-bazel/mac-x86/crypto/test/trampoline-x86.S', - ], - 'crypto_mac_x86_64': [ - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/chacha/chacha-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/aesni-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/ghash-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/md5-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/p256-x86_64-asm.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/rdrand-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/rsaz-avx2.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/sha256-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/sha512-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/vpaes-x86_64.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/x86_64-mont.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/fipsmodule/x86_64-mont5.S', - 'third_party/boringssl-with-bazel/mac-x86_64/crypto/test/trampoline-x86_64.S', - ], - 'crypto_win_aarch64': [ - 'third_party/boringssl-with-bazel/win-aarch64/crypto/chacha/chacha-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/aesv8-armx64.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/armv8-mont.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/ghash-neon-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/ghashv8-armx64.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/sha1-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/sha256-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/sha512-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/fipsmodule/vpaes-armv8.S', - 'third_party/boringssl-with-bazel/win-aarch64/crypto/test/trampoline-armv8.S', - ], - 'crypto_win_x86': [ - 'third_party/boringssl-with-bazel/win-x86/crypto/chacha/chacha-x86.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/aesni-x86.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/bn-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/co-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/ghash-ssse3-x86.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/ghash-x86.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/md5-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/sha1-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/sha256-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/sha512-586.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/vpaes-x86.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/fipsmodule/x86-mont.asm', - 'third_party/boringssl-with-bazel/win-x86/crypto/test/trampoline-x86.asm', - ], - 'crypto_win_x86_64': [ - 'third_party/boringssl-with-bazel/win-x86_64/crypto/chacha/chacha-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/aesni-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/ghash-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/md5-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/p256-x86_64-asm.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/rdrand-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/rsaz-avx2.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/sha256-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/sha512-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/vpaes-x86_64.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/x86_64-mont.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/fipsmodule/x86_64-mont5.asm', - 'third_party/boringssl-with-bazel/win-x86_64/crypto/test/trampoline-x86_64.asm', - ], -} diff --git a/contrib/libs/grpc/src/python/grpcio/grpc_version.py b/contrib/libs/grpc/src/python/grpcio/grpc_version.py deleted file mode 100644 index 9636ff390e..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/grpc_version.py +++ /dev/null @@ -1,17 +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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio/support.py b/contrib/libs/grpc/src/python/grpcio/support.py deleted file mode 100644 index 3d64b3170c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio/support.py +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from distutils import errors -import os -import os.path -import shutil -import sys -import tempfile - -import commands - -C_PYTHON_DEV = """ -#include <Python.h> -int main(int argc, char **argv) { return 0; } -""" -C_PYTHON_DEV_ERROR_MESSAGE = """ -Could not find <Python.h>. This could mean the following: - * You're on Ubuntu and haven't run `apt-get install <PY_REPR>-dev`. - * You're on RHEL/Fedora and haven't run `yum install <PY_REPR>-devel` or - `dnf install <PY_REPR>-devel` (make sure you also have redhat-rpm-config - installed) - * You're on Mac OS X and the usual Python framework was somehow corrupted - (check your environment variables or try re-installing?) - * You're on Windows and your Python installation was somehow corrupted - (check your environment variables or try re-installing?) -""" -if sys.version_info[0] == 2: - PYTHON_REPRESENTATION = 'python' -elif sys.version_info[0] == 3: - PYTHON_REPRESENTATION = 'python3' -else: - raise NotImplementedError('Unsupported Python version: %s' % sys.version) - -C_CHECKS = { - C_PYTHON_DEV: - C_PYTHON_DEV_ERROR_MESSAGE.replace('<PY_REPR>', PYTHON_REPRESENTATION), -} - - -def _compile(compiler, source_string): - tempdir = tempfile.mkdtemp() - cpath = os.path.join(tempdir, 'a.c') - with open(cpath, 'w') as cfile: - cfile.write(source_string) - try: - compiler.compile([cpath]) - except errors.CompileError as error: - return error - finally: - shutil.rmtree(tempdir) - - -def _expect_compile(compiler, source_string, error_message): - if _compile(compiler, source_string) is not None: - sys.stderr.write(error_message) - raise commands.CommandError( - "Diagnostics found a compilation environment issue:\n{}".format( - error_message)) - - -def diagnose_compile_error(build_ext, error): - """Attempt to diagnose an error during compilation.""" - for c_check, message in C_CHECKS.items(): - _expect_compile(build_ext.compiler, c_check, message) - python_sources = [ - source for source in build_ext.get_source_files() - if source.startswith('./src/python') and source.endswith('c') - ] - for source in python_sources: - if not os.path.isfile(source): - raise commands.CommandError(( - "Diagnostics found a missing Python extension source file:\n{}\n\n" - "This is usually because the Cython sources haven't been transpiled " - "into C yet and you're building from source.\n" - "Try setting the environment variable " - "`GRPC_PYTHON_BUILD_WITH_CYTHON=1` when invoking `setup.py` or " - "when using `pip`, e.g.:\n\n" - "pip install -rrequirements.txt\n" - "GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .").format(source)) - - -def diagnose_attribute_error(build_ext, error): - if any('_needs_stub' in arg for arg in error.args): - raise commands.CommandError( - "We expect a missing `_needs_stub` attribute from older versions of " - "setuptools. Consider upgrading setuptools.") - - -_ERROR_DIAGNOSES = { - errors.CompileError: diagnose_compile_error, - AttributeError: diagnose_attribute_error, -} - - -def diagnose_build_ext_error(build_ext, error, formatted): - diagnostic = _ERROR_DIAGNOSES.get(type(error)) - if diagnostic is None: - raise commands.CommandError( - "\n\nWe could not diagnose your build failure. If you are unable to " - "proceed, please file an issue at http://www.github.com/grpc/grpc " - "with `[Python install]` in the title; please attach the whole log " - "(including everything that may have appeared above the Python " - "backtrace).\n\n{}".format(formatted)) - else: - diagnostic(build_ext, error) diff --git a/contrib/libs/grpc/src/python/grpcio_admin/grpc_admin/__init__.py b/contrib/libs/grpc/src/python/grpcio_admin/grpc_admin/__init__.py deleted file mode 100644 index 95e70858b3..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_admin/grpc_admin/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2021 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. -"""gRPC Python's Admin interface.""" - -from grpc_channelz.v1 import channelz -import grpc_csds - - -def add_admin_servicers(server): - """Register admin servicers to a server. - - gRPC provides some predefined admin services to make debugging easier by - exposing gRPC's internal states. Each existing admin service is packaged as - a separate library, and the documentation of the predefined admin services - is usually scattered. It can be time consuming to get the dependency - management, module initialization, and library import right for each one of - them. - - This API provides a convenient way to create a gRPC server to expose admin - services. With this, any new admin services that you may add in the future - are automatically available via the admin interface just by upgrading your - gRPC version. - - Args: - server: A gRPC server to which all admin services will be added. - """ - channelz.add_channelz_servicer(server) - grpc_csds.add_csds_servicer(server) - - -__all__ = ['add_admin_servicers'] diff --git a/contrib/libs/grpc/src/python/grpcio_admin/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_admin/grpc_version.py deleted file mode 100644 index c48475b87e..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_admin/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2021 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_admin/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_admin/setup.py b/contrib/libs/grpc/src/python/grpcio_admin/setup.py deleted file mode 100644 index 2d966cdc0a..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_admin/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2021 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. -"""Setup module for admin interface in gRPC Python.""" - -import os -import sys - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'grpcio-channelz>={version}'.format(version=grpc_version.VERSION), - 'grpcio-csds>={version}'.format(version=grpc_version.VERSION), -) -SETUP_REQUIRES = INSTALL_REQUIRES - -setuptools.setup(name='grpcio-admin', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='a collection of admin services', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - classifiers=CLASSIFIERS, - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES) diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio_channelz/.yandex_meta/licenses.list.txt deleted file mode 100644 index e1a08df61b..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,24 +0,0 @@ -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2018 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/channelz_commands.py b/contrib/libs/grpc/src/python/grpcio_channelz/channelz_commands.py deleted file mode 100644 index dbbce2fda5..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/channelz_commands.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2018 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. -"""Provides distutils command classes for the GRPC Python setup process.""" - -import os -import shutil - -import setuptools - -ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) -CHANNELZ_PROTO = os.path.join(ROOT_DIR, - '../../proto/grpc/channelz/channelz.proto') -LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE') - - -class Preprocess(setuptools.Command): - """Command to copy proto modules from grpc/src/proto and LICENSE from - the root directory""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - if os.path.isfile(CHANNELZ_PROTO): - shutil.copyfile( - CHANNELZ_PROTO, - os.path.join(ROOT_DIR, 'grpc_channelz/v1/channelz.proto')) - if os.path.isfile(LICENSE): - shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE')) - - -class BuildPackageProtos(setuptools.Command): - """Command to generate project *_pb2.py modules from proto files.""" - - description = 'build grpc protobuf modules' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - # due to limitations of the proto generator, we require that only *one* - # directory is provided as an 'include' directory. We assume it's the '' key - # to `self.distribution.package_dir` (and get a key error if it's not - # there). - from grpc_tools import command - command.build_package_protos(self.distribution.package_dir['']) diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_channelz/grpc_version.py deleted file mode 100644 index 34edb1e08c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2018 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_channelz/setup.py b/contrib/libs/grpc/src/python/grpcio_channelz/setup.py deleted file mode 100644 index cec1ea2ee9..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_channelz/setup.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright 2018 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. -"""Setup module for the GRPC Python package's Channelz.""" - -import os -import sys - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - - -class _NoOpCommand(setuptools.Command): - """No-op command.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - pass - - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'grpcio>={version}'.format(version=grpc_version.VERSION), -) - -try: - import channelz_commands as _channelz_commands - - # we are in the build environment, otherwise the above import fails - SETUP_REQUIRES = ('grpcio-tools=={version}'.format( - version=grpc_version.VERSION),) - COMMAND_CLASS = { - # Run preprocess from the repository *before* doing any packaging! - 'preprocess': _channelz_commands.Preprocess, - 'build_package_protos': _channelz_commands.BuildPackageProtos, - } -except ImportError: - SETUP_REQUIRES = () - COMMAND_CLASS = { - # wire up commands to no-op not to break the external dependencies - 'preprocess': _NoOpCommand, - 'build_package_protos': _NoOpCommand, - } - -setuptools.setup( - name='grpcio-channelz', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='Channel Level Live Debug Information Service for gRPC', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - classifiers=CLASSIFIERS, - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES, - cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_csds/grpc_csds/__init__.py b/contrib/libs/grpc/src/python/grpcio_csds/grpc_csds/__init__.py deleted file mode 100644 index aa83465c61..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_csds/grpc_csds/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2021 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. -"""Channelz debug service implementation in gRPC Python.""" - -from google.protobuf import json_format -from grpc._cython import cygrpc - -try: - from envoy.service.status.v3 import csds_pb2 - from envoy.service.status.v3 import csds_pb2_grpc -except ImportError: - from src.proto.grpc.testing.xds.v3 import csds_pb2 - from src.proto.grpc.testing.xds.v3 import csds_pb2_grpc - - -class ClientStatusDiscoveryServiceServicer( - csds_pb2_grpc.ClientStatusDiscoveryServiceServicer): - """CSDS Servicer works for both the sync API and asyncio API.""" - - @staticmethod - def FetchClientStatus(request, unused_context): - client_config = csds_pb2.ClientConfig.FromString( - cygrpc.dump_xds_configs()) - response = csds_pb2.ClientStatusResponse() - response.config.append(client_config) - return response - - @staticmethod - def StreamClientStatus(request_iterator, context): - for request in request_iterator: - yield ClientStatusDiscoveryServiceServicer.FetchClientStatus( - request, context) - - -def add_csds_servicer(server): - """Register CSDS servicer to a server. - - CSDS is part of xDS protocol used to expose in-effective traffic - configuration (or xDS resources). It focuses on simplify the debugging of - unexpected routing behaviors, which could be due to a misconfiguration, - unhealthy backends or issues in the control or data plane. - - Args: - server: A gRPC server to which the CSDS service will be added. - """ - csds_pb2_grpc.add_ClientStatusDiscoveryServiceServicer_to_server( - ClientStatusDiscoveryServiceServicer(), server) - - -__all__ = ['ClientStatusDiscoveryServiceServicer', 'add_csds_servicer'] diff --git a/contrib/libs/grpc/src/python/grpcio_csds/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_csds/grpc_version.py deleted file mode 100644 index 88b38f3a6e..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_csds/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2021 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_csds/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_csds/setup.py b/contrib/libs/grpc/src/python/grpcio_csds/setup.py deleted file mode 100644 index c89c6b927b..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_csds/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2021 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. -"""Setup module for CSDS in gRPC Python.""" - -import os -import sys - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'xds-protos>=0.0.7', - 'grpcio>={version}'.format(version=grpc_version.VERSION), -) -SETUP_REQUIRES = INSTALL_REQUIRES - -setuptools.setup(name='grpcio-csds', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='xDS configuration dump library', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - classifiers=CLASSIFIERS, - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES) diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio_health_checking/.yandex_meta/licenses.list.txt deleted file mode 100644 index 02cb1ca478..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,32 +0,0 @@ -====================Apache-2.0==================== - license='Apache License 2.0', - - -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/_async.py b/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/_async.py deleted file mode 100644 index b56a945c61..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_health/v1/_async.py +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright 2020 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Reference implementation for health checking in gRPC Python.""" - -import asyncio -import collections -from typing import MutableMapping - -import grpc -from grpc_health.v1 import health_pb2 as _health_pb2 -from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc - - -class HealthServicer(_health_pb2_grpc.HealthServicer): - """An AsyncIO implementation of health checking servicer.""" - _server_status: MutableMapping[ - str, '_health_pb2.HealthCheckResponse.ServingStatus'] - _server_watchers: MutableMapping[str, asyncio.Condition] - _gracefully_shutting_down: bool - - def __init__(self) -> None: - self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING} - self._server_watchers = collections.defaultdict(asyncio.Condition) - self._gracefully_shutting_down = False - - async def Check(self, request: _health_pb2.HealthCheckRequest, - context) -> None: - status = self._server_status.get(request.service) - - if status is None: - await context.abort(grpc.StatusCode.NOT_FOUND) - else: - return _health_pb2.HealthCheckResponse(status=status) - - async def Watch(self, request: _health_pb2.HealthCheckRequest, - context) -> None: - condition = self._server_watchers[request.service] - last_status = None - try: - async with condition: - while True: - status = self._server_status.get( - request.service, - _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN) - - # NOTE(lidiz) If the observed status is the same, it means - # there are missing intermediate statuses. It's considered - # acceptable since peer only interested in eventual status. - if status != last_status: - # Responds with current health state - await context.write( - _health_pb2.HealthCheckResponse(status=status)) - - # Records the last sent status - last_status = status - - # Polling on health state changes - await condition.wait() - finally: - if request.service in self._server_watchers: - del self._server_watchers[request.service] - - async def _set( - self, service: str, - status: _health_pb2.HealthCheckResponse.ServingStatus) -> None: - if service in self._server_watchers: - condition = self._server_watchers.get(service) - async with condition: - self._server_status[service] = status - condition.notify_all() - else: - self._server_status[service] = status - - async def set( - self, service: str, - status: _health_pb2.HealthCheckResponse.ServingStatus) -> None: - """Sets the status of a service. - - Args: - service: string, the name of the service. - status: HealthCheckResponse.status enum value indicating the status of - the service - """ - if self._gracefully_shutting_down: - return - else: - await self._set(service, status) - - async def enter_graceful_shutdown(self) -> None: - """Permanently sets the status of all services to NOT_SERVING. - - This should be invoked when the server is entering a graceful shutdown - period. After this method is invoked, future attempts to set the status - of a service will be ignored. - """ - if self._gracefully_shutting_down: - return - else: - self._gracefully_shutting_down = True - for service in self._server_status: - await self._set(service, - _health_pb2.HealthCheckResponse.NOT_SERVING) diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_version.py deleted file mode 100644 index 0ba5178b82..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2016 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/health_commands.py b/contrib/libs/grpc/src/python/grpcio_health_checking/health_commands.py deleted file mode 100644 index 874dec7343..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/health_commands.py +++ /dev/null @@ -1,66 +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. -"""Provides distutils command classes for the GRPC Python setup process.""" - -import os -import shutil - -import setuptools - -ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) -HEALTH_PROTO = os.path.join(ROOT_DIR, '../../proto/grpc/health/v1/health.proto') -LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE') - - -class Preprocess(setuptools.Command): - """Command to copy proto modules from grpc/src/proto and LICENSE from - the root directory""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - if os.path.isfile(HEALTH_PROTO): - shutil.copyfile( - HEALTH_PROTO, - os.path.join(ROOT_DIR, 'grpc_health/v1/health.proto')) - if os.path.isfile(LICENSE): - shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE')) - - -class BuildPackageProtos(setuptools.Command): - """Command to generate project *_pb2.py modules from proto files.""" - - description = 'build grpc protobuf modules' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - # due to limitations of the proto generator, we require that only *one* - # directory is provided as an 'include' directory. We assume it's the '' key - # to `self.distribution.package_dir` (and get a key error if it's not - # there). - from grpc_tools import command - command.build_package_protos(self.distribution.package_dir['']) diff --git a/contrib/libs/grpc/src/python/grpcio_health_checking/setup.py b/contrib/libs/grpc/src/python/grpcio_health_checking/setup.py deleted file mode 100644 index 7491bd400a..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_health_checking/setup.py +++ /dev/null @@ -1,102 +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. -"""Setup module for the GRPC Python package's optional health checking.""" - -import os - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - - -class _NoOpCommand(setuptools.Command): - """No-op command.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - pass - - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'grpcio>={version}'.format(version=grpc_version.VERSION), -) - -try: - import health_commands as _health_commands - - # we are in the build environment, otherwise the above import fails - SETUP_REQUIRES = ('grpcio-tools=={version}'.format( - version=grpc_version.VERSION),) - COMMAND_CLASS = { - # Run preprocess from the repository *before* doing any packaging! - 'preprocess': _health_commands.Preprocess, - 'build_package_protos': _health_commands.BuildPackageProtos, - } -except ImportError: - SETUP_REQUIRES = () - COMMAND_CLASS = { - # wire up commands to no-op not to break the external dependencies - 'preprocess': _NoOpCommand, - 'build_package_protos': _NoOpCommand, - } - -setuptools.setup(name='grpcio-health-checking', - version=grpc_version.VERSION, - description='Standard Health Checking Service for gRPC', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - url='https://grpc.io', - license='Apache License 2.0', - classifiers=CLASSIFIERS, - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES, - cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt deleted file mode 100644 index 33706ec084..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,28 +0,0 @@ -====================Apache-2.0==================== - license='Apache License 2.0', - - -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py deleted file mode 100644 index 55ed71e32f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2016 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/reflection_commands.py b/contrib/libs/grpc/src/python/grpcio_reflection/reflection_commands.py deleted file mode 100644 index 311ca4c4db..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/reflection_commands.py +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright 2016 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. -"""Provides distutils command classes for the GRPC Python setup process.""" - -import os -import shutil - -import setuptools - -ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) -REFLECTION_PROTO = os.path.join( - ROOT_DIR, '../../proto/grpc/reflection/v1alpha/reflection.proto') -LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE') - - -class Preprocess(setuptools.Command): - """Command to copy proto modules from grpc/src/proto and LICENSE from - the root directory""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - if os.path.isfile(REFLECTION_PROTO): - shutil.copyfile( - REFLECTION_PROTO, - os.path.join(ROOT_DIR, - 'grpc_reflection/v1alpha/reflection.proto')) - if os.path.isfile(LICENSE): - shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE')) - - -class BuildPackageProtos(setuptools.Command): - """Command to generate project *_pb2.py modules from proto files.""" - - description = 'build grpc protobuf modules' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - # due to limitations of the proto generator, we require that only *one* - # directory is provided as an 'include' directory. We assume it's the '' key - # to `self.distribution.package_dir` (and get a key error if it's not - # there). - from grpc_tools import command - command.build_package_protos(self.distribution.package_dir['']) diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/setup.py b/contrib/libs/grpc/src/python/grpcio_reflection/setup.py deleted file mode 100644 index f90a3cce88..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_reflection/setup.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright 2016 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. -"""Setup module for the GRPC Python package's optional reflection.""" - -import os -import sys - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - - -class _NoOpCommand(setuptools.Command): - """No-op command.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - pass - - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'grpcio>={version}'.format(version=grpc_version.VERSION), -) - -try: - import reflection_commands as _reflection_commands - - # we are in the build environment, otherwise the above import fails - SETUP_REQUIRES = ('grpcio-tools=={version}'.format( - version=grpc_version.VERSION),) - COMMAND_CLASS = { - # Run preprocess from the repository *before* doing any packaging! - 'preprocess': _reflection_commands.Preprocess, - 'build_package_protos': _reflection_commands.BuildPackageProtos, - } -except ImportError: - SETUP_REQUIRES = () - COMMAND_CLASS = { - # wire up commands to no-op not to break the external dependencies - 'preprocess': _NoOpCommand, - 'build_package_protos': _NoOpCommand, - } - -setuptools.setup(name='grpcio-reflection', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='Standard Protobuf Reflection Service for gRPC', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - classifiers=CLASSIFIERS, - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES, - cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_status/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio_status/.yandex_meta/licenses.list.txt deleted file mode 100644 index 93c430236f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,28 +0,0 @@ -====================Apache-2.0==================== - license='Apache License 2.0', - - -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== -// Copyright 2018 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2020 The gRPC Authors diff --git a/contrib/libs/grpc/src/python/grpcio_status/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_status/grpc_version.py deleted file mode 100644 index c80d0a4a88..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2018 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_status/setup.py b/contrib/libs/grpc/src/python/grpcio_status/setup.py deleted file mode 100644 index 23bd11cb6b..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/setup.py +++ /dev/null @@ -1,99 +0,0 @@ -# Copyright 2018 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. -"""Setup module for the GRPC Python package's status mapping.""" - -import os - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import-style to ensure we can actually find our local modules. -import grpc_version - - -class _NoOpCommand(setuptools.Command): - """No-op command.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - pass - - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: Apache Software License', -] - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'grpcio>={version}'.format(version=grpc_version.VERSION), - 'googleapis-common-protos>=1.5.5', -) - -try: - import status_commands as _status_commands - - # we are in the build environment, otherwise the above import fails - COMMAND_CLASS = { - # Run preprocess from the repository *before* doing any packaging! - 'preprocess': _status_commands.Preprocess, - 'build_package_protos': _NoOpCommand, - } -except ImportError: - COMMAND_CLASS = { - # wire up commands to no-op not to break the external dependencies - 'preprocess': _NoOpCommand, - 'build_package_protos': _NoOpCommand, - } - -setuptools.setup(name='grpcio-status', - version=grpc_version.VERSION, - description='Status proto mapping for gRPC', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - url='https://grpc.io', - license='Apache License 2.0', - classifiers=CLASSIFIERS, - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - python_requires='>=3.6', - install_requires=INSTALL_REQUIRES, - cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_status/status_commands.py b/contrib/libs/grpc/src/python/grpcio_status/status_commands.py deleted file mode 100644 index 8306f3c027..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_status/status_commands.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2018 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. -"""Provides distutils command classes for the GRPC Python setup process.""" - -import os -import shutil - -import setuptools - -ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) -STATUS_PROTO = os.path.join( - ROOT_DIR, '../../../third_party/googleapis/google/rpc/status.proto') -PACKAGE_STATUS_PROTO_PATH = 'grpc_status/google/rpc' -LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE') - - -class Preprocess(setuptools.Command): - """Command to copy LICENSE from root directory.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - if os.path.isfile(STATUS_PROTO): - if not os.path.isdir(PACKAGE_STATUS_PROTO_PATH): - os.makedirs(PACKAGE_STATUS_PROTO_PATH) - shutil.copyfile( - STATUS_PROTO, - os.path.join(ROOT_DIR, PACKAGE_STATUS_PROTO_PATH, - 'status.proto')) - if os.path.isfile(LICENSE): - shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE')) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/__init__.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/__init__.py deleted file mode 100644 index 235b3afcf4..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/__init__.py +++ /dev/null @@ -1,696 +0,0 @@ -# Copyright 2017 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. -"""Objects for use in testing gRPC Python-using application code.""" - -import abc - -from google.protobuf import descriptor -import grpc -import six - - -class UnaryUnaryChannelRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a unary-unary RPC invoked by a system under test. - - Enables users to "play server" for the RPC. - """ - - @abc.abstractmethod - def send_initial_metadata(self, initial_metadata): - """Sends the RPC's initial metadata to the system under test. - - Args: - initial_metadata: The RPC's initial metadata to be "sent" to - the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def cancelled(self): - """Blocks until the system under test has cancelled the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def terminate(self, response, trailing_metadata, code, details): - """Terminates the RPC. - - Args: - response: The response for the RPC. - trailing_metadata: The RPC's trailing metadata. - code: The RPC's status code. - details: The RPC's status details. - """ - raise NotImplementedError() - - -class UnaryStreamChannelRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a unary-stream RPC invoked by a system under test. - - Enables users to "play server" for the RPC. - """ - - @abc.abstractmethod - def send_initial_metadata(self, initial_metadata): - """Sends the RPC's initial metadata to the system under test. - - Args: - initial_metadata: The RPC's initial metadata to be "sent" to - the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def send_response(self, response): - """Sends a response to the system under test. - - Args: - response: A response message to be "sent" to the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def cancelled(self): - """Blocks until the system under test has cancelled the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def terminate(self, trailing_metadata, code, details): - """Terminates the RPC. - - Args: - trailing_metadata: The RPC's trailing metadata. - code: The RPC's status code. - details: The RPC's status details. - """ - raise NotImplementedError() - - -class StreamUnaryChannelRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a stream-unary RPC invoked by a system under test. - - Enables users to "play server" for the RPC. - """ - - @abc.abstractmethod - def send_initial_metadata(self, initial_metadata): - """Sends the RPC's initial metadata to the system under test. - - Args: - initial_metadata: The RPC's initial metadata to be "sent" to - the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_request(self): - """Draws one of the requests added to the RPC by the system under test. - - This method blocks until the system under test has added to the RPC - the request to be returned. - - Successive calls to this method return requests in the same order in - which the system under test added them to the RPC. - - Returns: - A request message added to the RPC by the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def requests_closed(self): - """Blocks until the system under test has closed the request stream.""" - raise NotImplementedError() - - @abc.abstractmethod - def cancelled(self): - """Blocks until the system under test has cancelled the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def terminate(self, response, trailing_metadata, code, details): - """Terminates the RPC. - - Args: - response: The response for the RPC. - trailing_metadata: The RPC's trailing metadata. - code: The RPC's status code. - details: The RPC's status details. - """ - raise NotImplementedError() - - -class StreamStreamChannelRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a stream-stream RPC invoked by a system under test. - - Enables users to "play server" for the RPC. - """ - - @abc.abstractmethod - def send_initial_metadata(self, initial_metadata): - """Sends the RPC's initial metadata to the system under test. - - Args: - initial_metadata: The RPC's initial metadata to be "sent" to the - system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_request(self): - """Draws one of the requests added to the RPC by the system under test. - - This method blocks until the system under test has added to the RPC - the request to be returned. - - Successive calls to this method return requests in the same order in - which the system under test added them to the RPC. - - Returns: - A request message added to the RPC by the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def send_response(self, response): - """Sends a response to the system under test. - - Args: - response: A response messages to be "sent" to the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def requests_closed(self): - """Blocks until the system under test has closed the request stream.""" - raise NotImplementedError() - - @abc.abstractmethod - def cancelled(self): - """Blocks until the system under test has cancelled the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def terminate(self, trailing_metadata, code, details): - """Terminates the RPC. - - Args: - trailing_metadata: The RPC's trailing metadata. - code: The RPC's status code. - details: The RPC's status details. - """ - raise NotImplementedError() - - -class Channel(six.with_metaclass(abc.ABCMeta, grpc.Channel)): - """A grpc.Channel double with which to test a system that invokes RPCs.""" - - @abc.abstractmethod - def take_unary_unary(self, method_descriptor): - """Draws an RPC currently being made by the system under test. - - If the given descriptor does not identify any RPC currently being made - by the system under test, this method blocks until the system under - test invokes such an RPC. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a - unary-unary RPC method. - - Returns: - A (invocation_metadata, request, unary_unary_channel_rpc) tuple of - the RPC's invocation metadata, its request, and a - UnaryUnaryChannelRpc with which to "play server" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_unary_stream(self, method_descriptor): - """Draws an RPC currently being made by the system under test. - - If the given descriptor does not identify any RPC currently being made - by the system under test, this method blocks until the system under - test invokes such an RPC. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a - unary-stream RPC method. - - Returns: - A (invocation_metadata, request, unary_stream_channel_rpc) tuple of - the RPC's invocation metadata, its request, and a - UnaryStreamChannelRpc with which to "play server" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_stream_unary(self, method_descriptor): - """Draws an RPC currently being made by the system under test. - - If the given descriptor does not identify any RPC currently being made - by the system under test, this method blocks until the system under - test invokes such an RPC. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a - stream-unary RPC method. - - Returns: - A (invocation_metadata, stream_unary_channel_rpc) tuple of the RPC's - invocation metadata and a StreamUnaryChannelRpc with which to "play - server" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_stream_stream(self, method_descriptor): - """Draws an RPC currently being made by the system under test. - - If the given descriptor does not identify any RPC currently being made - by the system under test, this method blocks until the system under - test invokes such an RPC. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a - stream-stream RPC method. - - Returns: - A (invocation_metadata, stream_stream_channel_rpc) tuple of the RPC's - invocation metadata and a StreamStreamChannelRpc with which to - "play server" for the RPC. - """ - raise NotImplementedError() - - -class UnaryUnaryServerRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a unary-unary RPC serviced by a system under test. - - Enables users to "play client" for the RPC. - """ - - @abc.abstractmethod - def initial_metadata(self): - """Accesses the initial metadata emitted by the system under test. - - This method blocks until the system under test has added initial - metadata to the RPC (or has provided one or more response messages or - has terminated the RPC, either of which will cause gRPC Python to - synthesize initial metadata for the RPC). - - Returns: - The initial metadata for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - """Cancels the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def termination(self): - """Blocks until the system under test has terminated the RPC. - - Returns: - A (response, trailing_metadata, code, details) sequence with the RPC's - response, trailing metadata, code, and details. - """ - raise NotImplementedError() - - -class UnaryStreamServerRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a unary-stream RPC serviced by a system under test. - - Enables users to "play client" for the RPC. - """ - - @abc.abstractmethod - def initial_metadata(self): - """Accesses the initial metadata emitted by the system under test. - - This method blocks until the system under test has added initial - metadata to the RPC (or has provided one or more response messages or - has terminated the RPC, either of which will cause gRPC Python to - synthesize initial metadata for the RPC). - - Returns: - The initial metadata for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def take_response(self): - """Draws one of the responses added to the RPC by the system under test. - - Successive calls to this method return responses in the same order in - which the system under test added them to the RPC. - - Returns: - A response message added to the RPC by the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - """Cancels the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def termination(self): - """Blocks until the system under test has terminated the RPC. - - Returns: - A (trailing_metadata, code, details) sequence with the RPC's trailing - metadata, code, and details. - """ - raise NotImplementedError() - - -class StreamUnaryServerRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a stream-unary RPC serviced by a system under test. - - Enables users to "play client" for the RPC. - """ - - @abc.abstractmethod - def initial_metadata(self): - """Accesses the initial metadata emitted by the system under test. - - This method blocks until the system under test has added initial - metadata to the RPC (or has provided one or more response messages or - has terminated the RPC, either of which will cause gRPC Python to - synthesize initial metadata for the RPC). - - Returns: - The initial metadata for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def send_request(self, request): - """Sends a request to the system under test. - - Args: - request: A request message for the RPC to be "sent" to the system - under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def requests_closed(self): - """Indicates the end of the RPC's request stream.""" - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - """Cancels the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def termination(self): - """Blocks until the system under test has terminated the RPC. - - Returns: - A (response, trailing_metadata, code, details) sequence with the RPC's - response, trailing metadata, code, and details. - """ - raise NotImplementedError() - - -class StreamStreamServerRpc(six.with_metaclass(abc.ABCMeta)): - """Fixture for a stream-stream RPC serviced by a system under test. - - Enables users to "play client" for the RPC. - """ - - @abc.abstractmethod - def initial_metadata(self): - """Accesses the initial metadata emitted by the system under test. - - This method blocks until the system under test has added initial - metadata to the RPC (or has provided one or more response messages or - has terminated the RPC, either of which will cause gRPC Python to - synthesize initial metadata for the RPC). - - Returns: - The initial metadata for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def send_request(self, request): - """Sends a request to the system under test. - - Args: - request: A request message for the RPC to be "sent" to the system - under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def requests_closed(self): - """Indicates the end of the RPC's request stream.""" - raise NotImplementedError() - - @abc.abstractmethod - def take_response(self): - """Draws one of the responses added to the RPC by the system under test. - - Successive calls to this method return responses in the same order in - which the system under test added them to the RPC. - - Returns: - A response message added to the RPC by the system under test. - """ - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - """Cancels the RPC.""" - raise NotImplementedError() - - @abc.abstractmethod - def termination(self): - """Blocks until the system under test has terminated the RPC. - - Returns: - A (trailing_metadata, code, details) sequence with the RPC's trailing - metadata, code, and details. - """ - raise NotImplementedError() - - -class Server(six.with_metaclass(abc.ABCMeta)): - """A server with which to test a system that services RPCs.""" - - @abc.abstractmethod - def invoke_unary_unary(self, method_descriptor, invocation_metadata, - request, timeout): - """Invokes an RPC to be serviced by the system under test. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a unary-unary - RPC method. - invocation_metadata: The RPC's invocation metadata. - request: The RPC's request. - timeout: A duration of time in seconds for the RPC or None to - indicate that the RPC has no time limit. - - Returns: - A UnaryUnaryServerRpc with which to "play client" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def invoke_unary_stream(self, method_descriptor, invocation_metadata, - request, timeout): - """Invokes an RPC to be serviced by the system under test. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a unary-stream - RPC method. - invocation_metadata: The RPC's invocation metadata. - request: The RPC's request. - timeout: A duration of time in seconds for the RPC or None to - indicate that the RPC has no time limit. - - Returns: - A UnaryStreamServerRpc with which to "play client" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def invoke_stream_unary(self, method_descriptor, invocation_metadata, - timeout): - """Invokes an RPC to be serviced by the system under test. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a stream-unary - RPC method. - invocation_metadata: The RPC's invocation metadata. - timeout: A duration of time in seconds for the RPC or None to - indicate that the RPC has no time limit. - - Returns: - A StreamUnaryServerRpc with which to "play client" for the RPC. - """ - raise NotImplementedError() - - @abc.abstractmethod - def invoke_stream_stream(self, method_descriptor, invocation_metadata, - timeout): - """Invokes an RPC to be serviced by the system under test. - - Args: - method_descriptor: A descriptor.MethodDescriptor describing a stream-stream - RPC method. - invocation_metadata: The RPC's invocation metadata. - timeout: A duration of time in seconds for the RPC or None to - indicate that the RPC has no time limit. - - Returns: - A StreamStreamServerRpc with which to "play client" for the RPC. - """ - raise NotImplementedError() - - -class Time(six.with_metaclass(abc.ABCMeta)): - """A simulation of time. - - Implementations needn't be connected with real time as provided by the - Python interpreter, but as long as systems under test use - RpcContext.is_active and RpcContext.time_remaining for querying RPC liveness - implementations may be used to change passage of time in tests. - """ - - @abc.abstractmethod - def time(self): - """Accesses the current test time. - - Returns: - The current test time (over which this object has authority). - """ - raise NotImplementedError() - - @abc.abstractmethod - def call_in(self, behavior, delay): - """Adds a behavior to be called after some time. - - Args: - behavior: A behavior to be called with no arguments. - delay: A duration of time in seconds after which to call the behavior. - - Returns: - A grpc.Future with which the call of the behavior may be cancelled - before it is executed. - """ - raise NotImplementedError() - - @abc.abstractmethod - def call_at(self, behavior, time): - """Adds a behavior to be called at a specific time. - - Args: - behavior: A behavior to be called with no arguments. - time: The test time at which to call the behavior. - - Returns: - A grpc.Future with which the call of the behavior may be cancelled - before it is executed. - """ - raise NotImplementedError() - - @abc.abstractmethod - def sleep_for(self, duration): - """Blocks for some length of test time. - - Args: - duration: A duration of test time in seconds for which to block. - """ - raise NotImplementedError() - - @abc.abstractmethod - def sleep_until(self, time): - """Blocks until some test time. - - Args: - time: The test time until which to block. - """ - raise NotImplementedError() - - -def strict_real_time(): - """Creates a Time backed by the Python interpreter's time. - - The returned instance will be "strict" with respect to callbacks - submitted to it: it will ensure that all callbacks registered to - be called at time t have been called before it describes the time - as having advanced beyond t. - - Returns: - A Time backed by the "system" (Python interpreter's) time. - """ - from grpc_testing import _time - return _time.StrictRealTime() - - -def strict_fake_time(now): - """Creates a Time that can be manipulated by test code. - - The returned instance maintains an internal representation of time - independent of real time. This internal representation only advances - when user code calls the instance's sleep_for and sleep_until methods. - - The returned instance will be "strict" with respect to callbacks - submitted to it: it will ensure that all callbacks registered to - be called at time t have been called before it describes the time - as having advanced beyond t. - - Returns: - A Time that simulates the passage of time. - """ - from grpc_testing import _time - return _time.StrictFakeTime(now) - - -def channel(service_descriptors, time): - """Creates a Channel for use in tests of a gRPC Python-using system. - - Args: - service_descriptors: An iterable of descriptor.ServiceDescriptors - describing the RPCs that will be made on the returned Channel by the - system under test. - time: A Time to be used for tests. - - Returns: - A Channel for use in tests. - """ - from grpc_testing import _channel - return _channel.testing_channel(service_descriptors, time) - - -def server_from_dictionary(descriptors_to_servicers, time): - """Creates a Server for use in tests of a gRPC Python-using system. - - Args: - descriptors_to_servicers: A dictionary from descriptor.ServiceDescriptors - defining RPC services to servicer objects (usually instances of classes - that implement "Servicer" interfaces defined in generated "_pb2_grpc" - modules) implementing those services. - time: A Time to be used for tests. - - Returns: - A Server for use in tests. - """ - from grpc_testing import _server - return _server.server_from_dictionary(descriptors_to_servicers, time) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/__init__.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/__init__.py deleted file mode 100644 index 7a64cda889..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from grpc_testing._channel import _channel -from grpc_testing._channel import _channel_state - - -# descriptors is reserved for later use. -# pylint: disable=unused-argument -def testing_channel(descriptors, time): - return _channel.TestingChannel(time, _channel_state.State()) - - -# pylint: enable=unused-argument diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel.py deleted file mode 100644 index 0c1941e6be..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc_testing -from grpc_testing._channel import _channel_rpc -from grpc_testing._channel import _multi_callable - - -# All serializer and deserializer parameters are not (yet) used by this -# test infrastructure. -# pylint: disable=unused-argument -class TestingChannel(grpc_testing.Channel): - - def __init__(self, time, state): - self._time = time - self._state = state - - def subscribe(self, callback, try_to_connect=False): - raise NotImplementedError() - - def unsubscribe(self, callback): - raise NotImplementedError() - - def unary_unary(self, - method, - request_serializer=None, - response_deserializer=None): - return _multi_callable.UnaryUnary(method, self._state) - - def unary_stream(self, - method, - request_serializer=None, - response_deserializer=None): - return _multi_callable.UnaryStream(method, self._state) - - def stream_unary(self, - method, - request_serializer=None, - response_deserializer=None): - return _multi_callable.StreamUnary(method, self._state) - - def stream_stream(self, - method, - request_serializer=None, - response_deserializer=None): - return _multi_callable.StreamStream(method, self._state) - - def _close(self): - # TODO(https://github.com/grpc/grpc/issues/12531): Decide what - # action to take here, if any? - pass - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - self._close() - return False - - def close(self): - self._close() - - def take_unary_unary(self, method_descriptor): - return _channel_rpc.unary_unary(self._state, method_descriptor) - - def take_unary_stream(self, method_descriptor): - return _channel_rpc.unary_stream(self._state, method_descriptor) - - def take_stream_unary(self, method_descriptor): - return _channel_rpc.stream_unary(self._state, method_descriptor) - - def take_stream_stream(self, method_descriptor): - return _channel_rpc.stream_stream(self._state, method_descriptor) - - -# pylint: enable=unused-argument diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py deleted file mode 100644 index 54499b3b55..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_rpc.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc_testing - - -class _UnaryUnary(grpc_testing.UnaryUnaryChannelRpc): - - def __init__(self, rpc_state): - self._rpc_state = rpc_state - - def send_initial_metadata(self, initial_metadata): - self._rpc_state.send_initial_metadata(initial_metadata) - - def cancelled(self): - self._rpc_state.cancelled() - - def terminate(self, response, trailing_metadata, code, details): - self._rpc_state.terminate_with_response(response, trailing_metadata, - code, details) - - -class _UnaryStream(grpc_testing.UnaryStreamChannelRpc): - - def __init__(self, rpc_state): - self._rpc_state = rpc_state - - def send_initial_metadata(self, initial_metadata): - self._rpc_state.send_initial_metadata(initial_metadata) - - def send_response(self, response): - self._rpc_state.send_response(response) - - def cancelled(self): - self._rpc_state.cancelled() - - def terminate(self, trailing_metadata, code, details): - self._rpc_state.terminate(trailing_metadata, code, details) - - -class _StreamUnary(grpc_testing.StreamUnaryChannelRpc): - - def __init__(self, rpc_state): - self._rpc_state = rpc_state - - def send_initial_metadata(self, initial_metadata): - self._rpc_state.send_initial_metadata(initial_metadata) - - def take_request(self): - return self._rpc_state.take_request() - - def requests_closed(self): - return self._rpc_state.requests_closed() - - def cancelled(self): - self._rpc_state.cancelled() - - def terminate(self, response, trailing_metadata, code, details): - self._rpc_state.terminate_with_response(response, trailing_metadata, - code, details) - - -class _StreamStream(grpc_testing.StreamStreamChannelRpc): - - def __init__(self, rpc_state): - self._rpc_state = rpc_state - - def send_initial_metadata(self, initial_metadata): - self._rpc_state.send_initial_metadata(initial_metadata) - - def take_request(self): - return self._rpc_state.take_request() - - def send_response(self, response): - self._rpc_state.send_response(response) - - def requests_closed(self): - return self._rpc_state.requests_closed() - - def cancelled(self): - self._rpc_state.cancelled() - - def terminate(self, trailing_metadata, code, details): - self._rpc_state.terminate(trailing_metadata, code, details) - - -def unary_unary(channel_state, method_descriptor): - rpc_state = channel_state.take_rpc_state(method_descriptor) - invocation_metadata, request = ( - rpc_state.take_invocation_metadata_and_request()) - return invocation_metadata, request, _UnaryUnary(rpc_state) - - -def unary_stream(channel_state, method_descriptor): - rpc_state = channel_state.take_rpc_state(method_descriptor) - invocation_metadata, request = ( - rpc_state.take_invocation_metadata_and_request()) - return invocation_metadata, request, _UnaryStream(rpc_state) - - -def stream_unary(channel_state, method_descriptor): - rpc_state = channel_state.take_rpc_state(method_descriptor) - return rpc_state.take_invocation_metadata(), _StreamUnary(rpc_state) - - -def stream_stream(channel_state, method_descriptor): - rpc_state = channel_state.take_rpc_state(method_descriptor) - return rpc_state.take_invocation_metadata(), _StreamStream(rpc_state) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py deleted file mode 100644 index 779d59e59a..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_channel_state.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import collections -import threading - -from grpc_testing import _common -from grpc_testing._channel import _rpc_state - - -class State(_common.ChannelHandler): - - def __init__(self): - self._condition = threading.Condition() - self._rpc_states = collections.defaultdict(list) - - def invoke_rpc(self, method_full_rpc_name, invocation_metadata, requests, - requests_closed, timeout): - rpc_state = _rpc_state.State(invocation_metadata, requests, - requests_closed) - with self._condition: - self._rpc_states[method_full_rpc_name].append(rpc_state) - self._condition.notify_all() - return rpc_state - - def take_rpc_state(self, method_descriptor): - method_full_rpc_name = '/{}/{}'.format( - method_descriptor.containing_service.full_name, - method_descriptor.name) - with self._condition: - while True: - method_rpc_states = self._rpc_states[method_full_rpc_name] - if method_rpc_states: - return method_rpc_states.pop(0) - else: - self._condition.wait() diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py deleted file mode 100644 index d7205ca579..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_invocation.py +++ /dev/null @@ -1,324 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import threading - -import grpc - -_NOT_YET_OBSERVED = object() -logging.basicConfig() -_LOGGER = logging.getLogger(__name__) - - -def _cancel(handler): - return handler.cancel(grpc.StatusCode.CANCELLED, 'Locally cancelled!') - - -def _is_active(handler): - return handler.is_active() - - -def _time_remaining(unused_handler): - raise NotImplementedError() - - -def _add_callback(handler, callback): - return handler.add_callback(callback) - - -def _initial_metadata(handler): - return handler.initial_metadata() - - -def _trailing_metadata(handler): - trailing_metadata, unused_code, unused_details = handler.termination() - return trailing_metadata - - -def _code(handler): - unused_trailing_metadata, code, unused_details = handler.termination() - return code - - -def _details(handler): - unused_trailing_metadata, unused_code, details = handler.termination() - return details - - -class _Call(grpc.Call): - - def __init__(self, handler): - self._handler = handler - - def cancel(self): - _cancel(self._handler) - - def is_active(self): - return _is_active(self._handler) - - def time_remaining(self): - return _time_remaining(self._handler) - - def add_callback(self, callback): - return _add_callback(self._handler, callback) - - def initial_metadata(self): - return _initial_metadata(self._handler) - - def trailing_metadata(self): - return _trailing_metadata(self._handler) - - def code(self): - return _code(self._handler) - - def details(self): - return _details(self._handler) - - -class _RpcErrorCall(grpc.RpcError, grpc.Call): - - def __init__(self, handler): - self._handler = handler - - def cancel(self): - _cancel(self._handler) - - def is_active(self): - return _is_active(self._handler) - - def time_remaining(self): - return _time_remaining(self._handler) - - def add_callback(self, callback): - return _add_callback(self._handler, callback) - - def initial_metadata(self): - return _initial_metadata(self._handler) - - def trailing_metadata(self): - return _trailing_metadata(self._handler) - - def code(self): - return _code(self._handler) - - def details(self): - return _details(self._handler) - - -def _next(handler): - read = handler.take_response() - if read.code is None: - return read.response - elif read.code is grpc.StatusCode.OK: - raise StopIteration() - else: - raise _RpcErrorCall(handler) - - -class _HandlerExtras(object): - - def __init__(self): - self.condition = threading.Condition() - self.unary_response = _NOT_YET_OBSERVED - self.cancelled = False - - -def _with_extras_cancel(handler, extras): - with extras.condition: - if handler.cancel(grpc.StatusCode.CANCELLED, 'Locally cancelled!'): - extras.cancelled = True - return True - else: - return False - - -def _extras_without_cancelled(extras): - with extras.condition: - return extras.cancelled - - -def _running(handler): - return handler.is_active() - - -def _done(handler): - return not handler.is_active() - - -def _with_extras_unary_response(handler, extras): - with extras.condition: - if extras.unary_response is _NOT_YET_OBSERVED: - read = handler.take_response() - if read.code is None: - extras.unary_response = read.response - return read.response - else: - raise _RpcErrorCall(handler) - else: - return extras.unary_response - - -def _exception(unused_handler): - raise NotImplementedError('TODO!') - - -def _traceback(unused_handler): - raise NotImplementedError('TODO!') - - -def _add_done_callback(handler, callback, future): - adapted_callback = lambda: callback(future) - if not handler.add_callback(adapted_callback): - callback(future) - - -class _FutureCall(grpc.Future, grpc.Call): - - def __init__(self, handler, extras): - self._handler = handler - self._extras = extras - - def cancel(self): - return _with_extras_cancel(self._handler, self._extras) - - def cancelled(self): - return _extras_without_cancelled(self._extras) - - def running(self): - return _running(self._handler) - - def done(self): - return _done(self._handler) - - def result(self): - return _with_extras_unary_response(self._handler, self._extras) - - def exception(self): - return _exception(self._handler) - - def traceback(self): - return _traceback(self._handler) - - def add_done_callback(self, fn): - _add_done_callback(self._handler, fn, self) - - def is_active(self): - return _is_active(self._handler) - - def time_remaining(self): - return _time_remaining(self._handler) - - def add_callback(self, callback): - return _add_callback(self._handler, callback) - - def initial_metadata(self): - return _initial_metadata(self._handler) - - def trailing_metadata(self): - return _trailing_metadata(self._handler) - - def code(self): - return _code(self._handler) - - def details(self): - return _details(self._handler) - - -def consume_requests(request_iterator, handler): - - def _consume(): - while True: - try: - request = next(request_iterator) - added = handler.add_request(request) - if not added: - break - except StopIteration: - handler.close_requests() - break - except Exception: # pylint: disable=broad-except - details = 'Exception iterating requests!' - _LOGGER.exception(details) - handler.cancel(grpc.StatusCode.UNKNOWN, details) - - consumption = threading.Thread(target=_consume) - consumption.start() - - -def blocking_unary_response(handler): - read = handler.take_response() - if read.code is None: - unused_trailing_metadata, code, unused_details = handler.termination() - if code is grpc.StatusCode.OK: - return read.response - else: - raise _RpcErrorCall(handler) - else: - raise _RpcErrorCall(handler) - - -def blocking_unary_response_with_call(handler): - read = handler.take_response() - if read.code is None: - unused_trailing_metadata, code, unused_details = handler.termination() - if code is grpc.StatusCode.OK: - return read.response, _Call(handler) - else: - raise _RpcErrorCall(handler) - else: - raise _RpcErrorCall(handler) - - -def future_call(handler): - return _FutureCall(handler, _HandlerExtras()) - - -class ResponseIteratorCall(grpc.Call): - - def __init__(self, handler): - self._handler = handler - - def __iter__(self): - return self - - def __next__(self): - return _next(self._handler) - - def next(self): - return _next(self._handler) - - def cancel(self): - _cancel(self._handler) - - def is_active(self): - return _is_active(self._handler) - - def time_remaining(self): - return _time_remaining(self._handler) - - def add_callback(self, callback): - return _add_callback(self._handler, callback) - - def initial_metadata(self): - return _initial_metadata(self._handler) - - def trailing_metadata(self): - return _trailing_metadata(self._handler) - - def code(self): - return _code(self._handler) - - def details(self): - return _details(self._handler) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py deleted file mode 100644 index 2b2f5761f5..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_multi_callable.py +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc -from grpc_testing import _common -from grpc_testing._channel import _invocation - - -# All per-call credentials parameters are unused by this test infrastructure. -# pylint: disable=unused-argument -class UnaryUnary(grpc.UnaryUnaryMultiCallable): - - def __init__(self, method_full_rpc_name, channel_handler): - self._method_full_rpc_name = method_full_rpc_name - self._channel_handler = channel_handler - - def __call__(self, request, timeout=None, metadata=None, credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) - return _invocation.blocking_unary_response(rpc_handler) - - def with_call(self, request, timeout=None, metadata=None, credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) - return _invocation.blocking_unary_response_with_call(rpc_handler) - - def future(self, request, timeout=None, metadata=None, credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) - return _invocation.future_call(rpc_handler) - - -class UnaryStream(grpc.StreamStreamMultiCallable): - - def __init__(self, method_full_rpc_name, channel_handler): - self._method_full_rpc_name = method_full_rpc_name - self._channel_handler = channel_handler - - def __call__(self, request, timeout=None, metadata=None, credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [request], True, timeout) - return _invocation.ResponseIteratorCall(rpc_handler) - - -class StreamUnary(grpc.StreamUnaryMultiCallable): - - def __init__(self, method_full_rpc_name, channel_handler): - self._method_full_rpc_name = method_full_rpc_name - self._channel_handler = channel_handler - - def __call__(self, - request_iterator, - timeout=None, - metadata=None, - credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [], False, timeout) - _invocation.consume_requests(request_iterator, rpc_handler) - return _invocation.blocking_unary_response(rpc_handler) - - def with_call(self, - request_iterator, - timeout=None, - metadata=None, - credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [], False, timeout) - _invocation.consume_requests(request_iterator, rpc_handler) - return _invocation.blocking_unary_response_with_call(rpc_handler) - - def future(self, - request_iterator, - timeout=None, - metadata=None, - credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [], False, timeout) - _invocation.consume_requests(request_iterator, rpc_handler) - return _invocation.future_call(rpc_handler) - - -class StreamStream(grpc.StreamStreamMultiCallable): - - def __init__(self, method_full_rpc_name, channel_handler): - self._method_full_rpc_name = method_full_rpc_name - self._channel_handler = channel_handler - - def __call__(self, - request_iterator, - timeout=None, - metadata=None, - credentials=None): - rpc_handler = self._channel_handler.invoke_rpc( - self._method_full_rpc_name, _common.fuss_with_metadata(metadata), - [], False, timeout) - _invocation.consume_requests(request_iterator, rpc_handler) - return _invocation.ResponseIteratorCall(rpc_handler) - - -# pylint: enable=unused-argument diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py deleted file mode 100644 index a548ef0f12..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_channel/_rpc_state.py +++ /dev/null @@ -1,193 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import threading - -import grpc -from grpc_testing import _common - - -class State(_common.ChannelRpcHandler): - - def __init__(self, invocation_metadata, requests, requests_closed): - self._condition = threading.Condition() - self._invocation_metadata = invocation_metadata - self._requests = requests - self._requests_closed = requests_closed - self._initial_metadata = None - self._responses = [] - self._trailing_metadata = None - self._code = None - self._details = None - - def initial_metadata(self): - with self._condition: - while True: - if self._initial_metadata is None: - if self._code is None: - self._condition.wait() - else: - return _common.FUSSED_EMPTY_METADATA - else: - return self._initial_metadata - - def add_request(self, request): - with self._condition: - if self._code is None and not self._requests_closed: - self._requests.append(request) - self._condition.notify_all() - return True - else: - return False - - def close_requests(self): - with self._condition: - if self._code is None and not self._requests_closed: - self._requests_closed = True - self._condition.notify_all() - - def take_response(self): - with self._condition: - while True: - if self._code is grpc.StatusCode.OK: - if self._responses: - response = self._responses.pop(0) - return _common.ChannelRpcRead(response, None, None, - None) - else: - return _common.ChannelRpcRead(None, - self._trailing_metadata, - grpc.StatusCode.OK, - self._details) - elif self._code is None: - if self._responses: - response = self._responses.pop(0) - return _common.ChannelRpcRead(response, None, None, - None) - else: - self._condition.wait() - else: - return _common.ChannelRpcRead(None, self._trailing_metadata, - self._code, self._details) - - def termination(self): - with self._condition: - while True: - if self._code is None: - self._condition.wait() - else: - return self._trailing_metadata, self._code, self._details - - def cancel(self, code, details): - with self._condition: - if self._code is None: - if self._initial_metadata is None: - self._initial_metadata = _common.FUSSED_EMPTY_METADATA - self._trailing_metadata = _common.FUSSED_EMPTY_METADATA - self._code = code - self._details = details - self._condition.notify_all() - return True - else: - return False - - def take_invocation_metadata(self): - with self._condition: - if self._invocation_metadata is None: - raise ValueError('Expected invocation metadata!') - else: - invocation_metadata = self._invocation_metadata - self._invocation_metadata = None - return invocation_metadata - - def take_invocation_metadata_and_request(self): - with self._condition: - if self._invocation_metadata is None: - raise ValueError('Expected invocation metadata!') - elif not self._requests: - raise ValueError('Expected at least one request!') - else: - invocation_metadata = self._invocation_metadata - self._invocation_metadata = None - return invocation_metadata, self._requests.pop(0) - - def send_initial_metadata(self, initial_metadata): - with self._condition: - self._initial_metadata = _common.fuss_with_metadata( - initial_metadata) - self._condition.notify_all() - - def take_request(self): - with self._condition: - while True: - if self._requests: - return self._requests.pop(0) - else: - self._condition.wait() - - def requests_closed(self): - with self._condition: - while True: - if self._requests_closed: - return - else: - self._condition.wait() - - def send_response(self, response): - with self._condition: - if self._code is None: - self._responses.append(response) - self._condition.notify_all() - - def terminate_with_response(self, response, trailing_metadata, code, - details): - with self._condition: - if self._initial_metadata is None: - self._initial_metadata = _common.FUSSED_EMPTY_METADATA - self._responses.append(response) - self._trailing_metadata = _common.fuss_with_metadata( - trailing_metadata) - self._code = code - self._details = details - self._condition.notify_all() - - def terminate(self, trailing_metadata, code, details): - with self._condition: - if self._initial_metadata is None: - self._initial_metadata = _common.FUSSED_EMPTY_METADATA - self._trailing_metadata = _common.fuss_with_metadata( - trailing_metadata) - self._code = code - self._details = details - self._condition.notify_all() - - def cancelled(self): - with self._condition: - while True: - if self._code is grpc.StatusCode.CANCELLED: - return - elif self._code is None: - self._condition.wait() - else: - raise ValueError('Status code unexpectedly {}!'.format( - self._code)) - - def is_active(self): - raise NotImplementedError() - - def time_remaining(self): - raise NotImplementedError() - - def add_callback(self, callback): - raise NotImplementedError() diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_common.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_common.py deleted file mode 100644 index cebad31b5c..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_common.py +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright 2017 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. -"""Common interfaces and implementation.""" - -import abc -import collections - -import six - - -def _fuss(tuplified_metadata): - return tuplified_metadata + (( - 'grpc.metadata_added_by_runtime', - 'gRPC is allowed to add metadata in transmission and does so.', - ),) - - -FUSSED_EMPTY_METADATA = _fuss(()) - - -def fuss_with_metadata(metadata): - if metadata is None: - return FUSSED_EMPTY_METADATA - else: - return _fuss(tuple(metadata)) - - -def rpc_names(service_descriptors): - rpc_names_to_descriptors = {} - for service_descriptor in service_descriptors: - for method_descriptor in service_descriptor.methods_by_name.values(): - rpc_name = '/{}/{}'.format(service_descriptor.full_name, - method_descriptor.name) - rpc_names_to_descriptors[rpc_name] = method_descriptor - return rpc_names_to_descriptors - - -class ChannelRpcRead( - collections.namedtuple('ChannelRpcRead', ( - 'response', - 'trailing_metadata', - 'code', - 'details', - ))): - pass - - -class ChannelRpcHandler(six.with_metaclass(abc.ABCMeta)): - - @abc.abstractmethod - def initial_metadata(self): - raise NotImplementedError() - - @abc.abstractmethod - def add_request(self, request): - raise NotImplementedError() - - @abc.abstractmethod - def close_requests(self): - raise NotImplementedError() - - @abc.abstractmethod - def take_response(self): - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self, code, details): - raise NotImplementedError() - - @abc.abstractmethod - def termination(self): - raise NotImplementedError() - - @abc.abstractmethod - def is_active(self): - raise NotImplementedError() - - @abc.abstractmethod - def time_remaining(self): - raise NotImplementedError() - - @abc.abstractmethod - def add_callback(self, callback): - raise NotImplementedError() - - -class ChannelHandler(six.with_metaclass(abc.ABCMeta)): - - @abc.abstractmethod - def invoke_rpc(self, method_full_rpc_name, invocation_metadata, requests, - requests_closed, timeout): - raise NotImplementedError() - - -class ServerRpcRead( - collections.namedtuple('ServerRpcRead', ( - 'request', - 'requests_closed', - 'terminated', - ))): - pass - - -REQUESTS_CLOSED = ServerRpcRead(None, True, False) -TERMINATED = ServerRpcRead(None, False, True) - - -class ServerRpcHandler(six.with_metaclass(abc.ABCMeta)): - - @abc.abstractmethod - def send_initial_metadata(self, initial_metadata): - raise NotImplementedError() - - @abc.abstractmethod - def take_request(self): - raise NotImplementedError() - - @abc.abstractmethod - def add_response(self, response): - raise NotImplementedError() - - @abc.abstractmethod - def send_termination(self, trailing_metadata, code, details): - raise NotImplementedError() - - @abc.abstractmethod - def add_termination_callback(self, callback): - raise NotImplementedError() - - -class Serverish(six.with_metaclass(abc.ABCMeta)): - - @abc.abstractmethod - def invoke_unary_unary(self, method_descriptor, handler, - invocation_metadata, request, deadline): - raise NotImplementedError() - - @abc.abstractmethod - def invoke_unary_stream(self, method_descriptor, handler, - invocation_metadata, request, deadline): - raise NotImplementedError() - - @abc.abstractmethod - def invoke_stream_unary(self, method_descriptor, handler, - invocation_metadata, deadline): - raise NotImplementedError() - - @abc.abstractmethod - def invoke_stream_stream(self, method_descriptor, handler, - invocation_metadata, deadline): - raise NotImplementedError() diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/__init__.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/__init__.py deleted file mode 100644 index 5f035a91ca..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from grpc_testing._server import _server - - -def server_from_dictionary(descriptors_to_servicers, time): - return _server.server_from_descriptor_to_servicers(descriptors_to_servicers, - time) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_handler.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_handler.py deleted file mode 100644 index 100d8195f6..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_handler.py +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import abc -import threading - -import grpc -from grpc_testing import _common - -_CLIENT_INACTIVE = object() - - -class Handler(_common.ServerRpcHandler): - - @abc.abstractmethod - def initial_metadata(self): - raise NotImplementedError() - - @abc.abstractmethod - def add_request(self, request): - raise NotImplementedError() - - @abc.abstractmethod - def take_response(self): - raise NotImplementedError() - - @abc.abstractmethod - def requests_closed(self): - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - raise NotImplementedError() - - @abc.abstractmethod - def unary_response_termination(self): - raise NotImplementedError() - - @abc.abstractmethod - def stream_response_termination(self): - raise NotImplementedError() - - -class _Handler(Handler): - - def __init__(self, requests_closed): - self._condition = threading.Condition() - self._requests = [] - self._requests_closed = requests_closed - self._initial_metadata = None - self._responses = [] - self._trailing_metadata = None - self._code = None - self._details = None - self._unary_response = None - self._expiration_future = None - self._termination_callbacks = [] - - def send_initial_metadata(self, initial_metadata): - with self._condition: - self._initial_metadata = initial_metadata - self._condition.notify_all() - - def take_request(self): - with self._condition: - while True: - if self._code is None: - if self._requests: - request = self._requests.pop(0) - self._condition.notify_all() - return _common.ServerRpcRead(request, False, False) - elif self._requests_closed: - return _common.REQUESTS_CLOSED - else: - self._condition.wait() - else: - return _common.TERMINATED - - def is_active(self): - with self._condition: - return self._code is None - - def add_response(self, response): - with self._condition: - self._responses.append(response) - self._condition.notify_all() - - def send_termination(self, trailing_metadata, code, details): - with self._condition: - self._trailing_metadata = trailing_metadata - self._code = code - self._details = details - if self._expiration_future is not None: - self._expiration_future.cancel() - self._condition.notify_all() - - def add_termination_callback(self, callback): - with self._condition: - if self._code is None: - self._termination_callbacks.append(callback) - return True - else: - return False - - def initial_metadata(self): - with self._condition: - while True: - if self._initial_metadata is None: - if self._code is None: - self._condition.wait() - else: - raise ValueError( - 'No initial metadata despite status code!') - else: - return self._initial_metadata - - def add_request(self, request): - with self._condition: - self._requests.append(request) - self._condition.notify_all() - - def take_response(self): - with self._condition: - while True: - if self._responses: - response = self._responses.pop(0) - self._condition.notify_all() - return response - elif self._code is None: - self._condition.wait() - else: - raise ValueError('No more responses!') - - def requests_closed(self): - with self._condition: - self._requests_closed = True - self._condition.notify_all() - - def cancel(self): - with self._condition: - if self._code is None: - self._code = _CLIENT_INACTIVE - termination_callbacks = self._termination_callbacks - self._termination_callbacks = None - if self._expiration_future is not None: - self._expiration_future.cancel() - self._condition.notify_all() - for termination_callback in termination_callbacks: - termination_callback() - - def unary_response_termination(self): - with self._condition: - while True: - if self._code is _CLIENT_INACTIVE: - raise ValueError('Huh? Cancelled but wanting status?') - elif self._code is None: - self._condition.wait() - else: - if self._unary_response is None: - if self._responses: - self._unary_response = self._responses.pop(0) - return ( - self._unary_response, - self._trailing_metadata, - self._code, - self._details, - ) - - def stream_response_termination(self): - with self._condition: - while True: - if self._code is _CLIENT_INACTIVE: - raise ValueError('Huh? Cancelled but wanting status?') - elif self._code is None: - self._condition.wait() - else: - return self._trailing_metadata, self._code, self._details - - def expire(self): - with self._condition: - if self._code is None: - if self._initial_metadata is None: - self._initial_metadata = _common.FUSSED_EMPTY_METADATA - self._trailing_metadata = _common.FUSSED_EMPTY_METADATA - self._code = grpc.StatusCode.DEADLINE_EXCEEDED - self._details = 'Took too much time!' - termination_callbacks = self._termination_callbacks - self._termination_callbacks = None - self._condition.notify_all() - for termination_callback in termination_callbacks: - termination_callback() - - def set_expiration_future(self, expiration_future): - with self._condition: - self._expiration_future = expiration_future - - -def handler_without_deadline(requests_closed): - return _Handler(requests_closed) - - -def handler_with_deadline(requests_closed, time, deadline): - handler = _Handler(requests_closed) - expiration_future = time.call_at(handler.expire, deadline) - handler.set_expiration_future(expiration_future) - return handler diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_rpc.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_rpc.py deleted file mode 100644 index 736b714dc6..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_rpc.py +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import threading - -import grpc -from grpc_testing import _common - -logging.basicConfig() -_LOGGER = logging.getLogger(__name__) - - -class Rpc(object): - - def __init__(self, handler, invocation_metadata): - self._condition = threading.Condition() - self._handler = handler - self._invocation_metadata = invocation_metadata - self._initial_metadata_sent = False - self._pending_trailing_metadata = None - self._pending_code = None - self._pending_details = None - self._callbacks = [] - self._active = True - self._rpc_errors = [] - - def _ensure_initial_metadata_sent(self): - if not self._initial_metadata_sent: - self._handler.send_initial_metadata(_common.FUSSED_EMPTY_METADATA) - self._initial_metadata_sent = True - - def _call_back(self): - callbacks = tuple(self._callbacks) - self._callbacks = None - - def call_back(): - for callback in callbacks: - try: - callback() - except Exception: # pylint: disable=broad-except - _LOGGER.exception('Exception calling server-side callback!') - - callback_calling_thread = threading.Thread(target=call_back) - callback_calling_thread.start() - - def _terminate(self, trailing_metadata, code, details): - if self._active: - self._active = False - self._handler.send_termination(trailing_metadata, code, details) - self._call_back() - self._condition.notify_all() - - def _complete(self): - if self._pending_trailing_metadata is None: - trailing_metadata = _common.FUSSED_EMPTY_METADATA - else: - trailing_metadata = self._pending_trailing_metadata - if self._pending_code is None: - code = grpc.StatusCode.OK - else: - code = self._pending_code - details = '' if self._pending_details is None else self._pending_details - self._terminate(trailing_metadata, code, details) - - def _abort(self, code, details): - self._terminate(_common.FUSSED_EMPTY_METADATA, code, details) - - def add_rpc_error(self, rpc_error): - with self._condition: - self._rpc_errors.append(rpc_error) - - def application_cancel(self): - with self._condition: - self._abort(grpc.StatusCode.CANCELLED, - 'Cancelled by server-side application!') - - def application_exception_abort(self, exception): - with self._condition: - if exception not in self._rpc_errors: - _LOGGER.exception('Exception calling application!') - self._abort( - grpc.StatusCode.UNKNOWN, - 'Exception calling application: {}'.format(exception)) - - def extrinsic_abort(self): - with self._condition: - if self._active: - self._active = False - self._call_back() - self._condition.notify_all() - - def unary_response_complete(self, response): - with self._condition: - self._ensure_initial_metadata_sent() - self._handler.add_response(response) - self._complete() - - def stream_response(self, response): - with self._condition: - self._ensure_initial_metadata_sent() - self._handler.add_response(response) - - def stream_response_complete(self): - with self._condition: - self._ensure_initial_metadata_sent() - self._complete() - - def send_initial_metadata(self, initial_metadata): - with self._condition: - if self._initial_metadata_sent: - return False - else: - self._handler.send_initial_metadata(initial_metadata) - self._initial_metadata_sent = True - return True - - def is_active(self): - with self._condition: - return self._active - - def add_callback(self, callback): - with self._condition: - if self._callbacks is None: - return False - else: - self._callbacks.append(callback) - return True - - def invocation_metadata(self): - with self._condition: - return self._invocation_metadata - - def set_trailing_metadata(self, trailing_metadata): - with self._condition: - self._pending_trailing_metadata = trailing_metadata - - def set_code(self, code): - with self._condition: - self._pending_code = code - - def set_details(self, details): - with self._condition: - self._pending_details = details diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server.py deleted file mode 100644 index 6d256d848f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import threading - -import grpc_testing -from grpc_testing import _common -from grpc_testing._server import _handler -from grpc_testing._server import _rpc -from grpc_testing._server import _server_rpc -from grpc_testing._server import _service -from grpc_testing._server import _servicer_context - - -def _implementation(descriptors_to_servicers, method_descriptor): - servicer = descriptors_to_servicers[method_descriptor.containing_service] - return getattr(servicer, method_descriptor.name) - - -def _unary_unary_service(request): - - def service(implementation, rpc, servicer_context): - _service.unary_unary(implementation, rpc, request, servicer_context) - - return service - - -def _unary_stream_service(request): - - def service(implementation, rpc, servicer_context): - _service.unary_stream(implementation, rpc, request, servicer_context) - - return service - - -def _stream_unary_service(handler): - - def service(implementation, rpc, servicer_context): - _service.stream_unary(implementation, rpc, handler, servicer_context) - - return service - - -def _stream_stream_service(handler): - - def service(implementation, rpc, servicer_context): - _service.stream_stream(implementation, rpc, handler, servicer_context) - - return service - - -class _Serverish(_common.Serverish): - - def __init__(self, descriptors_to_servicers, time): - self._descriptors_to_servicers = descriptors_to_servicers - self._time = time - - def _invoke(self, service_behavior, method_descriptor, handler, - invocation_metadata, deadline): - implementation = _implementation(self._descriptors_to_servicers, - method_descriptor) - rpc = _rpc.Rpc(handler, invocation_metadata) - if handler.add_termination_callback(rpc.extrinsic_abort): - servicer_context = _servicer_context.ServicerContext( - rpc, self._time, deadline) - service_thread = threading.Thread(target=service_behavior, - args=( - implementation, - rpc, - servicer_context, - )) - service_thread.start() - - def invoke_unary_unary(self, method_descriptor, handler, - invocation_metadata, request, deadline): - self._invoke(_unary_unary_service(request), method_descriptor, handler, - invocation_metadata, deadline) - - def invoke_unary_stream(self, method_descriptor, handler, - invocation_metadata, request, deadline): - self._invoke(_unary_stream_service(request), method_descriptor, handler, - invocation_metadata, deadline) - - def invoke_stream_unary(self, method_descriptor, handler, - invocation_metadata, deadline): - self._invoke(_stream_unary_service(handler), method_descriptor, handler, - invocation_metadata, deadline) - - def invoke_stream_stream(self, method_descriptor, handler, - invocation_metadata, deadline): - self._invoke(_stream_stream_service(handler), method_descriptor, - handler, invocation_metadata, deadline) - - -def _deadline_and_handler(requests_closed, time, timeout): - if timeout is None: - return None, _handler.handler_without_deadline(requests_closed) - else: - deadline = time.time() + timeout - handler = _handler.handler_with_deadline(requests_closed, time, - deadline) - return deadline, handler - - -class _Server(grpc_testing.Server): - - def __init__(self, serverish, time): - self._serverish = serverish - self._time = time - - def invoke_unary_unary(self, method_descriptor, invocation_metadata, - request, timeout): - deadline, handler = _deadline_and_handler(True, self._time, timeout) - self._serverish.invoke_unary_unary(method_descriptor, handler, - invocation_metadata, request, - deadline) - return _server_rpc.UnaryUnaryServerRpc(handler) - - def invoke_unary_stream(self, method_descriptor, invocation_metadata, - request, timeout): - deadline, handler = _deadline_and_handler(True, self._time, timeout) - self._serverish.invoke_unary_stream(method_descriptor, handler, - invocation_metadata, request, - deadline) - return _server_rpc.UnaryStreamServerRpc(handler) - - def invoke_stream_unary(self, method_descriptor, invocation_metadata, - timeout): - deadline, handler = _deadline_and_handler(False, self._time, timeout) - self._serverish.invoke_stream_unary(method_descriptor, handler, - invocation_metadata, deadline) - return _server_rpc.StreamUnaryServerRpc(handler) - - def invoke_stream_stream(self, method_descriptor, invocation_metadata, - timeout): - deadline, handler = _deadline_and_handler(False, self._time, timeout) - self._serverish.invoke_stream_stream(method_descriptor, handler, - invocation_metadata, deadline) - return _server_rpc.StreamStreamServerRpc(handler) - - -def server_from_descriptor_to_servicers(descriptors_to_servicers, time): - return _Server(_Serverish(descriptors_to_servicers, time), time) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server_rpc.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server_rpc.py deleted file mode 100644 index 30de8ff0e2..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_server_rpc.py +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc_testing - - -class UnaryUnaryServerRpc(grpc_testing.UnaryUnaryServerRpc): - - def __init__(self, handler): - self._handler = handler - - def initial_metadata(self): - return self._handler.initial_metadata() - - def cancel(self): - self._handler.cancel() - - def termination(self): - return self._handler.unary_response_termination() - - -class UnaryStreamServerRpc(grpc_testing.UnaryStreamServerRpc): - - def __init__(self, handler): - self._handler = handler - - def initial_metadata(self): - return self._handler.initial_metadata() - - def take_response(self): - return self._handler.take_response() - - def cancel(self): - self._handler.cancel() - - def termination(self): - return self._handler.stream_response_termination() - - -class StreamUnaryServerRpc(grpc_testing.StreamUnaryServerRpc): - - def __init__(self, handler): - self._handler = handler - - def initial_metadata(self): - return self._handler.initial_metadata() - - def send_request(self, request): - self._handler.add_request(request) - - def requests_closed(self): - self._handler.requests_closed() - - def cancel(self): - self._handler.cancel() - - def termination(self): - return self._handler.unary_response_termination() - - -class StreamStreamServerRpc(grpc_testing.StreamStreamServerRpc): - - def __init__(self, handler): - self._handler = handler - - def initial_metadata(self): - return self._handler.initial_metadata() - - def send_request(self, request): - self._handler.add_request(request) - - def requests_closed(self): - self._handler.requests_closed() - - def take_response(self): - return self._handler.take_response() - - def cancel(self): - self._handler.cancel() - - def termination(self): - return self._handler.stream_response_termination() diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_service.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_service.py deleted file mode 100644 index 661257e275..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_service.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import copy - -import grpc - - -class _RequestIterator(object): - - def __init__(self, rpc, handler): - self._rpc = rpc - self._handler = handler - - def _next(self): - read = self._handler.take_request() - if read.requests_closed: - raise StopIteration() - elif read.terminated: - rpc_error = grpc.RpcError() - self._rpc.add_rpc_error(rpc_error) - raise rpc_error - else: - return read.request - - def __iter__(self): - return self - - def __next__(self): - return self._next() - - def next(self): - return self._next() - - -def _unary_response(argument, implementation, rpc, servicer_context): - try: - response = implementation(argument, servicer_context) - except Exception as exception: # pylint: disable=broad-except - rpc.application_exception_abort(exception) - else: - rpc.unary_response_complete(response) - - -def _stream_response(argument, implementation, rpc, servicer_context): - try: - response_iterator = implementation(argument, servicer_context) - except Exception as exception: # pylint: disable=broad-except - rpc.application_exception_abort(exception) - else: - while True: - try: - response = copy.deepcopy(next(response_iterator)) - except StopIteration: - rpc.stream_response_complete() - break - except Exception as exception: # pylint: disable=broad-except - rpc.application_exception_abort(exception) - break - else: - rpc.stream_response(response) - - -def unary_unary(implementation, rpc, request, servicer_context): - _unary_response(request, implementation, rpc, servicer_context) - - -def unary_stream(implementation, rpc, request, servicer_context): - _stream_response(request, implementation, rpc, servicer_context) - - -def stream_unary(implementation, rpc, handler, servicer_context): - _unary_response(_RequestIterator(rpc, handler), implementation, rpc, - servicer_context) - - -def stream_stream(implementation, rpc, handler, servicer_context): - _stream_response(_RequestIterator(rpc, handler), implementation, rpc, - servicer_context) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py deleted file mode 100644 index c63750f978..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_server/_servicer_context.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc -from grpc_testing import _common - - -class ServicerContext(grpc.ServicerContext): - - def __init__(self, rpc, time, deadline): - self._rpc = rpc - self._time = time - self._deadline = deadline - - def is_active(self): - return self._rpc.is_active() - - def time_remaining(self): - if self._rpc.is_active(): - if self._deadline is None: - return None - else: - return max(0.0, self._deadline - self._time.time()) - else: - return 0.0 - - def cancel(self): - self._rpc.application_cancel() - - def add_callback(self, callback): - return self._rpc.add_callback(callback) - - def invocation_metadata(self): - return self._rpc.invocation_metadata() - - def peer(self): - raise NotImplementedError() - - def peer_identities(self): - raise NotImplementedError() - - def peer_identity_key(self): - raise NotImplementedError() - - def auth_context(self): - raise NotImplementedError() - - def set_compression(self): - raise NotImplementedError() - - def send_initial_metadata(self, initial_metadata): - initial_metadata_sent = self._rpc.send_initial_metadata( - _common.fuss_with_metadata(initial_metadata)) - if not initial_metadata_sent: - raise ValueError( - 'ServicerContext.send_initial_metadata called too late!') - - def disable_next_message_compression(self): - raise NotImplementedError() - - def set_trailing_metadata(self, trailing_metadata): - self._rpc.set_trailing_metadata( - _common.fuss_with_metadata(trailing_metadata)) - - def abort(self, code, details): - with self._rpc._condition: - self._rpc._abort(code, details) - raise Exception() - - def abort_with_status(self, status): - raise NotImplementedError() - - def set_code(self, code): - self._rpc.set_code(code) - - def set_details(self, details): - self._rpc.set_details(details) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_time.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_time.py deleted file mode 100644 index 9692c34e6f..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_testing/_time.py +++ /dev/null @@ -1,229 +0,0 @@ -# Copyright 2017 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. -"""Test times.""" - -import collections -import logging -import threading -import time as _time - -import grpc -import grpc_testing - -logging.basicConfig() -_LOGGER = logging.getLogger(__name__) - - -def _call(behaviors): - for behavior in behaviors: - try: - behavior() - except Exception: # pylint: disable=broad-except - _LOGGER.exception('Exception calling behavior "%r"!', behavior) - - -def _call_in_thread(behaviors): - calling = threading.Thread(target=_call, args=(behaviors,)) - calling.start() - # NOTE(nathaniel): Because this function is called from "strict" Time - # implementations, it blocks until after all behaviors have terminated. - calling.join() - - -class _State(object): - - def __init__(self): - self.condition = threading.Condition() - self.times_to_behaviors = collections.defaultdict(list) - - -class _Delta( - collections.namedtuple('_Delta', ( - 'mature_behaviors', - 'earliest_mature_time', - 'earliest_immature_time', - ))): - pass - - -def _process(state, now): - mature_behaviors = [] - earliest_mature_time = None - while state.times_to_behaviors: - earliest_time = min(state.times_to_behaviors) - if earliest_time <= now: - if earliest_mature_time is None: - earliest_mature_time = earliest_time - earliest_mature_behaviors = state.times_to_behaviors.pop( - earliest_time) - mature_behaviors.extend(earliest_mature_behaviors) - else: - earliest_immature_time = earliest_time - break - else: - earliest_immature_time = None - return _Delta(mature_behaviors, earliest_mature_time, - earliest_immature_time) - - -class _Future(grpc.Future): - - def __init__(self, state, behavior, time): - self._state = state - self._behavior = behavior - self._time = time - self._cancelled = False - - def cancel(self): - with self._state.condition: - if self._cancelled: - return True - else: - behaviors_at_time = self._state.times_to_behaviors.get( - self._time) - if behaviors_at_time is None: - return False - else: - behaviors_at_time.remove(self._behavior) - if not behaviors_at_time: - self._state.times_to_behaviors.pop(self._time) - self._state.condition.notify_all() - self._cancelled = True - return True - - def cancelled(self): - with self._state.condition: - return self._cancelled - - def running(self): - raise NotImplementedError() - - def done(self): - raise NotImplementedError() - - def result(self, timeout=None): - raise NotImplementedError() - - def exception(self, timeout=None): - raise NotImplementedError() - - def traceback(self, timeout=None): - raise NotImplementedError() - - def add_done_callback(self, fn): - raise NotImplementedError() - - -class StrictRealTime(grpc_testing.Time): - - def __init__(self): - self._state = _State() - self._active = False - self._calling = None - - def _activity(self): - while True: - with self._state.condition: - while True: - now = _time.time() - delta = _process(self._state, now) - self._state.condition.notify_all() - if delta.mature_behaviors: - self._calling = delta.earliest_mature_time - break - self._calling = None - if delta.earliest_immature_time is None: - self._active = False - return - else: - timeout = max(0, delta.earliest_immature_time - now) - self._state.condition.wait(timeout=timeout) - _call(delta.mature_behaviors) - - def _ensure_called_through(self, time): - with self._state.condition: - while ((self._state.times_to_behaviors and - min(self._state.times_to_behaviors) < time) or - (self._calling is not None and self._calling < time)): - self._state.condition.wait() - - def _call_at(self, behavior, time): - with self._state.condition: - self._state.times_to_behaviors[time].append(behavior) - if self._active: - self._state.condition.notify_all() - else: - activity = threading.Thread(target=self._activity) - activity.start() - self._active = True - return _Future(self._state, behavior, time) - - def time(self): - return _time.time() - - def call_in(self, behavior, delay): - return self._call_at(behavior, _time.time() + delay) - - def call_at(self, behavior, time): - return self._call_at(behavior, time) - - def sleep_for(self, duration): - time = _time.time() + duration - _time.sleep(duration) - self._ensure_called_through(time) - - def sleep_until(self, time): - _time.sleep(max(0, time - _time.time())) - self._ensure_called_through(time) - - -class StrictFakeTime(grpc_testing.Time): - - def __init__(self, time): - self._state = _State() - self._time = time - - def time(self): - return self._time - - def call_in(self, behavior, delay): - if delay <= 0: - _call_in_thread((behavior,)) - else: - with self._state.condition: - time = self._time + delay - self._state.times_to_behaviors[time].append(behavior) - return _Future(self._state, behavior, time) - - def call_at(self, behavior, time): - with self._state.condition: - if time <= self._time: - _call_in_thread((behavior,)) - else: - self._state.times_to_behaviors[time].append(behavior) - return _Future(self._state, behavior, time) - - def sleep_for(self, duration): - if 0 < duration: - with self._state.condition: - self._time += duration - delta = _process(self._state, self._time) - _call_in_thread(delta.mature_behaviors) - - def sleep_until(self, time): - with self._state.condition: - if self._time < time: - self._time = time - delta = _process(self._state, self._time) - _call_in_thread(delta.mature_behaviors) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_testing/grpc_version.py deleted file mode 100644 index 66abb8b188..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/grpc_version.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2017 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. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! - -VERSION = '1.43.2' diff --git a/contrib/libs/grpc/src/python/grpcio_testing/setup.py b/contrib/libs/grpc/src/python/grpcio_testing/setup.py deleted file mode 100644 index b976620484..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/setup.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2017 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. -"""Setup module for gRPC Python's testing package.""" - -import os -import sys - -import setuptools - -_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__)) -_README_PATH = os.path.join(_PACKAGE_PATH, 'README.rst') - -# Ensure we're in the proper directory whether or not we're being used by pip. -os.chdir(os.path.dirname(os.path.abspath(__file__))) - -# Break import style to ensure that we can find same-directory modules. -import grpc_version - - -class _NoOpCommand(setuptools.Command): - """No-op command.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - pass - - -PACKAGE_DIRECTORIES = { - '': '.', -} - -INSTALL_REQUIRES = ( - 'protobuf>=3.6.0', - 'grpcio>={version}'.format(version=grpc_version.VERSION), -) - -try: - import testing_commands as _testing_commands - - # we are in the build environment, otherwise the above import fails - COMMAND_CLASS = { - # Run preprocess from the repository *before* doing any packaging! - 'preprocess': _testing_commands.Preprocess, - } -except ImportError: - COMMAND_CLASS = { - # wire up commands to no-op not to break the external dependencies - 'preprocess': _NoOpCommand, - } - -setuptools.setup(name='grpcio-testing', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='Testing utilities for gRPC Python', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - install_requires=INSTALL_REQUIRES, - cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_testing/testing_commands.py b/contrib/libs/grpc/src/python/grpcio_testing/testing_commands.py deleted file mode 100644 index fb40d37efb..0000000000 --- a/contrib/libs/grpc/src/python/grpcio_testing/testing_commands.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 gRPC Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Provides distutils command classes for the GRPC Python setup process.""" - -import os -import shutil - -import setuptools - -ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) -LICENSE = os.path.join(ROOT_DIR, '../../../LICENSE') - - -class Preprocess(setuptools.Command): - """Command to copy LICENSE from root directory.""" - - description = '' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - if os.path.isfile(LICENSE): - shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, 'LICENSE')) diff --git a/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt deleted file mode 100644 index b31c8995b8..0000000000 --- a/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,72 +0,0 @@ -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -# 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. - - -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 the gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. diff --git a/contrib/libs/grpc/test/core/util/cmdline.cc b/contrib/libs/grpc/test/core/util/cmdline.cc deleted file mode 100644 index c031ef8b4c..0000000000 --- a/contrib/libs/grpc/test/core/util/cmdline.cc +++ /dev/null @@ -1,321 +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. - * - */ - -#include "test/core/util/cmdline.h" - -#include <limits.h> -#include <stdio.h> -#include <string.h> - -#include <vector> - -#include "y_absl/strings/str_cat.h" -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_join.h" - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> - -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/memory.h" - -typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype; - -typedef struct arg { - const char* name; - const char* help; - argtype type; - void* value; - struct arg* next; -} arg; - -struct gpr_cmdline { - const char* description; - arg* args; - const char* argv0; - - const char* extra_arg_name; - const char* extra_arg_help; - void (*extra_arg)(void* user_data, const char* arg); - void* extra_arg_user_data; - - int (*state)(gpr_cmdline* cl, char* arg); - arg* cur_arg; - - int survive_failure; -}; - -static int normal_state(gpr_cmdline* cl, char* str); - -gpr_cmdline* gpr_cmdline_create(const char* description) { - gpr_cmdline* cl = grpc_core::Zalloc<gpr_cmdline>(); - - cl->description = description; - cl->state = normal_state; - - return cl; -} - -void gpr_cmdline_set_survive_failure(gpr_cmdline* cl) { - cl->survive_failure = 1; -} - -void gpr_cmdline_destroy(gpr_cmdline* cl) { - while (cl->args) { - arg* a = cl->args; - cl->args = a->next; - gpr_free(a); - } - gpr_free(cl); -} - -static void add_arg(gpr_cmdline* cl, const char* name, const char* help, - argtype type, void* value) { - arg* a; - - for (a = cl->args; a; a = a->next) { - GPR_ASSERT(0 != strcmp(a->name, name)); - } - - a = static_cast<arg*>(gpr_zalloc(sizeof(arg))); - a->name = name; - a->help = help; - a->type = type; - a->value = value; - a->next = cl->args; - cl->args = a; -} - -void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, - int* value) { - add_arg(cl, name, help, ARGTYPE_INT, value); -} - -void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, - int* value) { - add_arg(cl, name, help, ARGTYPE_BOOL, value); -} - -void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, - const char** value) { - add_arg(cl, name, help, ARGTYPE_STRING, value); -} - -void gpr_cmdline_on_extra_arg( - gpr_cmdline* cl, const char* name, const char* help, - void (*on_extra_arg)(void* user_data, const char* arg), void* user_data) { - GPR_ASSERT(!cl->extra_arg); - GPR_ASSERT(on_extra_arg); - - cl->extra_arg = on_extra_arg; - cl->extra_arg_user_data = user_data; - cl->extra_arg_name = name; - cl->extra_arg_help = help; -} - -/* recursively descend argument list, adding the last element - to s first - so that arguments are added in the order they were - added to the list by api calls */ -static void add_args_to_usage(arg* a, std::vector<TString>* s) { - if (a == nullptr) return; - add_args_to_usage(a->next, s); - switch (a->type) { - case ARGTYPE_BOOL: - s->push_back(y_absl::StrFormat(" [--%s|--no-%s]", a->name, a->name)); - break; - case ARGTYPE_STRING: - s->push_back(y_absl::StrFormat(" [--%s=string]", a->name)); - break; - case ARGTYPE_INT: - s->push_back(y_absl::StrFormat(" [--%s=int]", a->name)); - break; - } -} - -TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) { - const char* name = strrchr(argv0, '/'); - if (name != nullptr) { - name++; - } else { - name = argv0; - } - - std::vector<TString> s; - s.push_back(y_absl::StrCat("Usage: ", name)); - add_args_to_usage(cl->args, &s); - if (cl->extra_arg) { - s.push_back(y_absl::StrFormat(" [%s...]", cl->extra_arg_name)); - } - s.push_back("\n"); - return y_absl::StrJoin(s, ""); -} - -static int print_usage_and_die(gpr_cmdline* cl) { - fprintf(stderr, "%s", gpr_cmdline_usage_string(cl, cl->argv0).c_str()); - if (!cl->survive_failure) { - exit(1); - } - return 0; -} - -static int extra_state(gpr_cmdline* cl, char* str) { - if (!cl->extra_arg) { - return print_usage_and_die(cl); - } - cl->extra_arg(cl->extra_arg_user_data, str); - return 1; -} - -static arg* find_arg(gpr_cmdline* cl, char* name) { - arg* a; - - for (a = cl->args; a; a = a->next) { - if (0 == strcmp(a->name, name)) { - break; - } - } - - if (!a) { - fprintf(stderr, "Unknown argument: %s\n", name); - return nullptr; - } - - return a; -} - -static int value_state(gpr_cmdline* cl, char* str) { - long intval; - char* end; - - GPR_ASSERT(cl->cur_arg); - - switch (cl->cur_arg->type) { - case ARGTYPE_INT: - intval = strtol(str, &end, 0); - if (*end || intval < INT_MIN || intval > INT_MAX) { - fprintf(stderr, "expected integer, got '%s' for %s\n", str, - cl->cur_arg->name); - return print_usage_and_die(cl); - } - *static_cast<int*>(cl->cur_arg->value) = static_cast<int>(intval); - break; - case ARGTYPE_BOOL: - if (0 == strcmp(str, "1") || 0 == strcmp(str, "true")) { - *static_cast<int*>(cl->cur_arg->value) = 1; - } else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) { - *static_cast<int*>(cl->cur_arg->value) = 0; - } else { - fprintf(stderr, "expected boolean, got '%s' for %s\n", str, - cl->cur_arg->name); - return print_usage_and_die(cl); - } - break; - case ARGTYPE_STRING: - *static_cast<char**>(cl->cur_arg->value) = str; - break; - } - - cl->state = normal_state; - return 1; -} - -static int normal_state(gpr_cmdline* cl, char* str) { - char* eq = nullptr; - char* tmp = nullptr; - char* arg_name = nullptr; - int r = 1; - - if (0 == strcmp(str, "-help") || 0 == strcmp(str, "--help") || - 0 == strcmp(str, "-h")) { - return print_usage_and_die(cl); - } - - cl->cur_arg = nullptr; - - if (str[0] == '-') { - if (str[1] == '-') { - if (str[2] == 0) { - /* handle '--' to move to just extra args */ - cl->state = extra_state; - return 1; - } - str += 2; - } else { - str += 1; - } - /* first byte of str is now past the leading '-' or '--' */ - if (str[0] == 'n' && str[1] == 'o' && str[2] == '-') { - /* str is of the form '--no-foo' - it's a flag disable */ - str += 3; - cl->cur_arg = find_arg(cl, str); - if (cl->cur_arg == nullptr) { - return print_usage_and_die(cl); - } - if (cl->cur_arg->type != ARGTYPE_BOOL) { - fprintf(stderr, "%s is not a flag argument\n", str); - return print_usage_and_die(cl); - } - *static_cast<int*>(cl->cur_arg->value) = 0; - return 1; /* early out */ - } - eq = strchr(str, '='); - if (eq != nullptr) { - /* copy the string into a temp buffer and extract the name */ - tmp = arg_name = - static_cast<char*>(gpr_malloc(static_cast<size_t>(eq - str + 1))); - memcpy(arg_name, str, static_cast<size_t>(eq - str)); - arg_name[eq - str] = 0; - } else { - arg_name = str; - } - cl->cur_arg = find_arg(cl, arg_name); - if (cl->cur_arg == nullptr) { - return print_usage_and_die(cl); - } - if (eq != nullptr) { - /* str was of the type --foo=value, parse the value */ - r = value_state(cl, eq + 1); - } else if (cl->cur_arg->type != ARGTYPE_BOOL) { - /* flag types don't have a '--foo value' variant, other types do */ - cl->state = value_state; - } else { - /* flag parameter: just set the value */ - *static_cast<int*>(cl->cur_arg->value) = 1; - } - } else { - r = extra_state(cl, str); - } - - gpr_free(tmp); - return r; -} - -int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv) { - int i; - - GPR_ASSERT(argc >= 1); - cl->argv0 = argv[0]; - - for (i = 1; i < argc; i++) { - if (!cl->state(cl, argv[i])) { - return 0; - } - } - return 1; -} diff --git a/contrib/libs/grpc/test/core/util/cmdline.h b/contrib/libs/grpc/test/core/util/cmdline.h deleted file mode 100644 index cc75a8974e..0000000000 --- a/contrib/libs/grpc/test/core/util/cmdline.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_CMDLINE_H -#define GRPC_TEST_CORE_UTIL_CMDLINE_H - -#include <grpc/support/port_platform.h> - -#include <util/generic/string.h> - -/** Simple command line parser. - - Supports flags that can be specified as -foo, --foo, --no-foo, -no-foo, etc - And integers, strings that can be specified as -foo=4, -foo blah, etc - - No support for short command line options (but we may get that in the - future.) - - Usage (for a program with a single flag argument 'foo'): - - int main(int argc, char **argv) { - gpr_cmdline *cl; - int verbose = 0; - - cl = gpr_cmdline_create("My cool tool"); - gpr_cmdline_add_int(cl, "verbose", "Produce verbose output?", &verbose); - gpr_cmdline_parse(cl, argc, argv); - gpr_cmdline_destroy(cl); - - if (verbose) { - gpr_log(GPR_INFO, "Goodbye cruel world!"); - } - - return 0; - } */ - -typedef struct gpr_cmdline gpr_cmdline; - -/** Construct a command line parser: takes a short description of the tool - doing the parsing */ -gpr_cmdline* gpr_cmdline_create(const char* description); -/** Add an integer parameter, with a name (used on the command line) and some - helpful text (used in the command usage) */ -void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, - int* value); -/** The same, for a boolean flag */ -void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, - int* value); -/** And for a string */ -void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, - const char** value); -/** Set a callback for non-named arguments */ -void gpr_cmdline_on_extra_arg( - gpr_cmdline* cl, const char* name, const char* help, - void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); -/** Enable surviving failure: default behavior is to exit the process */ -void gpr_cmdline_set_survive_failure(gpr_cmdline* cl); -/** Parse the command line; returns 1 on success, on failure either dies - (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been - called */ -int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv); -/** Destroy the parser */ -void gpr_cmdline_destroy(gpr_cmdline* cl); -/** Get a string describing usage */ -TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0); - -#endif /* GRPC_TEST_CORE_UTIL_CMDLINE_H */ diff --git a/contrib/libs/grpc/test/core/util/cmdline_test.cc b/contrib/libs/grpc/test/core/util/cmdline_test.cc deleted file mode 100644 index 32f9a156a1..0000000000 --- a/contrib/libs/grpc/test/core/util/cmdline_test.cc +++ /dev/null @@ -1,494 +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. - * - */ - -#include "test/core/util/cmdline.h" - -#include <string.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/gpr/useful.h" -#include "test/core/util/test_config.h" - -#define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__) - -static void test_simple_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("-foo"), - const_cast<char*>("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_eq_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("-foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo"), - const_cast<char*>("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_eq_int(void) { - int x = 1; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_int(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 1); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 3); - gpr_cmdline_destroy(cl); -} - -static void test_simple_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("-foo"), - const_cast<char*>("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_eq_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("-foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo"), - const_cast<char*>("3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_2dash_eq_string(void) { - const char* x = nullptr; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo=3")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "foo", nullptr, &x); - GPR_ASSERT(x == nullptr); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(0 == strcmp(x, "3")); - gpr_cmdline_destroy(cl); -} - -static void test_flag_on(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_no(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--no-foo")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_1(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo=1")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_0(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo=0")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_true(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--foo=true")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 1); - gpr_cmdline_destroy(cl); -} - -static void test_flag_val_false(void) { - int x = 2; - gpr_cmdline* cl; - char* args[] = {const_cast<char*>(__FILE__), - const_cast<char*>("--foo=false")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_flag(cl, "foo", nullptr, &x); - GPR_ASSERT(x == 2); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 0); - gpr_cmdline_destroy(cl); -} - -static void test_many(void) { - const char* str = nullptr; - int x = 0; - int flag = 2; - gpr_cmdline* cl; - - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--str"), - const_cast<char*>("hello"), const_cast<char*>("-x=4"), - const_cast<char*>("-no-flag")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(x == 4); - GPR_ASSERT(0 == strcmp(str, "hello")); - GPR_ASSERT(flag == 0); - gpr_cmdline_destroy(cl); -} - -static void extra_arg_cb(void* user_data, const char* arg) { - int* count = static_cast<int*>(user_data); - GPR_ASSERT(arg != nullptr); - GPR_ASSERT(strlen(arg) == 1); - GPR_ASSERT(arg[0] == 'a' + *count); - ++*count; -} - -static void test_extra(void) { - gpr_cmdline* cl; - int count = 0; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("a"), - const_cast<char*>("b"), const_cast<char*>("c")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - &count); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(count == 3); - gpr_cmdline_destroy(cl); -} - -static void test_extra_dashdash(void) { - gpr_cmdline* cl; - int count = 0; - char* args[] = {const_cast<char*>(__FILE__), const_cast<char*>("--"), - const_cast<char*>("a"), const_cast<char*>("b"), - const_cast<char*>("c")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - &count); - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(args), args); - GPR_ASSERT(count == 3); - gpr_cmdline_destroy(cl); -} - -static void test_usage(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - TString usage = gpr_cmdline_usage_string(cl, "test"); - GPR_ASSERT(usage == - "Usage: test [--str=string] [--x=int] " - "[--flag|--no-flag] [file...]\n"); - - usage = gpr_cmdline_usage_string(cl, "/foo/test"); - GPR_ASSERT(usage == - "Usage: test [--str=string] [--x=int] " - "[--flag|--no-flag] [file...]\n"); - - gpr_cmdline_destroy(cl); -} - -static void test_help(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* help[] = {const_cast<char*>(__FILE__), const_cast<char*>("-h")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(help), help)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs1(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_arg_name[] = {const_cast<char*>(__FILE__), - const_cast<char*>("--y")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == - gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_arg_name), bad_arg_name)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs2(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_int_value[] = {const_cast<char*>(__FILE__), - const_cast<char*>("--x"), - const_cast<char*>("henry")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT( - 0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_int_value), bad_int_value)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs3(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_bool_value[] = {const_cast<char*>(__FILE__), - const_cast<char*>("--flag=henry")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), - bad_bool_value)); - - gpr_cmdline_destroy(cl); -} - -static void test_badargs4(void) { - gpr_cmdline* cl; - - const char* str = nullptr; - int x = 0; - int flag = 2; - - char* bad_bool_value[] = {const_cast<char*>(__FILE__), - const_cast<char*>("--no-str")}; - - LOG_TEST(); - - cl = gpr_cmdline_create(nullptr); - gpr_cmdline_set_survive_failure(cl); - gpr_cmdline_add_string(cl, "str", nullptr, &str); - gpr_cmdline_add_int(cl, "x", nullptr, &x); - gpr_cmdline_add_flag(cl, "flag", nullptr, &flag); - gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb, - nullptr); - - GPR_ASSERT(0 == gpr_cmdline_parse(cl, GPR_ARRAY_SIZE(bad_bool_value), - bad_bool_value)); - - gpr_cmdline_destroy(cl); -} - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - test_simple_int(); - test_eq_int(); - test_2dash_int(); - test_2dash_eq_int(); - test_simple_string(); - test_eq_string(); - test_2dash_string(); - test_2dash_eq_string(); - test_flag_on(); - test_flag_no(); - test_flag_val_1(); - test_flag_val_0(); - test_flag_val_true(); - test_flag_val_false(); - test_many(); - test_extra(); - test_extra_dashdash(); - test_usage(); - test_help(); - test_badargs1(); - test_badargs2(); - test_badargs3(); - test_badargs4(); - return 0; -} diff --git a/contrib/libs/grpc/test/core/util/evaluate_args_test_util.h b/contrib/libs/grpc/test/core/util/evaluate_args_test_util.h deleted file mode 100644 index 37541c89f4..0000000000 --- a/contrib/libs/grpc/test/core/util/evaluate_args_test_util.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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. - -#ifndef GRPC_TEST_CORE_UTIL_EVALUATE_ARGS_TEST_UTIL_H -#define GRPC_TEST_CORE_UTIL_EVALUATE_ARGS_TEST_UTIL_H - -#include <grpc/support/port_platform.h> - -#include <list> - -#include <gtest/gtest.h> - -#include "src/core/lib/security/authorization/evaluate_args.h" -#include "test/core/util/mock_authorization_endpoint.h" - -namespace grpc_core { - -class EvaluateArgsTestUtil { - public: - EvaluateArgsTestUtil() = default; - - ~EvaluateArgsTestUtil() { delete channel_args_; } - - void AddPairToMetadata(const char* key, const char* value) { - metadata_.Append( - key, Slice(grpc_slice_intern(grpc_slice_from_static_string(value)))); - } - - void SetLocalEndpoint(y_absl::string_view local_uri) { - endpoint_.SetLocalAddress(local_uri); - } - - void SetPeerEndpoint(y_absl::string_view peer_uri) { - endpoint_.SetPeer(peer_uri); - } - - void AddPropertyToAuthContext(const char* name, const char* value) { - auth_context_.add_cstring_property(name, value); - } - - EvaluateArgs MakeEvaluateArgs() { - channel_args_ = - new EvaluateArgs::PerChannelArgs(&auth_context_, &endpoint_); - return EvaluateArgs(&metadata_, channel_args_); - } - - private: - ScopedArenaPtr arena_ = MakeScopedArena(1024); - grpc_metadata_batch metadata_{arena_.get()}; - MockAuthorizationEndpoint endpoint_{/*local_uri=*/"", /*peer_uri=*/""}; - grpc_auth_context auth_context_{nullptr}; - EvaluateArgs::PerChannelArgs* channel_args_ = nullptr; -}; - -} // namespace grpc_core - -#endif // GRPC_TEST_CORE_UTIL_EVALUATE_ARGS_TEST_UTIL_H diff --git a/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc b/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc deleted file mode 100644 index 8037e68aca..0000000000 --- a/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <dirent.h> -#include <stdbool.h> -#include <stdio.h> -#include <sys/types.h> - -#include <gtest/gtest.h> - -#include "y_absl/flags/flag.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/load_file.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/test_config.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); -extern bool squelch; -extern bool leak_check; - -Y_ABSL_FLAG(TString, file, "", "Use this file as test data"); -Y_ABSL_FLAG(TString, directory, "", "Use this directory as test data"); - -class FuzzerCorpusTest : public ::testing::TestWithParam<TString> {}; - -TEST_P(FuzzerCorpusTest, RunOneExample) { - // Need to call grpc_init() here to use a slice, but need to shut it - // down before calling LLVMFuzzerTestOneInput(), because most - // implementations of that function will initialize and shutdown gRPC - // internally. - grpc_init(); - gpr_log(GPR_INFO, "Example file: %s", GetParam().c_str()); - grpc_slice buffer; - squelch = false; - leak_check = false; - GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(GetParam().c_str(), 0, &buffer))); - size_t length = GRPC_SLICE_LENGTH(buffer); - void* data = gpr_malloc(length); - memcpy(data, GPR_SLICE_START_PTR(buffer), length); - grpc_slice_unref(buffer); - grpc_shutdown(); - LLVMFuzzerTestOneInput(static_cast<uint8_t*>(data), length); - gpr_free(data); -} - -class ExampleGenerator - : public ::testing::internal::ParamGeneratorInterface<TString> { - public: - ::testing::internal::ParamIteratorInterface<TString>* Begin() - const override; - ::testing::internal::ParamIteratorInterface<TString>* End() - const override; - - private: - void Materialize() const { - if (examples_.empty()) { - if (!y_absl::GetFlag(FLAGS_file).empty()) { - examples_.push_back(y_absl::GetFlag(FLAGS_file)); - } - if (!y_absl::GetFlag(FLAGS_directory).empty()) { - char* test_srcdir = gpr_getenv("TEST_SRCDIR"); - gpr_log(GPR_DEBUG, "test_srcdir=\"%s\"", test_srcdir); - TString directory = y_absl::GetFlag(FLAGS_directory); - if (test_srcdir != nullptr) { - directory = - test_srcdir + TString("/com_github_grpc_grpc/") + directory; - } - gpr_log(GPR_DEBUG, "Using corpus directory: %s", directory.c_str()); - DIR* dp; - struct dirent* ep; - dp = opendir(directory.c_str()); - - if (dp != nullptr) { - while ((ep = readdir(dp)) != nullptr) { - if (strcmp(ep->d_name, ".") != 0 && strcmp(ep->d_name, "..") != 0) { - examples_.push_back(directory + "/" + ep->d_name); - } - } - - (void)closedir(dp); - } else { - perror("Couldn't open the directory"); - abort(); - } - gpr_free(test_srcdir); - } - } - // Make sure we don't succeed without doing anything, which caused - // us to be blind to our fuzzers not running for 9 months. - GPR_ASSERT(!examples_.empty()); - } - - mutable std::vector<TString> examples_; -}; - -class ExampleIterator - : public ::testing::internal::ParamIteratorInterface<TString> { - public: - ExampleIterator(const ExampleGenerator& base_, - std::vector<TString>::const_iterator begin) - : base_(base_), begin_(begin), current_(begin) {} - - const ExampleGenerator* BaseGenerator() const override { return &base_; } - - void Advance() override { current_++; } - ExampleIterator* Clone() const override { return new ExampleIterator(*this); } - const TString* Current() const override { return &*current_; } - - bool Equals(const ParamIteratorInterface<TString>& other) const override { - return &base_ == other.BaseGenerator() && - current_ == dynamic_cast<const ExampleIterator*>(&other)->current_; - } - - private: - ExampleIterator(const ExampleIterator& other) - : base_(other.base_), begin_(other.begin_), current_(other.current_) {} - - const ExampleGenerator& base_; - const std::vector<TString>::const_iterator begin_; - std::vector<TString>::const_iterator current_; -}; - -::testing::internal::ParamIteratorInterface<TString>* -ExampleGenerator::Begin() const { - Materialize(); - return new ExampleIterator(*this, examples_.begin()); -} - -::testing::internal::ParamIteratorInterface<TString>* -ExampleGenerator::End() const { - Materialize(); - return new ExampleIterator(*this, examples_.end()); -} - -INSTANTIATE_TEST_SUITE_P( - CorpusExamples, FuzzerCorpusTest, - ::testing::internal::ParamGenerator<TString>(new ExampleGenerator)); - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - grpc::testing::InitTest(&argc, &argv, true); - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/core/util/fuzzer_one_entry_runner.sh b/contrib/libs/grpc/test/core/util/fuzzer_one_entry_runner.sh deleted file mode 100755 index 7c471afcc2..0000000000 --- a/contrib/libs/grpc/test/core/util/fuzzer_one_entry_runner.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Test runner for fuzzer tests from bazel - -# Copyright 2017 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. -"$1" "$2" diff --git a/contrib/libs/grpc/test/core/util/fuzzer_util.cc b/contrib/libs/grpc/test/core/util/fuzzer_util.cc deleted file mode 100644 index ffd8832a51..0000000000 --- a/contrib/libs/grpc/test/core/util/fuzzer_util.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/core/util/fuzzer_util.h" - -#include <algorithm> - -#include <grpc/support/alloc.h> - -#include "src/core/lib/gpr/useful.h" - -namespace grpc_core { -namespace testing { - -uint8_t grpc_fuzzer_get_next_byte(input_stream* inp) { - if (inp->cur == inp->end) { - return 0; - } - return *inp->cur++; -} - -char* grpc_fuzzer_get_next_string(input_stream* inp, bool* special) { - char* str = nullptr; - size_t cap = 0; - size_t sz = 0; - char c; - do { - if (cap == sz) { - cap = std::max(3 * cap / 2, cap + 8); - str = static_cast<char*>(gpr_realloc(str, cap)); - } - c = static_cast<char>(grpc_fuzzer_get_next_byte(inp)); - str[sz++] = c; - } while (c != 0 && c != 1); - if (special != nullptr) { - *special = (c == 1); - } - if (c == 1) { - str[sz - 1] = 0; - } - return str; -} - -uint32_t grpc_fuzzer_get_next_uint32(input_stream* inp) { - uint8_t b = grpc_fuzzer_get_next_byte(inp); - uint32_t x = b & 0x7f; - if (b & 0x80) { - x <<= 7; - b = grpc_fuzzer_get_next_byte(inp); - x |= b & 0x7f; - if (b & 0x80) { - x <<= 7; - b = grpc_fuzzer_get_next_byte(inp); - x |= b & 0x7f; - if (b & 0x80) { - x <<= 7; - b = grpc_fuzzer_get_next_byte(inp); - x |= b & 0x7f; - if (b & 0x80) { - x = (x << 4) | (grpc_fuzzer_get_next_byte(inp) & 0x0f); - } - } - } - } - return x; -} - -} // namespace testing -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/fuzzer_util.h b/contrib/libs/grpc/test/core/util/fuzzer_util.h deleted file mode 100644 index 0e938399a1..0000000000 --- a/contrib/libs/grpc/test/core/util/fuzzer_util.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_FUZZER_UTIL_H -#define GRPC_TEST_CORE_UTIL_FUZZER_UTIL_H - -#include <stdint.h> - -namespace grpc_core { - -namespace testing { - -// Main struct for input_stream. It allows easy access to input -// bytes, and allows reading a little past the end(avoiding -// needing to check everywhere). -typedef struct { - const uint8_t* cur; - const uint8_t* end; -} input_stream; - -// get a byte from an input stream. -uint8_t grpc_fuzzer_get_next_byte(input_stream* inp); - -// get a string and boolean values (if special is not null) from an input -// stream. -char* grpc_fuzzer_get_next_string(input_stream* inp, bool* special); - -// get a uint32 value from an input stream. -uint32_t grpc_fuzzer_get_next_uint32(input_stream* inp); - -} // namespace testing -} // namespace grpc_core - -#endif /* GRPC_TEST_CORE_UTIL_FUZZER_UTIL_H */ diff --git a/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl b/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl deleted file mode 100644 index 8ae71b61f3..0000000000 --- a/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2016 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. - -""" -Includes fuzzer rules. -""" - -load("//bazel:grpc_build_system.bzl", "grpc_cc_test") -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_cc//cc:defs.bzl", "cc_proto_library") - -def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", **kwargs): - """Instantiates a fuzzer test. - - Args: - name: The name of the test. - corpus: The corpus for the test. - srcs: The source files for the test. - deps: The dependencies of the test. - data: The data dependencies of the test. - size: The size of the test. - **kwargs: Other arguments to supply to the test. - """ - CORPUS_DIR = native.package_name() + "/" + corpus - grpc_cc_test( - name = name, - srcs = srcs, - deps = deps + select({ - "//:grpc_build_fuzzers": [], - "//conditions:default": ["//test/core/util:fuzzer_corpus_test"], - }), - data = data + native.glob([corpus + "/**"]), - external_deps = [ - "gtest", - ], - size = size, - args = select({ - "//:grpc_build_fuzzers": [CORPUS_DIR], - "//conditions:default": ["--directory=" + CORPUS_DIR], - }), - **kwargs - ) - -def grpc_proto_fuzzer(name, corpus, proto, srcs = [], deps = [], data = [], size = "large", **kwargs): - """Instantiates a protobuf mutator fuzzer test. - - Args: - name: The name of the test. - corpus: The corpus for the test. - proto: The proto for the test. - srcs: The source files for the test. - deps: The dependencies of the test. - data: The data dependencies of the test. - size: The size of the test. - **kwargs: Other arguments to supply to the test. - """ - PROTO_LIBRARY = "_%s_proto" % name - CC_PROTO_LIBRARY = "_%s_cc_proto" % name - CORPUS_DIR = native.package_name() + "/" + corpus - - proto_library( - name = PROTO_LIBRARY, - srcs = [proto], - ) - - cc_proto_library( - name = CC_PROTO_LIBRARY, - deps = [PROTO_LIBRARY], - ) - - grpc_cc_test( - name = name, - srcs = srcs, - deps = deps + [ - "@com_google_libprotobuf_mutator//:libprotobuf_mutator", - CC_PROTO_LIBRARY, - ] + select({ - "//:grpc_build_fuzzers": [], - "//conditions:default": ["//test/core/util:fuzzer_corpus_test"], - }), - data = data + native.glob([corpus + "/**"]), - external_deps = [ - "gtest", - ], - size = size, - args = select({ - "//:grpc_build_fuzzers": [CORPUS_DIR], - "//conditions:default": ["--directory=" + CORPUS_DIR], - }), - **kwargs - ) diff --git a/contrib/libs/grpc/test/core/util/grpc_profiler.cc b/contrib/libs/grpc/test/core/util/grpc_profiler.cc deleted file mode 100644 index 88f233598b..0000000000 --- a/contrib/libs/grpc/test/core/util/grpc_profiler.cc +++ /dev/null @@ -1,45 +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. - * - */ - -#include "test/core/util/grpc_profiler.h" - -#if GRPC_HAVE_PERFTOOLS -#include <gperftools/profiler.h> - -void grpc_profiler_start(const char* filename) { ProfilerStart(filename); } - -void grpc_profiler_stop() { ProfilerStop(); } -#else -#include <grpc/support/log.h> - -void grpc_profiler_start(const char* filename) { - static int printed_warning = 0; - if (!printed_warning) { - gpr_log(GPR_DEBUG, - "You do not have google-perftools installed, profiling is disabled " - "[for %s]", - filename); - gpr_log(GPR_DEBUG, - "To install on ubuntu: sudo apt-get install google-perftools " - "libgoogle-perftools-dev"); - printed_warning = 1; - } -} - -void grpc_profiler_stop(void) {} -#endif diff --git a/contrib/libs/grpc/test/core/util/grpc_profiler.h b/contrib/libs/grpc/test/core/util/grpc_profiler.h deleted file mode 100644 index f9ddd2242e..0000000000 --- a/contrib/libs/grpc/test/core/util/grpc_profiler.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H -#define GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H - -void grpc_profiler_start(const char* filename); -void grpc_profiler_stop(); - -#endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */ diff --git a/contrib/libs/grpc/test/core/util/histogram.cc b/contrib/libs/grpc/test/core/util/histogram.cc deleted file mode 100644 index fc3e21c5b4..0000000000 --- a/contrib/libs/grpc/test/core/util/histogram.cc +++ /dev/null @@ -1,233 +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. - * - */ - -#include <grpc/support/port_platform.h> - -#include "test/core/util/histogram.h" - -#include <math.h> -#include <stddef.h> -#include <string.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/gpr/useful.h" - -/* Histograms are stored with exponentially increasing bucket sizes. - The first bucket is [0, m) where m = 1 + resolution - Bucket n (n>=1) contains [m**n, m**(n+1)) - There are sufficient buckets to reach max_bucket_start */ - -struct grpc_histogram { - /* Sum of all values seen so far */ - double sum; - /* Sum of squares of all values seen so far */ - double sum_of_squares; - /* number of values seen so far */ - double count; - /* m in the description */ - double multiplier; - double one_on_log_multiplier; - /* minimum value seen */ - double min_seen; - /* maximum value seen */ - double max_seen; - /* maximum representable value */ - double max_possible; - /* number of buckets */ - size_t num_buckets; - /* the buckets themselves */ - uint32_t* buckets; -}; - -/* determine a bucket index given a value - does no bounds checking */ -static size_t bucket_for_unchecked(grpc_histogram* h, double x) { - return static_cast<size_t>(log(x) * h->one_on_log_multiplier); -} - -/* bounds checked version of the above */ -static size_t bucket_for(grpc_histogram* h, double x) { - size_t bucket = - bucket_for_unchecked(h, grpc_core::Clamp(x, 1.0, h->max_possible)); - GPR_ASSERT(bucket < h->num_buckets); - return bucket; -} - -/* at what value does a bucket start? */ -static double bucket_start(grpc_histogram* h, double x) { - return pow(h->multiplier, x); -} - -grpc_histogram* grpc_histogram_create(double resolution, - double max_bucket_start) { - grpc_histogram* h = - static_cast<grpc_histogram*>(gpr_malloc(sizeof(grpc_histogram))); - GPR_ASSERT(resolution > 0.0); - GPR_ASSERT(max_bucket_start > resolution); - h->sum = 0.0; - h->sum_of_squares = 0.0; - h->multiplier = 1.0 + resolution; - h->one_on_log_multiplier = 1.0 / log(1.0 + resolution); - h->max_possible = max_bucket_start; - h->count = 0.0; - h->min_seen = max_bucket_start; - h->max_seen = 0.0; - h->num_buckets = bucket_for_unchecked(h, max_bucket_start) + 1; - GPR_ASSERT(h->num_buckets > 1); - GPR_ASSERT(h->num_buckets < 100000000); - h->buckets = - static_cast<uint32_t*>(gpr_zalloc(sizeof(uint32_t) * h->num_buckets)); - return h; -} - -void grpc_histogram_destroy(grpc_histogram* h) { - gpr_free(h->buckets); - gpr_free(h); -} - -void grpc_histogram_add(grpc_histogram* h, double x) { - h->sum += x; - h->sum_of_squares += x * x; - h->count++; - if (x < h->min_seen) { - h->min_seen = x; - } - if (x > h->max_seen) { - h->max_seen = x; - } - h->buckets[bucket_for(h, x)]++; -} - -int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src) { - if ((dst->num_buckets != src->num_buckets) || - (dst->multiplier != src->multiplier)) { - /* Fail because these histograms don't match */ - return 0; - } - grpc_histogram_merge_contents(dst, src->buckets, src->num_buckets, - src->min_seen, src->max_seen, src->sum, - src->sum_of_squares, src->count); - return 1; -} - -void grpc_histogram_merge_contents(grpc_histogram* histogram, - const uint32_t* data, size_t data_count, - double min_seen, double max_seen, double sum, - double sum_of_squares, double count) { - size_t i; - GPR_ASSERT(histogram->num_buckets == data_count); - histogram->sum += sum; - histogram->sum_of_squares += sum_of_squares; - histogram->count += count; - if (min_seen < histogram->min_seen) { - histogram->min_seen = min_seen; - } - if (max_seen > histogram->max_seen) { - histogram->max_seen = max_seen; - } - for (i = 0; i < histogram->num_buckets; i++) { - histogram->buckets[i] += data[i]; - } -} - -static double threshold_for_count_below(grpc_histogram* h, double count_below) { - double count_so_far; - double lower_bound; - double upper_bound; - size_t lower_idx; - size_t upper_idx; - - if (h->count == 0) { - return 0.0; - } - - if (count_below <= 0) { - return h->min_seen; - } - if (count_below >= h->count) { - return h->max_seen; - } - - /* find the lowest bucket that gets us above count_below */ - count_so_far = 0.0; - for (lower_idx = 0; lower_idx < h->num_buckets; lower_idx++) { - count_so_far += h->buckets[lower_idx]; - if (count_so_far >= count_below) { - break; - } - } - if (count_so_far == count_below) { - /* this bucket hits the threshold exactly... we should be midway through - any run of zero values following the bucket */ - for (upper_idx = lower_idx + 1; upper_idx < h->num_buckets; upper_idx++) { - if (h->buckets[upper_idx]) { - break; - } - } - return (bucket_start(h, static_cast<double>(lower_idx)) + - bucket_start(h, static_cast<double>(upper_idx))) / - 2.0; - } else { - /* treat values as uniform throughout the bucket, and find where this value - should lie */ - lower_bound = bucket_start(h, static_cast<double>(lower_idx)); - upper_bound = bucket_start(h, static_cast<double>(lower_idx + 1)); - return grpc_core::Clamp(upper_bound - (upper_bound - lower_bound) * - (count_so_far - count_below) / - h->buckets[lower_idx], - h->min_seen, h->max_seen); - } -} - -double grpc_histogram_percentile(grpc_histogram* h, double percentile) { - return threshold_for_count_below(h, h->count * percentile / 100.0); -} - -double grpc_histogram_mean(grpc_histogram* h) { - GPR_ASSERT(h->count != 0); - return h->sum / h->count; -} - -double grpc_histogram_stddev(grpc_histogram* h) { - return sqrt(grpc_histogram_variance(h)); -} - -double grpc_histogram_variance(grpc_histogram* h) { - if (h->count == 0) return 0.0; - return (h->sum_of_squares * h->count - h->sum * h->sum) / - (h->count * h->count); -} - -double grpc_histogram_maximum(grpc_histogram* h) { return h->max_seen; } - -double grpc_histogram_minimum(grpc_histogram* h) { return h->min_seen; } - -double grpc_histogram_count(grpc_histogram* h) { return h->count; } - -double grpc_histogram_sum(grpc_histogram* h) { return h->sum; } - -double grpc_histogram_sum_of_squares(grpc_histogram* h) { - return h->sum_of_squares; -} - -const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram, - size_t* count) { - *count = histogram->num_buckets; - return histogram->buckets; -} diff --git a/contrib/libs/grpc/test/core/util/histogram.h b/contrib/libs/grpc/test/core/util/histogram.h deleted file mode 100644 index 9e872869bf..0000000000 --- a/contrib/libs/grpc/test/core/util/histogram.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_HISTOGRAM_H -#define GRPC_SUPPORT_HISTOGRAM_H - -#include <grpc/support/port_platform.h> - -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct grpc_histogram grpc_histogram; - -grpc_histogram* grpc_histogram_create(double resolution, - double max_bucket_start); -void grpc_histogram_destroy(grpc_histogram* h); -void grpc_histogram_add(grpc_histogram* h, double x); - -/** The following merges the second histogram into the first. It only works - if they have the same buckets and resolution. Returns 0 on failure, 1 - on success */ -int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src); - -double grpc_histogram_percentile(grpc_histogram* histogram, double percentile); -double grpc_histogram_mean(grpc_histogram* histogram); -double grpc_histogram_stddev(grpc_histogram* histogram); -double grpc_histogram_variance(grpc_histogram* histogram); -double grpc_histogram_maximum(grpc_histogram* histogram); -double grpc_histogram_minimum(grpc_histogram* histogram); -double grpc_histogram_count(grpc_histogram* histogram); -double grpc_histogram_sum(grpc_histogram* histogram); -double grpc_histogram_sum_of_squares(grpc_histogram* histogram); - -const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram, - size_t* count); -void grpc_histogram_merge_contents(grpc_histogram* histogram, - const uint32_t* data, size_t data_count, - double min_seen, double max_seen, double sum, - double sum_of_squares, double count); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_HISTOGRAM_H */ diff --git a/contrib/libs/grpc/test/core/util/histogram_test.cc b/contrib/libs/grpc/test/core/util/histogram_test.cc deleted file mode 100644 index 3ff92a31e1..0000000000 --- a/contrib/libs/grpc/test/core/util/histogram_test.cc +++ /dev/null @@ -1,164 +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. - * - */ - -#include "test/core/util/histogram.h" - -#include <grpc/support/log.h> - -#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x); - -static void test_no_op(void) { - grpc_histogram_destroy(grpc_histogram_create(0.01, 60e9)); -} - -static void expect_percentile(grpc_histogram* h, double percentile, - double min_expect, double max_expect) { - double got = grpc_histogram_percentile(h, percentile); - gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got, - max_expect); - GPR_ASSERT(min_expect <= got); - GPR_ASSERT(got <= max_expect); -} - -static void test_simple(void) { - grpc_histogram* h; - - LOG_TEST("test_simple"); - - h = grpc_histogram_create(0.01, 60e9); - grpc_histogram_add(h, 10000); - grpc_histogram_add(h, 10000); - grpc_histogram_add(h, 11000); - grpc_histogram_add(h, 11000); - - expect_percentile(h, 50, 10001, 10999); - GPR_ASSERT(grpc_histogram_mean(h) == 10500); - - grpc_histogram_destroy(h); -} - -static void test_percentile(void) { - grpc_histogram* h; - double last; - double i; - double cur; - - LOG_TEST("test_percentile"); - - h = grpc_histogram_create(0.05, 1e9); - grpc_histogram_add(h, 2.5); - grpc_histogram_add(h, 2.5); - grpc_histogram_add(h, 8); - grpc_histogram_add(h, 4); - - GPR_ASSERT(grpc_histogram_count(h) == 4); - GPR_ASSERT(grpc_histogram_minimum(h) == 2.5); - GPR_ASSERT(grpc_histogram_maximum(h) == 8); - GPR_ASSERT(grpc_histogram_sum(h) == 17); - GPR_ASSERT(grpc_histogram_sum_of_squares(h) == 92.5); - GPR_ASSERT(grpc_histogram_mean(h) == 4.25); - GPR_ASSERT(grpc_histogram_variance(h) == 5.0625); - GPR_ASSERT(grpc_histogram_stddev(h) == 2.25); - - expect_percentile(h, -10, 2.5, 2.5); - expect_percentile(h, 0, 2.5, 2.5); - expect_percentile(h, 12.5, 2.5, 2.5); - expect_percentile(h, 25, 2.5, 2.5); - expect_percentile(h, 37.5, 2.5, 2.8); - expect_percentile(h, 50, 3.0, 3.5); - expect_percentile(h, 62.5, 3.5, 4.5); - expect_percentile(h, 75, 5, 7.9); - expect_percentile(h, 100, 8, 8); - expect_percentile(h, 110, 8, 8); - - /* test monotonicity */ - last = 0.0; - for (i = 0; i < 100.0; i += 0.01) { - cur = grpc_histogram_percentile(h, i); - GPR_ASSERT(cur >= last); - last = cur; - } - - grpc_histogram_destroy(h); -} - -static void test_merge(void) { - grpc_histogram *h1, *h2; - double last; - double i; - double cur; - - LOG_TEST("test_merge"); - - h1 = grpc_histogram_create(0.05, 1e9); - grpc_histogram_add(h1, 2.5); - grpc_histogram_add(h1, 2.5); - grpc_histogram_add(h1, 8); - grpc_histogram_add(h1, 4); - - h2 = grpc_histogram_create(0.01, 1e9); - GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0); - grpc_histogram_destroy(h2); - - h2 = grpc_histogram_create(0.05, 1e10); - GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0); - grpc_histogram_destroy(h2); - - h2 = grpc_histogram_create(0.05, 1e9); - GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1); - GPR_ASSERT(grpc_histogram_count(h1) == 4); - GPR_ASSERT(grpc_histogram_minimum(h1) == 2.5); - GPR_ASSERT(grpc_histogram_maximum(h1) == 8); - GPR_ASSERT(grpc_histogram_sum(h1) == 17); - GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 92.5); - GPR_ASSERT(grpc_histogram_mean(h1) == 4.25); - GPR_ASSERT(grpc_histogram_variance(h1) == 5.0625); - GPR_ASSERT(grpc_histogram_stddev(h1) == 2.25); - grpc_histogram_destroy(h2); - - h2 = grpc_histogram_create(0.05, 1e9); - grpc_histogram_add(h2, 7.0); - grpc_histogram_add(h2, 17.0); - grpc_histogram_add(h2, 1.0); - GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1); - GPR_ASSERT(grpc_histogram_count(h1) == 7); - GPR_ASSERT(grpc_histogram_minimum(h1) == 1.0); - GPR_ASSERT(grpc_histogram_maximum(h1) == 17.0); - GPR_ASSERT(grpc_histogram_sum(h1) == 42.0); - GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 431.5); - GPR_ASSERT(grpc_histogram_mean(h1) == 6.0); - - /* test monotonicity */ - last = 0.0; - for (i = 0; i < 100.0; i += 0.01) { - cur = grpc_histogram_percentile(h1, i); - GPR_ASSERT(cur >= last); - last = cur; - } - - grpc_histogram_destroy(h1); - grpc_histogram_destroy(h2); -} - -int main(void) { - test_no_op(); - test_simple(); - test_percentile(); - test_merge(); - return 0; -} diff --git a/contrib/libs/grpc/test/core/util/memory_counters.cc b/contrib/libs/grpc/test/core/util/memory_counters.cc deleted file mode 100644 index 0deb1a4d37..0000000000 --- a/contrib/libs/grpc/test/core/util/memory_counters.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/core/util/memory_counters.h" - -#include <inttypes.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/sync.h> -#include <grpc/support/time.h> - -#include "src/core/lib/gpr/alloc.h" -#include "src/core/lib/surface/init.h" - -static struct grpc_memory_counters g_memory_counters; -static bool g_memory_counter_enabled; - -#ifdef GPR_LOW_LEVEL_COUNTERS -/* hide these from the microbenchmark atomic stats */ -#define NO_BARRIER_FETCH_ADD(x, sz) \ - __atomic_fetch_add((x), (sz), __ATOMIC_RELAXED) -#define NO_BARRIER_LOAD(x) __atomic_load_n((x), __ATOMIC_RELAXED) -#else -#define NO_BARRIER_FETCH_ADD(x, sz) gpr_atm_no_barrier_fetch_add(x, sz) -#define NO_BARRIER_LOAD(x) gpr_atm_no_barrier_load(x) -#endif - -// Memory counter uses --wrap=symbol feature from ld. To use this, -// `GPR_WRAP_MEMORY_COUNTER` needs to be defined. following options should be -// passed to the compiler. -// -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -// * Reference: https://linux.die.net/man/1/ld) -#if GPR_WRAP_MEMORY_COUNTER - -extern "C" { -void* __real_malloc(size_t size); -void* __real_calloc(size_t size); -void* __real_realloc(void* ptr, size_t size); -void __real_free(void* ptr); - -void* __wrap_malloc(size_t size); -void* __wrap_calloc(size_t size); -void* __wrap_realloc(void* ptr, size_t size); -void __wrap_free(void* ptr); -} - -void* __wrap_malloc(size_t size) { - if (!size) return nullptr; - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1); - void* ptr = - __real_malloc(GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)) + size); - *static_cast<size_t*>(ptr) = size; - return static_cast<char*>(ptr) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); -} - -void* __wrap_calloc(size_t size) { - if (!size) return nullptr; - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1); - void* ptr = - __real_calloc(GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)) + size); - *static_cast<size_t*>(ptr) = size; - return static_cast<char*>(ptr) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); -} - -void* __wrap_realloc(void* ptr, size_t size) { - if (ptr == nullptr) { - return __wrap_malloc(size); - } - if (size == 0) { - __wrap_free(ptr); - return nullptr; - } - void* rptr = - static_cast<char*>(ptr) - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, - -*static_cast<gpr_atm*>(rptr)); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); - void* new_ptr = - __real_realloc(rptr, GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)) + size); - *static_cast<size_t*>(new_ptr) = size; - return static_cast<char*>(new_ptr) + - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size)); -} - -void __wrap_free(void* ptr) { - if (ptr == nullptr) return; - void* rptr = - static_cast<char*>(ptr) - GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(size_t)); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, - -*static_cast<gpr_atm*>(rptr)); - NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, -(gpr_atm)1); - __real_free(rptr); -} - -#endif // GPR_WRAP_MEMORY_COUNTER - -void grpc_memory_counters_init() { - memset(&g_memory_counters, 0, sizeof(g_memory_counters)); - g_memory_counter_enabled = true; -} - -void grpc_memory_counters_destroy() { g_memory_counter_enabled = false; } - -struct grpc_memory_counters grpc_memory_counters_snapshot() { - struct grpc_memory_counters counters; - counters.total_size_relative = - NO_BARRIER_LOAD(&g_memory_counters.total_size_relative); - counters.total_size_absolute = - NO_BARRIER_LOAD(&g_memory_counters.total_size_absolute); - counters.total_allocs_relative = - NO_BARRIER_LOAD(&g_memory_counters.total_allocs_relative); - counters.total_allocs_absolute = - NO_BARRIER_LOAD(&g_memory_counters.total_allocs_absolute); - return counters; -} - -namespace grpc_core { -namespace testing { - -LeakDetector::LeakDetector(bool enable) : enabled_(enable) { - if (enabled_) { - grpc_memory_counters_init(); - } -} - -LeakDetector::~LeakDetector() { - // Wait for grpc_shutdown() to finish its async work. - grpc_maybe_wait_for_async_shutdown(); - if (enabled_) { - struct grpc_memory_counters counters = grpc_memory_counters_snapshot(); - if (counters.total_size_relative != 0) { - gpr_log(GPR_ERROR, "Leaking %" PRIuPTR " bytes", - static_cast<uintptr_t>(counters.total_size_relative)); - GPR_ASSERT(0); - } - grpc_memory_counters_destroy(); - } -} - -} // namespace testing -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/memory_counters.h b/contrib/libs/grpc/test/core/util/memory_counters.h deleted file mode 100644 index c92a001ff1..0000000000 --- a/contrib/libs/grpc/test/core/util/memory_counters.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_MEMORY_COUNTERS_H -#define GRPC_TEST_CORE_UTIL_MEMORY_COUNTERS_H - -#include <grpc/support/atm.h> - -struct grpc_memory_counters { - gpr_atm total_size_relative; - gpr_atm total_size_absolute; - gpr_atm total_allocs_relative; - gpr_atm total_allocs_absolute; -}; - -void grpc_memory_counters_init(); -void grpc_memory_counters_destroy(); -struct grpc_memory_counters grpc_memory_counters_snapshot(); - -namespace grpc_core { -namespace testing { - -// At destruction time, it will check there is no memory leak. -// The object should be created before grpc_init() is called and destroyed after -// grpc_shutdown() is returned. -class LeakDetector { - public: - explicit LeakDetector(bool enable); - ~LeakDetector(); - - private: - const bool enabled_; -}; - -} // namespace testing -} // namespace grpc_core - -#endif diff --git a/contrib/libs/grpc/test/core/util/mock_authorization_endpoint.h b/contrib/libs/grpc/test/core/util/mock_authorization_endpoint.h deleted file mode 100644 index b0404f7f05..0000000000 --- a/contrib/libs/grpc/test/core/util/mock_authorization_endpoint.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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. - -#ifndef GRPC_TEST_CORE_UTIL_MOCK_AUTHORIZATION_ENDPOINT_H -#define GRPC_TEST_CORE_UTIL_MOCK_AUTHORIZATION_ENDPOINT_H - -#include <grpc/support/port_platform.h> - -#include "src/core/lib/iomgr/endpoint.h" - -namespace grpc_core { - -class MockAuthorizationEndpoint : public grpc_endpoint { - public: - MockAuthorizationEndpoint(y_absl::string_view local_uri, - y_absl::string_view peer_uri) - : local_address_(local_uri), peer_address_(peer_uri) { - static constexpr grpc_endpoint_vtable vtable = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, GetPeer, GetLocalAddress, nullptr, nullptr}; - grpc_endpoint::vtable = &vtable; - } - - static y_absl::string_view GetPeer(grpc_endpoint* ep) { - MockAuthorizationEndpoint* m = - reinterpret_cast<MockAuthorizationEndpoint*>(ep); - return m->peer_address_; - } - - static y_absl::string_view GetLocalAddress(grpc_endpoint* ep) { - MockAuthorizationEndpoint* m = - reinterpret_cast<MockAuthorizationEndpoint*>(ep); - return m->local_address_; - } - - void SetPeer(y_absl::string_view peer_address) { - peer_address_ = TString(peer_address); - } - - void SetLocalAddress(y_absl::string_view local_address) { - local_address_ = TString(local_address); - } - - private: - TString local_address_; - TString peer_address_; -}; - -} // namespace grpc_core - -#endif // GRPC_TEST_CORE_UTIL_MOCK_AUTHORIZATION_ENDPOINT_H diff --git a/contrib/libs/grpc/test/core/util/mock_endpoint.cc b/contrib/libs/grpc/test/core/util/mock_endpoint.cc deleted file mode 100644 index 34ce7ffbf7..0000000000 --- a/contrib/libs/grpc/test/core/util/mock_endpoint.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/core/util/mock_endpoint.h" - -#include <inttypes.h> - -#include <util/generic/string.h> - -#include "y_absl/strings/str_format.h" - -#include <grpc/support/alloc.h> -#include <grpc/support/string_util.h> - -#include "src/core/lib/iomgr/sockaddr.h" - -typedef struct mock_endpoint { - grpc_endpoint base; - gpr_mu mu; - void (*on_write)(grpc_slice slice); - grpc_slice_buffer read_buffer; - grpc_slice_buffer* on_read_out; - grpc_closure* on_read; -} mock_endpoint; - -static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices, - grpc_closure* cb, bool /*urgent*/) { - mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep); - gpr_mu_lock(&m->mu); - if (m->read_buffer.count > 0) { - grpc_slice_buffer_swap(&m->read_buffer, slices); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, GRPC_ERROR_NONE); - } else { - m->on_read = cb; - m->on_read_out = slices; - } - gpr_mu_unlock(&m->mu); -} - -static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices, - grpc_closure* cb, void* /*arg*/) { - mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep); - for (size_t i = 0; i < slices->count; i++) { - m->on_write(slices->slices[i]); - } - grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, GRPC_ERROR_NONE); -} - -static void me_add_to_pollset(grpc_endpoint* /*ep*/, - grpc_pollset* /*pollset*/) {} - -static void me_add_to_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - -static void me_delete_from_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - -static void me_shutdown(grpc_endpoint* ep, grpc_error_handle why) { - mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep); - gpr_mu_lock(&m->mu); - if (m->on_read) { - grpc_core::ExecCtx::Run(DEBUG_LOCATION, m->on_read, - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Endpoint Shutdown", &why, 1)); - m->on_read = nullptr; - } - gpr_mu_unlock(&m->mu); - GRPC_ERROR_UNREF(why); -} - -static void me_destroy(grpc_endpoint* ep) { - mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep); - grpc_slice_buffer_destroy(&m->read_buffer); - gpr_mu_destroy(&m->mu); - gpr_free(m); -} - -static y_absl::string_view me_get_peer(grpc_endpoint* /*ep*/) { - return "fake:mock_endpoint"; -} - -static y_absl::string_view me_get_local_address(grpc_endpoint* /*ep*/) { - return "fake:mock_endpoint"; -} - -static int me_get_fd(grpc_endpoint* /*ep*/) { return -1; } - -static bool me_can_track_err(grpc_endpoint* /*ep*/) { return false; } - -static const grpc_endpoint_vtable vtable = {me_read, - me_write, - me_add_to_pollset, - me_add_to_pollset_set, - me_delete_from_pollset_set, - me_shutdown, - me_destroy, - me_get_peer, - me_get_local_address, - me_get_fd, - me_can_track_err}; - -grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice)) { - mock_endpoint* m = static_cast<mock_endpoint*>(gpr_malloc(sizeof(*m))); - m->base.vtable = &vtable; - grpc_slice_buffer_init(&m->read_buffer); - gpr_mu_init(&m->mu); - m->on_write = on_write; - m->on_read = nullptr; - return &m->base; -} - -void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) { - mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep); - gpr_mu_lock(&m->mu); - if (m->on_read != nullptr) { - grpc_slice_buffer_add(m->on_read_out, slice); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, m->on_read, GRPC_ERROR_NONE); - m->on_read = nullptr; - } else { - grpc_slice_buffer_add(&m->read_buffer, slice); - } - gpr_mu_unlock(&m->mu); -} diff --git a/contrib/libs/grpc/test/core/util/mock_endpoint.h b/contrib/libs/grpc/test/core/util/mock_endpoint.h deleted file mode 100644 index 6d52390e09..0000000000 --- a/contrib/libs/grpc/test/core/util/mock_endpoint.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Copyright 2016 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 MOCK_ENDPOINT_H -#define MOCK_ENDPOINT_H - -#include "src/core/lib/iomgr/endpoint.h" - -grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice)); -void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice); - -#endif diff --git a/contrib/libs/grpc/test/core/util/one_corpus_entry_fuzzer.cc b/contrib/libs/grpc/test/core/util/one_corpus_entry_fuzzer.cc deleted file mode 100644 index fa0f04f025..0000000000 --- a/contrib/libs/grpc/test/core/util/one_corpus_entry_fuzzer.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <stdbool.h> - -#include <grpc/grpc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/load_file.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); - -extern bool squelch; -extern bool leak_check; - -int main(int argc, char** argv) { - grpc_slice buffer; - squelch = false; - leak_check = false; - /* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace - * grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with - * grpc_shutdown */ - GPR_ASSERT(argc > 1); /* Make sure that we have a filename argument */ - GPR_ASSERT( - GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); - LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), - GRPC_SLICE_LENGTH(buffer)); - grpc_core::ExecCtx::GlobalInit(); - grpc_slice_unref(buffer); - grpc_core::ExecCtx::GlobalShutdown(); - return 0; -} diff --git a/contrib/libs/grpc/test/core/util/parse_hexstring.cc b/contrib/libs/grpc/test/core/util/parse_hexstring.cc deleted file mode 100644 index a65ef99951..0000000000 --- a/contrib/libs/grpc/test/core/util/parse_hexstring.cc +++ /dev/null @@ -1,57 +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. - * - */ - -#include "test/core/util/parse_hexstring.h" - -#include <grpc/support/log.h> - -grpc_slice parse_hexstring(const char* hexstring) { - size_t nibbles = 0; - const char* p = nullptr; - uint8_t* out; - uint8_t temp; - grpc_slice slice; - - for (p = hexstring; *p; p++) { - nibbles += (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f'); - } - - GPR_ASSERT((nibbles & 1) == 0); - - slice = grpc_slice_malloc(nibbles / 2); - out = GRPC_SLICE_START_PTR(slice); - - nibbles = 0; - temp = 0; - for (p = hexstring; *p; p++) { - if (*p >= '0' && *p <= '9') { - temp = static_cast<uint8_t>(temp << 4) | static_cast<uint8_t>(*p - '0'); - nibbles++; - } else if (*p >= 'a' && *p <= 'f') { - temp = - static_cast<uint8_t>(temp << 4) | static_cast<uint8_t>(*p - 'a' + 10); - nibbles++; - } - if (nibbles == 2) { - *out++ = temp; - nibbles = 0; - } - } - - return slice; -} diff --git a/contrib/libs/grpc/test/core/util/parse_hexstring.h b/contrib/libs/grpc/test/core/util/parse_hexstring.h deleted file mode 100644 index b7d54c1711..0000000000 --- a/contrib/libs/grpc/test/core/util/parse_hexstring.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H -#define GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H - -#include <grpc/slice.h> - -grpc_slice parse_hexstring(const char* hexstring); - -#endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ diff --git a/contrib/libs/grpc/test/core/util/passthru_endpoint.cc b/contrib/libs/grpc/test/core/util/passthru_endpoint.cc deleted file mode 100644 index 080076bcb5..0000000000 --- a/contrib/libs/grpc/test/core/util/passthru_endpoint.cc +++ /dev/null @@ -1,497 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/core/util/passthru_endpoint.h" - -#include <inttypes.h> -#include <string.h> - -#include <util/generic/string.h> - -#include "y_absl/strings/str_format.h" - -#include <grpc/support/alloc.h> -#include <grpc/support/string_util.h> - -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/slice/slice_internal.h" - -typedef struct passthru_endpoint passthru_endpoint; - -typedef struct { - bool is_armed; - grpc_endpoint* ep; - grpc_slice_buffer* slices; - grpc_closure* cb; -} pending_op; - -typedef struct { - grpc_timer timer; - uint64_t allowed_write_bytes; - uint64_t allowed_read_bytes; - std::vector<grpc_passthru_endpoint_channel_action> actions; - std::function<void()> on_complete; -} grpc_passthru_endpoint_channel_effects; - -typedef struct { - grpc_endpoint base; - passthru_endpoint* parent; - grpc_slice_buffer read_buffer; - grpc_slice_buffer write_buffer; - grpc_slice_buffer* on_read_out; - grpc_closure* on_read; - pending_op pending_read_op; - pending_op pending_write_op; - uint64_t bytes_read_so_far; - uint64_t bytes_written_so_far; -} half; - -struct passthru_endpoint { - gpr_mu mu; - int halves; - grpc_passthru_endpoint_stats* stats; - grpc_passthru_endpoint_channel_effects* channel_effects; - bool simulate_channel_actions; - bool shutdown; - half client; - half server; -}; - -static void do_pending_read_op_locked(half* m, grpc_error_handle error) { - GPR_ASSERT(m->pending_read_op.is_armed); - GPR_ASSERT(m->bytes_read_so_far <= - m->parent->channel_effects->allowed_read_bytes); - if (m->parent->shutdown) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, m->pending_read_op.cb, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown")); - grpc_slice_buffer_reset_and_unref(&m->read_buffer); - m->pending_read_op.is_armed = false; - return; - } - - if (m->bytes_read_so_far == m->parent->channel_effects->allowed_read_bytes) { - // Keep it in pending state. - return; - } - // This delayed processing should only be invoked when read_buffer has - // something in it. - GPR_ASSERT(m->read_buffer.count > 0); - uint64_t readable_length = std::min<uint64_t>( - m->read_buffer.length, - m->parent->channel_effects->allowed_read_bytes - m->bytes_read_so_far); - GPR_ASSERT(readable_length > 0); - grpc_slice_buffer_move_first_no_ref(&m->read_buffer, readable_length, - m->pending_read_op.slices); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, m->pending_read_op.cb, error); - if (m->parent->simulate_channel_actions) { - m->bytes_read_so_far += readable_length; - } - m->pending_read_op.is_armed = false; -} - -static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices, - grpc_closure* cb, bool /*urgent*/) { - half* m = reinterpret_cast<half*>(ep); - gpr_mu_lock(&m->parent->mu); - if (m->parent->shutdown) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, cb, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown")); - } else if (m->read_buffer.count > 0) { - GPR_ASSERT(!m->pending_read_op.is_armed); - GPR_ASSERT(!m->on_read); - m->pending_read_op.is_armed = true; - m->pending_read_op.cb = cb; - m->pending_read_op.ep = ep; - m->pending_read_op.slices = slices; - do_pending_read_op_locked(m, GRPC_ERROR_NONE); - } else { - GPR_ASSERT(!m->pending_read_op.is_armed); - m->on_read = cb; - m->on_read_out = slices; - } - gpr_mu_unlock(&m->parent->mu); -} - -// Copy src slice and split the copy at n bytes into two separate slices -void grpc_slice_copy_split(grpc_slice src, uint64_t n, grpc_slice& split1, - grpc_slice& split2) { - GPR_ASSERT(n <= GRPC_SLICE_LENGTH(src)); - if (n == GRPC_SLICE_LENGTH(src)) { - split1 = grpc_slice_copy(src); - split2 = grpc_empty_slice(); - return; - } - split1 = GRPC_SLICE_MALLOC(n); - memcpy(GRPC_SLICE_START_PTR(split1), GRPC_SLICE_START_PTR(src), n); - split2 = GRPC_SLICE_MALLOC(GRPC_SLICE_LENGTH(src) - n); - memcpy(GRPC_SLICE_START_PTR(split2), GRPC_SLICE_START_PTR(src) + n, - GRPC_SLICE_LENGTH(src) - n); -} - -static half* other_half(half* h) { - if (h == &h->parent->client) return &h->parent->server; - return &h->parent->client; -} - -static void do_pending_write_op_locked(half* m, grpc_error_handle error) { - GPR_ASSERT(m->pending_write_op.is_armed); - GPR_ASSERT(m->bytes_written_so_far <= - m->parent->channel_effects->allowed_write_bytes); - if (m->parent->shutdown) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, m->pending_write_op.cb, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown")); - m->pending_write_op.is_armed = false; - grpc_slice_buffer_reset_and_unref(m->pending_write_op.slices); - return; - } - if (m->bytes_written_so_far == - m->parent->channel_effects->allowed_write_bytes) { - // Keep it in pending state. - return; - } - - half* other = other_half(m); - uint64_t max_writable = - std::min<uint64_t>(m->pending_write_op.slices->length, - m->parent->channel_effects->allowed_write_bytes - - m->bytes_written_so_far); - uint64_t max_readable = other->parent->channel_effects->allowed_read_bytes - - other->bytes_read_so_far; - uint64_t immediate_bytes_read = - other->on_read != nullptr ? std::min<uint64_t>(max_readable, max_writable) - : 0; - - GPR_ASSERT(max_writable > 0); - GPR_ASSERT(max_readable >= 0); - // At the end of this process, we should have written max_writable bytes; - if (m->parent->simulate_channel_actions) { - m->bytes_written_so_far += max_writable; - } - // Estimate if the original write would still be pending at the end of this - // process - bool would_write_be_pending = - max_writable < m->pending_write_op.slices->length; - if (!m->parent->simulate_channel_actions) { - GPR_ASSERT(!would_write_be_pending); - } - grpc_slice_buffer* slices = m->pending_write_op.slices; - grpc_slice_buffer* dest = - other->on_read != nullptr ? other->on_read_out : &other->read_buffer; - while (max_writable > 0) { - grpc_slice slice = grpc_slice_buffer_take_first(slices); - uint64_t slice_length = GPR_SLICE_LENGTH(slice); - GPR_ASSERT(slice_length > 0); - grpc_slice split1, split2; - uint64_t split_length = 0; - if (slice_length <= max_readable) { - split_length = std::min<uint64_t>(slice_length, max_writable); - } else if (max_readable > 0) { - // slice_length > max_readable - split_length = std::min<uint64_t>(max_readable, max_writable); - } else { - // slice_length still > max_readable but max_readable is 0. - // In this case put the bytes into other->read_buffer. During a future - // read if max_readable still remains zero at the time of read, the - // pending read logic will kick in. - dest = &other->read_buffer; - split_length = std::min<uint64_t>(slice_length, max_writable); - } - - grpc_slice_copy_split(slice, split_length, split1, split2); - grpc_slice_unref_internal(slice); - // Write a copy of the slice to the destination to be read - grpc_slice_buffer_add_indexed(dest, split1); - // Re-insert split2 into source for next iteration. - if (GPR_SLICE_LENGTH(split2) > 0) { - grpc_slice_buffer_undo_take_first(slices, split2); - } else { - grpc_slice_unref_internal(split2); - } - - if (max_readable > 0) { - GPR_ASSERT(max_readable >= static_cast<uint64_t>(split_length)); - max_readable -= split_length; - } - - GPR_ASSERT(max_writable >= static_cast<uint64_t>(split_length)); - max_writable -= split_length; - } - - if (immediate_bytes_read > 0) { - GPR_ASSERT(!other->pending_read_op.is_armed); - if (m->parent->simulate_channel_actions) { - other->bytes_read_so_far += immediate_bytes_read; - } - grpc_core::ExecCtx::Run(DEBUG_LOCATION, other->on_read, error); - other->on_read = nullptr; - } - - if (!would_write_be_pending) { - // No slices should be left - GPR_ASSERT(m->pending_write_op.slices->count == 0); - grpc_slice_buffer_reset_and_unref(m->pending_write_op.slices); - m->pending_write_op.is_armed = false; - grpc_core::ExecCtx::Run(DEBUG_LOCATION, m->pending_write_op.cb, error); - } -} - -static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices, - grpc_closure* cb, void* /*arg*/) { - half* m = reinterpret_cast<half*>(ep); - gpr_mu_lock(&m->parent->mu); - gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1); - if (m->parent->shutdown) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, cb, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown")); - } else { - GPR_ASSERT(!m->pending_write_op.is_armed); - // Copy slices into m->pending_write_op.slices - m->pending_write_op.slices = &m->write_buffer; - GPR_ASSERT(m->pending_write_op.slices->count == 0); - for (int i = 0; i < static_cast<int>(slices->count); i++) { - if (GPR_SLICE_LENGTH(slices->slices[i]) > 0) { - grpc_slice_buffer_add_indexed(m->pending_write_op.slices, - grpc_slice_copy(slices->slices[i])); - } - } - if (m->pending_write_op.slices->count > 0) { - m->pending_write_op.is_armed = true; - m->pending_write_op.cb = cb; - m->pending_write_op.ep = ep; - do_pending_write_op_locked(m, GRPC_ERROR_NONE); - } else { - // There is nothing to write. Schedule callback to be run right away. - grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, GRPC_ERROR_NONE); - } - } - gpr_mu_unlock(&m->parent->mu); -} - -void flush_pending_ops_locked(half* m, grpc_error_handle error) { - if (m->pending_read_op.is_armed) { - do_pending_read_op_locked(m, error); - } - if (m->pending_write_op.is_armed) { - do_pending_write_op_locked(m, error); - } -} - -static void me_add_to_pollset(grpc_endpoint* /*ep*/, - grpc_pollset* /*pollset*/) {} - -static void me_add_to_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - -static void me_delete_from_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - -static void me_shutdown(grpc_endpoint* ep, grpc_error_handle why) { - half* m = reinterpret_cast<half*>(ep); - gpr_mu_lock(&m->parent->mu); - m->parent->shutdown = true; - flush_pending_ops_locked(m, GRPC_ERROR_NONE); - if (m->on_read) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, m->on_read, - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1)); - m->on_read = nullptr; - } - m = other_half(m); - flush_pending_ops_locked(m, GRPC_ERROR_NONE); - if (m->on_read) { - grpc_core::ExecCtx::Run( - DEBUG_LOCATION, m->on_read, - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1)); - m->on_read = nullptr; - } - gpr_mu_unlock(&m->parent->mu); - GRPC_ERROR_UNREF(why); -} - -void grpc_passthru_endpoint_destroy(passthru_endpoint* p) { - gpr_mu_destroy(&p->mu); - grpc_passthru_endpoint_stats_destroy(p->stats); - delete p->channel_effects; - grpc_slice_buffer_destroy_internal(&p->client.read_buffer); - grpc_slice_buffer_destroy_internal(&p->server.read_buffer); - grpc_slice_buffer_destroy_internal(&p->client.write_buffer); - grpc_slice_buffer_destroy_internal(&p->server.write_buffer); - gpr_free(p); -} - -static void me_destroy(grpc_endpoint* ep) { - passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent; - gpr_mu_lock(&p->mu); - if (0 == --p->halves && p->channel_effects->actions.empty()) { - // no pending channel actions exist - gpr_mu_unlock(&p->mu); - grpc_passthru_endpoint_destroy(p); - } else { - if (p->halves == 0 && p->simulate_channel_actions) { - grpc_timer_cancel(&p->channel_effects->timer); - } - gpr_mu_unlock(&p->mu); - } -} - -static y_absl::string_view me_get_peer(grpc_endpoint* ep) { - passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent; - return (reinterpret_cast<half*>(ep)) == &p->client - ? "fake:mock_client_endpoint" - : "fake:mock_server_endpoint"; -} - -static y_absl::string_view me_get_local_address(grpc_endpoint* ep) { - passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent; - return (reinterpret_cast<half*>(ep)) == &p->client - ? "fake:mock_client_endpoint" - : "fake:mock_server_endpoint"; -} - -static int me_get_fd(grpc_endpoint* /*ep*/) { return -1; } - -static bool me_can_track_err(grpc_endpoint* /*ep*/) { return false; } - -static const grpc_endpoint_vtable vtable = { - me_read, - me_write, - me_add_to_pollset, - me_add_to_pollset_set, - me_delete_from_pollset_set, - me_shutdown, - me_destroy, - me_get_peer, - me_get_local_address, - me_get_fd, - me_can_track_err, -}; - -static void half_init(half* m, passthru_endpoint* parent, - const char* half_name) { - m->base.vtable = &vtable; - m->parent = parent; - grpc_slice_buffer_init(&m->read_buffer); - grpc_slice_buffer_init(&m->write_buffer); - m->pending_write_op.slices = nullptr; - m->on_read = nullptr; - m->bytes_read_so_far = 0; - m->bytes_written_so_far = 0; - m->pending_write_op.is_armed = false; - m->pending_read_op.is_armed = false; - TString name = - y_absl::StrFormat("passthru_endpoint_%s_%p", half_name, parent); -} - -void grpc_passthru_endpoint_create(grpc_endpoint** client, - grpc_endpoint** server, - grpc_passthru_endpoint_stats* stats, - bool simulate_channel_actions) { - passthru_endpoint* m = - static_cast<passthru_endpoint*>(gpr_malloc(sizeof(*m))); - m->halves = 2; - m->shutdown = false; - if (stats == nullptr) { - m->stats = grpc_passthru_endpoint_stats_create(); - } else { - gpr_ref(&stats->refs); - m->stats = stats; - } - m->channel_effects = new grpc_passthru_endpoint_channel_effects(); - m->simulate_channel_actions = simulate_channel_actions; - if (!simulate_channel_actions) { - m->channel_effects->allowed_read_bytes = UINT64_MAX; - m->channel_effects->allowed_write_bytes = UINT64_MAX; - } - half_init(&m->client, m, "client"); - half_init(&m->server, m, "server"); - gpr_mu_init(&m->mu); - *client = &m->client.base; - *server = &m->server.base; -} - -grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create() { - grpc_passthru_endpoint_stats* stats = - static_cast<grpc_passthru_endpoint_stats*>( - gpr_malloc(sizeof(grpc_passthru_endpoint_stats))); - memset(stats, 0, sizeof(*stats)); - gpr_ref_init(&stats->refs, 1); - return stats; -} - -void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats) { - if (gpr_unref(&stats->refs)) { - gpr_free(stats); - } -} - -static void sched_next_channel_action_locked(half* m); - -static void do_next_sched_channel_action(void* arg, grpc_error_handle error) { - half* m = reinterpret_cast<half*>(arg); - gpr_mu_lock(&m->parent->mu); - GPR_ASSERT(!m->parent->channel_effects->actions.empty()); - if (m->parent->halves == 0) { - gpr_mu_unlock(&m->parent->mu); - grpc_passthru_endpoint_destroy(m->parent); - return; - } - auto curr_action = m->parent->channel_effects->actions[0]; - m->parent->channel_effects->actions.erase( - m->parent->channel_effects->actions.begin()); - m->parent->channel_effects->allowed_read_bytes += - curr_action.add_n_readable_bytes; - m->parent->channel_effects->allowed_write_bytes += - curr_action.add_n_writable_bytes; - flush_pending_ops_locked(m, error); - flush_pending_ops_locked(other_half(m), error); - sched_next_channel_action_locked(m); - gpr_mu_unlock(&m->parent->mu); -} - -static void sched_next_channel_action_locked(half* m) { - if (m->parent->channel_effects->actions.empty()) { - m->parent->channel_effects->on_complete(); - return; - } - grpc_timer_init(&m->parent->channel_effects->timer, - m->parent->channel_effects->actions[0].wait_ms + - grpc_core::ExecCtx::Get()->Now(), - GRPC_CLOSURE_CREATE(do_next_sched_channel_action, m, - grpc_schedule_on_exec_ctx)); -} - -void start_scheduling_grpc_passthru_endpoint_channel_effects( - grpc_endpoint* ep, - const std::vector<grpc_passthru_endpoint_channel_action>& actions, - std::function<void()> on_complete) { - half* m = reinterpret_cast<half*>(ep); - gpr_mu_lock(&m->parent->mu); - if (!m->parent->simulate_channel_actions || m->parent->shutdown) { - gpr_mu_unlock(&m->parent->mu); - return; - } - m->parent->channel_effects->actions = actions; - m->parent->channel_effects->on_complete = std::move(on_complete); - sched_next_channel_action_locked(m); - gpr_mu_unlock(&m->parent->mu); -} diff --git a/contrib/libs/grpc/test/core/util/passthru_endpoint.h b/contrib/libs/grpc/test/core/util/passthru_endpoint.h deleted file mode 100644 index b34cbc25f9..0000000000 --- a/contrib/libs/grpc/test/core/util/passthru_endpoint.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2016 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 PASSTHRU_ENDPOINT_H -#define PASSTHRU_ENDPOINT_H - -#include <grpc/support/atm.h> - -#include "src/core/lib/iomgr/endpoint.h" - -/* The struct is refcounted, always use grpc_passthru_endpoint_stats_create and - * grpc_passthru_endpoint_stats_destroy, rather then embedding it in your - * objects by value. */ -typedef struct { - gpr_refcount refs; - gpr_atm num_writes; -} grpc_passthru_endpoint_stats; - -typedef struct { - uint64_t wait_ms; - uint64_t add_n_writable_bytes; - uint64_t add_n_readable_bytes; -} grpc_passthru_endpoint_channel_action; - -void grpc_passthru_endpoint_create(grpc_endpoint** client, - grpc_endpoint** server, - grpc_passthru_endpoint_stats* stats, - bool simulate_channel_actions = false); - -grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create(); - -void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats); - -void start_scheduling_grpc_passthru_endpoint_channel_effects( - grpc_endpoint* ep, - const std::vector<grpc_passthru_endpoint_channel_action>& actions, - std::function<void()> on_complete); - -#endif // PASSTHRU_ENDPOINT_H diff --git a/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc b/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc deleted file mode 100644 index 6d32aeb4cd..0000000000 --- a/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright 2017 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. - * - */ - -/* When individual tests run in an isolated runtime environment (e.g. each test - * runs in a separate container) the framework takes a round-robin pick of a - * port within certain range. There is no need to recycle ports. - */ -#include <stdlib.h> - -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> - -#include "src/core/lib/iomgr/port.h" -#include "test/core/util/test_config.h" -#if defined(GRPC_PORT_ISOLATED_RUNTIME) - -#include "test/core/util/port.h" - -#define MIN_PORT 1025 -#define MAX_PORT 32766 - -static int get_random_port_offset() { - srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); - double rnd = static_cast<double>(rand()) / - (static_cast<double>(RAND_MAX) + 1.0); // values from [0,1) - return static_cast<int>(rnd * (MAX_PORT - MIN_PORT + 1)); -} - -static int s_initial_offset = get_random_port_offset(); -static gpr_atm s_pick_counter = 0; - -static int grpc_pick_unused_port_or_die_impl(void) { - int orig_counter_val = - static_cast<int>(gpr_atm_full_fetch_add(&s_pick_counter, 1)); - GPR_ASSERT(orig_counter_val < (MAX_PORT - MIN_PORT + 1)); - return MIN_PORT + - (s_initial_offset + orig_counter_val) % (MAX_PORT - MIN_PORT + 1); -} - -int grpc_pick_unused_port_or_die(void) { - while (true) { - int port = grpc_pick_unused_port_or_die_impl(); - // 5985 cannot be bound on Windows RBE and results in - // WSA_ERROR 10013: "An attempt was made to access a socket in a way - // forbidden by its access permissions." - if (port == 5985) { - continue; - } - return port; - } -} - -void grpc_recycle_unused_port(int port) { (void)port; } - -#endif /* GRPC_PORT_ISOLATED_RUNTIME */ diff --git a/contrib/libs/grpc/test/core/util/reconnect_server.cc b/contrib/libs/grpc/test/core/util/reconnect_server.cc deleted file mode 100644 index 7ce4b6fbe8..0000000000 --- a/contrib/libs/grpc/test/core/util/reconnect_server.cc +++ /dev/null @@ -1,131 +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. - * - */ - -#include "test/core/util/reconnect_server.h" - -#include <string.h> - -#include "y_absl/strings/string_view.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/sync.h> -#include <grpc/support/time.h> - -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/iomgr/tcp_server.h" -#include "test/core/util/port.h" -#include "test/core/util/test_tcp_server.h" - -static void pretty_print_backoffs(reconnect_server* server) { - gpr_timespec diff; - int i = 1; - double expected_backoff = 1000.0, backoff; - timestamp_list* head = server->head; - gpr_log(GPR_INFO, "reconnect server: new connection"); - for (head = server->head; head && head->next; head = head->next, i++) { - diff = gpr_time_sub(head->next->timestamp, head->timestamp); - backoff = gpr_time_to_millis(diff); - gpr_log(GPR_INFO, - "retry %2d:backoff %6.2fs,expected backoff %6.2fs, jitter %4.2f%%", - i, backoff / 1000.0, expected_backoff / 1000.0, - (backoff - expected_backoff) * 100.0 / expected_backoff); - expected_backoff *= 1.6; - int max_reconnect_backoff_ms = 120 * 1000; - if (server->max_reconnect_backoff_ms > 0) { - max_reconnect_backoff_ms = server->max_reconnect_backoff_ms; - } - if (expected_backoff > max_reconnect_backoff_ms) { - expected_backoff = max_reconnect_backoff_ms; - } - } -} - -static void on_connect(void* arg, grpc_endpoint* tcp, - grpc_pollset* /*accepting_pollset*/, - grpc_tcp_server_acceptor* acceptor) { - gpr_free(acceptor); - y_absl::string_view peer; - y_absl::string_view::size_type last_colon; - reconnect_server* server = static_cast<reconnect_server*>(arg); - gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); - timestamp_list* new_tail; - peer = grpc_endpoint_get_peer(tcp); - grpc_endpoint_shutdown(tcp, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); - grpc_endpoint_destroy(tcp); - last_colon = peer.rfind(':'); - if (server->peer == nullptr) { - server->peer = new TString(peer); - } else { - if (last_colon == TString::npos) { - gpr_log(GPR_ERROR, "peer does not contain a ':'"); - } else if (peer.compare(0, static_cast<size_t>(last_colon), - *server->peer) != 0) { - gpr_log(GPR_ERROR, "mismatched peer! %s vs %s", server->peer->c_str(), - TString(peer).c_str()); - } - } - new_tail = static_cast<timestamp_list*>(gpr_malloc(sizeof(timestamp_list))); - new_tail->timestamp = now; - new_tail->next = nullptr; - if (server->tail == nullptr) { - server->head = new_tail; - server->tail = new_tail; - } else { - server->tail->next = new_tail; - server->tail = new_tail; - } - pretty_print_backoffs(server); -} - -void reconnect_server_init(reconnect_server* server) { - test_tcp_server_init(&server->tcp_server, on_connect, server); - server->head = nullptr; - server->tail = nullptr; - server->peer = nullptr; - server->max_reconnect_backoff_ms = 0; -} - -void reconnect_server_start(reconnect_server* server, int port) { - test_tcp_server_start(&server->tcp_server, port); -} - -void reconnect_server_poll(reconnect_server* server, int seconds) { - test_tcp_server_poll(&server->tcp_server, 1000 * seconds); -} - -void reconnect_server_clear_timestamps(reconnect_server* server) { - timestamp_list* new_head = server->head; - while (server->head) { - new_head = server->head->next; - gpr_free(server->head); - server->head = new_head; - } - server->tail = nullptr; - delete server->peer; - server->peer = nullptr; -} - -void reconnect_server_destroy(reconnect_server* server) { - reconnect_server_clear_timestamps(server); - test_tcp_server_destroy(&server->tcp_server); -} diff --git a/contrib/libs/grpc/test/core/util/reconnect_server.h b/contrib/libs/grpc/test/core/util/reconnect_server.h deleted file mode 100644 index 6f63f9293d..0000000000 --- a/contrib/libs/grpc/test/core/util/reconnect_server.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Copyright 2015-2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_RECONNECT_SERVER_H -#define GRPC_TEST_CORE_UTIL_RECONNECT_SERVER_H - -#include <grpc/support/sync.h> -#include <grpc/support/time.h> - -#include "test/core/util/test_tcp_server.h" - -typedef struct timestamp_list { - gpr_timespec timestamp; - struct timestamp_list* next; -} timestamp_list; - -typedef struct reconnect_server { - test_tcp_server tcp_server; - timestamp_list* head; - timestamp_list* tail; - TString* peer; - int max_reconnect_backoff_ms; -} reconnect_server; - -void reconnect_server_init(reconnect_server* server); -void reconnect_server_start(reconnect_server* server, int port); -void reconnect_server_poll(reconnect_server* server, int seconds); -void reconnect_server_destroy(reconnect_server* server); -void reconnect_server_clear_timestamps(reconnect_server* server); - -#endif /* GRPC_TEST_CORE_UTIL_RECONNECT_SERVER_H */ diff --git a/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.cc b/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.cc deleted file mode 100644 index bf3f621c17..0000000000 --- a/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.cc +++ /dev/null @@ -1,58 +0,0 @@ -// -// -// Copyright 2020 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#include "test/core/util/resolve_localhost_ip46.h" - -#include <grpc/support/log.h> - -#include "src/core/lib/iomgr/port.h" -#include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/lib/iomgr/sockaddr.h" - -namespace grpc_core { -namespace { - -bool localhost_to_ipv4 = false; -bool localhost_to_ipv6 = false; -gpr_once g_resolve_localhost_ipv46 = GPR_ONCE_INIT; - -void InitResolveLocalhost() { - grpc_resolved_addresses* addresses; - grpc_error_handle err = - grpc_blocking_resolve_address("localhost", "https", &addresses); - GPR_ASSERT(err == GRPC_ERROR_NONE); - for (size_t i = 0; i < addresses->naddrs; i++) { - grpc_sockaddr* addr = - reinterpret_cast<grpc_sockaddr*>(addresses->addrs[i].addr); - if (addr->sa_family == GRPC_AF_INET) { - localhost_to_ipv4 = true; - } else if (addr->sa_family == GRPC_AF_INET6) { - localhost_to_ipv6 = true; - } - } - grpc_resolved_addresses_destroy(addresses); -} -} // namespace - -void LocalhostResolves(bool* ipv4, bool* ipv6) { - gpr_once_init(&g_resolve_localhost_ipv46, InitResolveLocalhost); - *ipv4 = localhost_to_ipv4; - *ipv6 = localhost_to_ipv6; -} - -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.h b/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.h deleted file mode 100644 index d8f7883adf..0000000000 --- a/contrib/libs/grpc/test/core/util/resolve_localhost_ip46.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// -// Copyright 2020 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#ifndef GRPC_TEST_CORE_UTIL_RESOLVE_LOCALHOST_IP46_H_ -#define GRPC_TEST_CORE_UTIL_RESOLVE_LOCALHOST_IP46_H_ - -namespace grpc_core { - -// Test whether localhost resolves to ipv4 and/or ipv6 -void LocalhostResolves(bool* ipv4, bool* ipv6); - -} // namespace grpc_core - -#endif // GRPC_TEST_CORE_UTIL_RESOLVE_LOCALHOST_IP46_H_ diff --git a/contrib/libs/grpc/test/core/util/run_with_poller.sh b/contrib/libs/grpc/test/core/util/run_with_poller.sh deleted file mode 100755 index 382a63e8ae..0000000000 --- a/contrib/libs/grpc/test/core/util/run_with_poller.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex -export GRPC_POLL_STRATEGY=$1 -shift -"$@" diff --git a/contrib/libs/grpc/test/core/util/slice_splitter.cc b/contrib/libs/grpc/test/core/util/slice_splitter.cc deleted file mode 100644 index 82864d6abf..0000000000 --- a/contrib/libs/grpc/test/core/util/slice_splitter.cc +++ /dev/null @@ -1,128 +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. - * - */ - -#include "test/core/util/slice_splitter.h" - -#include <string.h> - -#include <algorithm> - -#include <grpc/support/alloc.h> - -#include "src/core/lib/gpr/useful.h" - -const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) { - switch (mode) { - case GRPC_SLICE_SPLIT_IDENTITY: - return "identity"; - case GRPC_SLICE_SPLIT_MERGE_ALL: - return "merge_all"; - case GRPC_SLICE_SPLIT_ONE_BYTE: - return "one_byte"; - } - return "error"; -} - -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, - size_t src_slice_count, grpc_slice** dst_slices, - size_t* dst_slice_count) { - size_t i, j; - size_t length; - - switch (mode) { - case GRPC_SLICE_SPLIT_IDENTITY: - *dst_slice_count = src_slice_count; - *dst_slices = static_cast<grpc_slice*>( - gpr_malloc(sizeof(grpc_slice) * src_slice_count)); - for (i = 0; i < src_slice_count; i++) { - (*dst_slices)[i] = src_slices[i]; - grpc_slice_ref((*dst_slices)[i]); - } - break; - case GRPC_SLICE_SPLIT_MERGE_ALL: - *dst_slice_count = 1; - length = 0; - for (i = 0; i < src_slice_count; i++) { - length += GRPC_SLICE_LENGTH(src_slices[i]); - } - *dst_slices = static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice))); - **dst_slices = grpc_slice_malloc(length); - length = 0; - for (i = 0; i < src_slice_count; i++) { - memcpy(GRPC_SLICE_START_PTR(**dst_slices) + length, - GRPC_SLICE_START_PTR(src_slices[i]), - GRPC_SLICE_LENGTH(src_slices[i])); - length += GRPC_SLICE_LENGTH(src_slices[i]); - } - break; - case GRPC_SLICE_SPLIT_ONE_BYTE: - length = 0; - for (i = 0; i < src_slice_count; i++) { - length += GRPC_SLICE_LENGTH(src_slices[i]); - } - *dst_slice_count = length; - *dst_slices = - static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * length)); - length = 0; - for (i = 0; i < src_slice_count; i++) { - for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) { - (*dst_slices)[length] = grpc_slice_sub(src_slices[i], j, j + 1); - length++; - } - } - break; - } -} - -void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice* src_slices, size_t src_slice_count, - grpc_slice_buffer* dst) { - grpc_slice* slices; - size_t nslices; - size_t i; - grpc_split_slices(mode, src_slices, src_slice_count, &slices, &nslices); - for (i = 0; i < nslices; i++) { - /* add indexed to avoid re-merging split slices */ - grpc_slice_buffer_add_indexed(dst, slices[i]); - } - gpr_free(slices); -} - -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, - grpc_slice_buffer* dst) { - grpc_split_slices_to_buffer(mode, src->slices, src->count, dst); -} - -grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) { - uint8_t* out = nullptr; - size_t length = 0; - size_t capacity = 0; - size_t i; - - for (i = 0; i < nslices; i++) { - if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) { - capacity = std::max(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length); - out = static_cast<uint8_t*>(gpr_realloc(out, capacity)); - } - memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]), - GRPC_SLICE_LENGTH(slices[i])); - length += GRPC_SLICE_LENGTH(slices[i]); - } - - return grpc_slice_new(out, length, gpr_free); -} diff --git a/contrib/libs/grpc/test/core/util/slice_splitter.h b/contrib/libs/grpc/test/core/util/slice_splitter.h deleted file mode 100644 index 65b9f6f7df..0000000000 --- a/contrib/libs/grpc/test/core/util/slice_splitter.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H -#define GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H - -/* utility function to split/merge slices together to help create test - cases */ - -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> - -typedef enum { - /* merge all input slices into a single slice */ - GRPC_SLICE_SPLIT_MERGE_ALL, - /* leave slices as is */ - GRPC_SLICE_SPLIT_IDENTITY, - /* split slices into one byte chunks */ - GRPC_SLICE_SPLIT_ONE_BYTE -} grpc_slice_split_mode; - -/* allocates *dst_slices; caller must unref all slices in dst_slices then free - it */ -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, - size_t src_slice_count, grpc_slice** dst_slices, - size_t* dst_slice_count); - -void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice* src_slices, size_t src_slice_count, - grpc_slice_buffer* dst); -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, - grpc_slice_buffer* dst); - -grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices); - -const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode); - -#endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ diff --git a/contrib/libs/grpc/test/core/util/stack_tracer_test.cc b/contrib/libs/grpc/test/core/util/stack_tracer_test.cc deleted file mode 100644 index c610c96841..0000000000 --- a/contrib/libs/grpc/test/core/util/stack_tracer_test.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2020 the gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/core/util/stack_tracer.h" - -#include <util/generic/string.h> - -#include <gtest/gtest.h> - -#include "y_absl/debugging/symbolize.h" -#include "y_absl/strings/match.h" - -#include <grpc/support/log.h> - -#include "test/core/util/test_config.h" - -TEST(StackTracerTest, Basic) { - TString stack_trace = grpc_core::testing::GetCurrentStackTrace(); - gpr_log(GPR_INFO, "stack_trace=%s", stack_trace.c_str()); -#if !defined(NDEBUG) && !defined(GPR_MUSL_LIBC_COMPAT) - EXPECT_TRUE(y_absl::StrContains(stack_trace, "Basic")); -#endif -} - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/core/util/subprocess.h b/contrib/libs/grpc/test/core/util/subprocess.h deleted file mode 100644 index c7fe9af435..0000000000 --- a/contrib/libs/grpc/test/core/util/subprocess.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_SUBPROCESS_H -#define GRPC_TEST_CORE_UTIL_SUBPROCESS_H - -#include <grpc/support/port_platform.h> - -typedef struct gpr_subprocess gpr_subprocess; - -/** .exe on windows, empty on unices */ -const char* gpr_subprocess_binary_extension(); - -gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); -/** if subprocess has not been joined, kill it */ -void gpr_subprocess_destroy(gpr_subprocess* p); -/** returns exit status; can be called at most once */ -int gpr_subprocess_join(gpr_subprocess* p); -void gpr_subprocess_interrupt(gpr_subprocess* p); - -#endif /* GRPC_TEST_CORE_UTIL_SUBPROCESS_H */ diff --git a/contrib/libs/grpc/test/core/util/subprocess_posix.cc b/contrib/libs/grpc/test/core/util/subprocess_posix.cc deleted file mode 100644 index 6136314293..0000000000 --- a/contrib/libs/grpc/test/core/util/subprocess_posix.cc +++ /dev/null @@ -1,100 +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. - * - */ - -#include <grpc/support/port_platform.h> - -#ifdef GPR_POSIX_SUBPROCESS - -#include <assert.h> -#include <errno.h> -#include <signal.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/gprpp/memory.h" -#include "test/core/util/subprocess.h" - -struct gpr_subprocess { - int pid; - bool joined; -}; - -const char* gpr_subprocess_binary_extension() { return ""; } - -gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { - gpr_subprocess* r; - int pid; - char** exec_args; - - pid = fork(); - if (pid == -1) { - return nullptr; - } else if (pid == 0) { - exec_args = static_cast<char**>( - gpr_malloc((static_cast<size_t>(argc) + 1) * sizeof(char*))); - memcpy(exec_args, argv, static_cast<size_t>(argc) * sizeof(char*)); - exec_args[argc] = nullptr; - execv(exec_args[0], exec_args); - /* if we reach here, an error has occurred */ - gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno)); - _exit(1); - } else { - r = grpc_core::Zalloc<gpr_subprocess>(); - r->pid = pid; - return r; - } -} - -void gpr_subprocess_destroy(gpr_subprocess* p) { - if (!p->joined) { - kill(p->pid, SIGKILL); - gpr_subprocess_join(p); - } - gpr_free(p); -} - -int gpr_subprocess_join(gpr_subprocess* p) { - int status; -retry: - if (waitpid(p->pid, &status, 0) == -1) { - if (errno == EINTR) { - goto retry; - } - gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid, - strerror(errno)); - return -1; - } - p->joined = true; - return status; -} - -void gpr_subprocess_interrupt(gpr_subprocess* p) { - if (!p->joined) { - kill(p->pid, SIGINT); - } -} - -#endif /* GPR_POSIX_SUBPROCESS */ diff --git a/contrib/libs/grpc/test/core/util/subprocess_windows.cc b/contrib/libs/grpc/test/core/util/subprocess_windows.cc deleted file mode 100644 index 7d69af1368..0000000000 --- a/contrib/libs/grpc/test/core/util/subprocess_windows.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/support/port_platform.h> - -#ifdef GPR_WINDOWS_SUBPROCESS - -#include <string.h> -#include <tchar.h> -#include <windows.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> - -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/string_windows.h" -#include "test/core/util/subprocess.h" - -struct gpr_subprocess { - PROCESS_INFORMATION pi; - int joined; - int interrupted; -}; - -const char* gpr_subprocess_binary_extension() { return ".exe"; } - -gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { - gpr_subprocess* r; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - char* args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); - TCHAR* args_tchar; - - args_tchar = gpr_char_to_tchar(args); - gpr_free(args); - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - memset(&pi, 0, sizeof(pi)); - - if (!CreateProcess(NULL, args_tchar, NULL, NULL, FALSE, - CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { - gpr_free(args_tchar); - return NULL; - } - gpr_free(args_tchar); - - r = (gpr_subprocess*)gpr_malloc(sizeof(gpr_subprocess)); - memset(r, 0, sizeof(*r)); - r->pi = pi; - return r; -} - -void gpr_subprocess_destroy(gpr_subprocess* p) { - if (p) { - if (!p->joined) { - gpr_subprocess_interrupt(p); - gpr_subprocess_join(p); - } - if (p->pi.hProcess) { - CloseHandle(p->pi.hProcess); - } - if (p->pi.hThread) { - CloseHandle(p->pi.hThread); - } - gpr_free(p); - } -} - -int gpr_subprocess_join(gpr_subprocess* p) { - DWORD dwExitCode; - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - if (dwExitCode == STILL_ACTIVE) { - if (WaitForSingleObject(p->pi.hProcess, INFINITE) == WAIT_OBJECT_0) { - p->joined = 1; - goto getExitCode; - } - return -1; // failed to join - } else { - goto getExitCode; - } - } else { - return -1; // failed to get exit code - } - -getExitCode: - if (p->interrupted) { - return 0; - } - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - return (int)dwExitCode; - } else { - return -1; // failed to get exit code - } -} - -void gpr_subprocess_interrupt(gpr_subprocess* p) { - DWORD dwExitCode; - if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - if (dwExitCode == STILL_ACTIVE) { - gpr_log(GPR_INFO, "sending ctrl-break"); - GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, p->pi.dwProcessId); - p->joined = 1; - p->interrupted = 1; - } - } - return; -} - -#endif /* GPR_WINDOWS_SUBPROCESS */ diff --git a/contrib/libs/grpc/test/core/util/test_tcp_server.cc b/contrib/libs/grpc/test/core/util/test_tcp_server.cc deleted file mode 100644 index 57d6c21374..0000000000 --- a/contrib/libs/grpc/test/core/util/test_tcp_server.cc +++ /dev/null @@ -1,122 +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. - * - */ - -#include "test/core/util/test_tcp_server.h" - -#include <string.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/sync.h> -#include <grpc/support/time.h> - -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/iomgr/socket_utils.h" -#include "src/core/lib/iomgr/tcp_server.h" -#include "src/core/lib/resource_quota/api.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -static void on_server_destroyed(void* data, grpc_error_handle /*error*/) { - test_tcp_server* server = static_cast<test_tcp_server*>(data); - server->shutdown = true; -} - -void test_tcp_server_init(test_tcp_server* server, - grpc_tcp_server_cb on_connect, void* user_data) { - grpc_init(); - GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server, - grpc_schedule_on_exec_ctx); - - grpc_pollset* pollset = - static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); - grpc_pollset_init(pollset, &server->mu); - server->pollset.push_back(pollset); - server->on_connect = on_connect; - server->cb_data = user_data; -} - -void test_tcp_server_start(test_tcp_server* server, int port) { - grpc_resolved_address resolved_addr; - grpc_sockaddr_in* addr = - reinterpret_cast<grpc_sockaddr_in*>(resolved_addr.addr); - int port_added; - grpc_core::ExecCtx exec_ctx; - - addr->sin_family = GRPC_AF_INET; - addr->sin_port = grpc_htons(static_cast<uint16_t>(port)); - memset(&addr->sin_addr, 0, sizeof(addr->sin_addr)); - resolved_addr.len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in)); - - const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(nullptr); - grpc_error_handle error = grpc_tcp_server_create(&server->shutdown_complete, - args, &server->tcp_server); - grpc_channel_args_destroy(args); - GPR_ASSERT(error == GRPC_ERROR_NONE); - error = - grpc_tcp_server_add_port(server->tcp_server, &resolved_addr, &port_added); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(port_added == port); - - grpc_tcp_server_start(server->tcp_server, &server->pollset, - server->on_connect, server->cb_data); - gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port); -} - -void test_tcp_server_poll(test_tcp_server* server, int milliseconds) { - grpc_pollset_worker* worker = nullptr; - grpc_core::ExecCtx exec_ctx; - grpc_millis deadline = grpc_timespec_to_millis_round_up( - grpc_timeout_milliseconds_to_deadline(milliseconds)); - gpr_mu_lock(server->mu); - GRPC_LOG_IF_ERROR("pollset_work", - grpc_pollset_work(server->pollset[0], &worker, deadline)); - gpr_mu_unlock(server->mu); -} - -static void do_nothing(void* /*arg*/, grpc_error_handle /*error*/) {} -static void finish_pollset(void* arg, grpc_error_handle /*error*/) { - grpc_pollset_destroy(static_cast<grpc_pollset*>(arg)); -} - -void test_tcp_server_destroy(test_tcp_server* server) { - grpc_core::ExecCtx exec_ctx; - gpr_timespec shutdown_deadline; - grpc_closure do_nothing_cb; - grpc_tcp_server_unref(server->tcp_server); - GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr, - grpc_schedule_on_exec_ctx); - shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(5, GPR_TIMESPAN)); - grpc_core::ExecCtx::Get()->Flush(); - while (!server->shutdown && - gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) { - test_tcp_server_poll(server, 1000); - } - grpc_pollset_shutdown(server->pollset[0], - GRPC_CLOSURE_CREATE(finish_pollset, server->pollset[0], - grpc_schedule_on_exec_ctx)); - grpc_core::ExecCtx::Get()->Flush(); - gpr_free(server->pollset[0]); - grpc_shutdown(); -} diff --git a/contrib/libs/grpc/test/core/util/test_tcp_server.h b/contrib/libs/grpc/test/core/util/test_tcp_server.h deleted file mode 100644 index a06dde8ace..0000000000 --- a/contrib/libs/grpc/test/core/util/test_tcp_server.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H -#define GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H - -#include <vector> - -#include <grpc/support/sync.h> - -#include "src/core/lib/iomgr/tcp_server.h" - -// test_tcp_server should be stack-allocated or new'ed, never gpr_malloc'ed -// since it contains C++ objects. -struct test_tcp_server { - grpc_tcp_server* tcp_server = nullptr; - grpc_closure shutdown_complete; - bool shutdown = false; - // mu is filled in by grpc_pollset_init and controls the pollset. - // TODO(unknown): Switch this to a Mutex once pollset_init can provide a Mutex - gpr_mu* mu; - std::vector<grpc_pollset*> pollset; - grpc_tcp_server_cb on_connect; - void* cb_data; -}; - -void test_tcp_server_init(test_tcp_server* server, - grpc_tcp_server_cb on_connect, void* user_data); -void test_tcp_server_start(test_tcp_server* server, int port); -void test_tcp_server_poll(test_tcp_server* server, int milliseconds); -void test_tcp_server_destroy(test_tcp_server* server); - -#endif /* GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H */ diff --git a/contrib/libs/grpc/test/core/util/tls_utils.cc b/contrib/libs/grpc/test/core/util/tls_utils.cc deleted file mode 100644 index 7f2fd0c126..0000000000 --- a/contrib/libs/grpc/test/core/util/tls_utils.cc +++ /dev/null @@ -1,172 +0,0 @@ -// -// Copyright 2020 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "test/core/util/tls_utils.h" - -#include <grpc/support/log.h> - -#include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/iomgr/load_file.h" -#include "src/core/lib/slice/slice_internal.h" - -namespace grpc_core { - -namespace testing { - -TmpFile::TmpFile(y_absl::string_view data) { - name_ = CreateTmpFileAndWriteData(data); - GPR_ASSERT(!name_.empty()); -} - -TmpFile::~TmpFile() { GPR_ASSERT(remove(name_.c_str()) == 0); } - -void TmpFile::RewriteFile(y_absl::string_view data) { - // Create a new file containing new data. - TString new_name = CreateTmpFileAndWriteData(data); - GPR_ASSERT(!new_name.empty()); - // Remove the old file. - GPR_ASSERT(remove(name_.c_str()) == 0); - // Rename the new file to the original name. - GPR_ASSERT(rename(new_name.c_str(), name_.c_str()) == 0); -} - -TString TmpFile::CreateTmpFileAndWriteData(y_absl::string_view data) { - char* name = nullptr; - FILE* file_descriptor = gpr_tmpfile("test", &name); - GPR_ASSERT(fwrite(data.data(), 1, data.size(), file_descriptor) == - data.size()); - GPR_ASSERT(fclose(file_descriptor) == 0); - GPR_ASSERT(file_descriptor != nullptr); - GPR_ASSERT(name != nullptr); - TString name_to_return = name; - gpr_free(name); - return name_to_return; -} - -PemKeyCertPairList MakeCertKeyPairs(y_absl::string_view private_key, - y_absl::string_view certs) { - if (private_key.empty() && certs.empty()) { - return {}; - } - return PemKeyCertPairList{PemKeyCertPair(private_key, certs)}; -} - -TString GetFileContents(const char* path) { - grpc_slice slice = grpc_empty_slice(); - GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", grpc_load_file(path, 0, &slice))); - TString data = TString(StringViewFromSlice(slice)); - grpc_slice_unref(slice); - return data; -} - -int SyncExternalVerifier::Verify(void* user_data, - grpc_tls_custom_verification_check_request*, - grpc_tls_on_custom_verification_check_done_cb, - void*, grpc_status_code* sync_status, - char** sync_error_details) { - auto* self = static_cast<SyncExternalVerifier*>(user_data); - if (self->success_) { - *sync_status = GRPC_STATUS_OK; - return true; // Synchronous call - } - *sync_status = GRPC_STATUS_UNAUTHENTICATED; - *sync_error_details = gpr_strdup("SyncExternalVerifier failed"); - return true; // Synchronous call -} - -void SyncExternalVerifier::Destruct(void* user_data) { - auto* self = static_cast<SyncExternalVerifier*>(user_data); - delete self; -} - -AsyncExternalVerifier::~AsyncExternalVerifier() { - // Tell the thread to shut down. - { - MutexLock lock(&mu_); - queue_.push_back(Request{nullptr, nullptr, nullptr, true}); - } - // Wait for thread to exit. - thread_.Join(); - grpc_shutdown(); -} - -int AsyncExternalVerifier::Verify( - void* user_data, grpc_tls_custom_verification_check_request* request, - grpc_tls_on_custom_verification_check_done_cb callback, void* callback_arg, - grpc_status_code*, char**) { - auto* self = static_cast<AsyncExternalVerifier*>(user_data); - // Add request to queue to be picked up by worker thread. - MutexLock lock(&self->mu_); - self->queue_.push_back(Request{request, callback, callback_arg, false}); - return false; // Asynchronous call -} - -namespace { - -void DestroyExternalVerifier(void* arg) { - auto* verifier = static_cast<AsyncExternalVerifier*>(arg); - delete verifier; -} - -} // namespace - -void AsyncExternalVerifier::Destruct(void* user_data) { - auto* self = static_cast<AsyncExternalVerifier*>(user_data); - // Spawn a detached thread to destroy the verifier, to make sure that we don't - // try to join the worker thread from within the worker thread. - Thread destroy_thread("DestroyExternalVerifier", DestroyExternalVerifier, - self, nullptr, Thread::Options().set_joinable(false)); - destroy_thread.Start(); -} - -void AsyncExternalVerifier::WorkerThread(void* arg) { - auto* self = static_cast<AsyncExternalVerifier*>(arg); - while (true) { - // Check queue for work. - bool got_request = false; - Request request; - { - MutexLock lock(&self->mu_); - if (!self->queue_.empty()) { - got_request = true; - request = self->queue_.front(); - self->queue_.pop_front(); - } - } - // If nothing found in the queue, sleep for a bit and try again. - if (!got_request) { - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); - continue; - } - // If we're being told to shut down, return. - if (request.shutdown) { - return; - } - // Process the request. - if (self->success_) { - request.callback(request.request, request.callback_arg, GRPC_STATUS_OK, - ""); - } else { - request.callback(request.request, request.callback_arg, - GRPC_STATUS_UNAUTHENTICATED, - "AsyncExternalVerifier failed"); - } - } -} - -} // namespace testing - -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/tls_utils.h b/contrib/libs/grpc/test/core/util/tls_utils.h deleted file mode 100644 index be88a804e3..0000000000 --- a/contrib/libs/grpc/test/core/util/tls_utils.h +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright 2020 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include <deque> - -#include "src/core/lib/gprpp/thd.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" -#include "test/core/util/test_config.h" - -namespace grpc_core { - -namespace testing { - -class TmpFile { - public: - // Create a temporary file with |data| written in. - explicit TmpFile(y_absl::string_view data); - - ~TmpFile(); - - const TString& name() { return name_; } - - // Rewrite |data| to the temporary file, in an atomic way. - void RewriteFile(y_absl::string_view data); - - private: - TString CreateTmpFileAndWriteData(y_absl::string_view data); - - TString name_; -}; - -PemKeyCertPairList MakeCertKeyPairs(y_absl::string_view private_key, - y_absl::string_view certs); - -TString GetFileContents(const char* path); - -// A synchronous external verifier implementation that simply returns -// verification results based on users' inputs. Note that it will delete itself -// in Destruct(), so create it like -// ``` -// auto* sync_verifier_ = new SyncExternalVerifier(false); -// ``` -// and no need to delete it later. This is basically to keep consistent with the -// semantics in AsyncExternalVerifier. -class SyncExternalVerifier { - public: - explicit SyncExternalVerifier(bool success) - : success_(success), base_{this, Verify, Cancel, Destruct} {} - - grpc_tls_certificate_verifier_external* base() { return &base_; } - - private: - static int Verify(void* user_data, - grpc_tls_custom_verification_check_request* request, - grpc_tls_on_custom_verification_check_done_cb callback, - void* callback_arg, grpc_status_code* sync_status, - char** sync_error_details); - - static void Cancel(void*, grpc_tls_custom_verification_check_request*) {} - - static void Destruct(void* user_data); - - bool success_ = false; - grpc_tls_certificate_verifier_external base_; -}; - -// An asynchronous external verifier implementation that runs a thread and -// process each request received from the verifier sequentially. Note that it -// will delete itself in Destruct(), so create it like -// ``` -// auto* async_verifier = new AsyncExternalVerifier(true, &event); -// auto* core_external_verifier = -// new ExternalCertificateVerifier(async_verifier->base()); -// ``` -// and no need to delete it later. -// We delete AsyncExternalVerifier in Destruct() instead of its dtor because we -// wanted AsyncExternalVerifier to outlive the underlying core -// ExternalCertificateVerifier implementation. -class AsyncExternalVerifier { - public: - explicit AsyncExternalVerifier(bool success) - : success_(success), - thread_("AsyncExternalVerifierWorkerThread", WorkerThread, this), - base_{this, Verify, Cancel, Destruct} { - grpc_init(); - thread_.Start(); - } - - ~AsyncExternalVerifier(); - - grpc_tls_certificate_verifier_external* base() { return &base_; } - - private: - // A request to pass to the worker thread. - struct Request { - grpc_tls_custom_verification_check_request* request; - grpc_tls_on_custom_verification_check_done_cb callback; - void* callback_arg; - bool shutdown; // If true, thread will exit. - }; - - static int Verify(void* user_data, - grpc_tls_custom_verification_check_request* request, - grpc_tls_on_custom_verification_check_done_cb callback, - void* callback_arg, grpc_status_code* sync_status, - char** sync_error_details); - - static void Cancel(void*, grpc_tls_custom_verification_check_request*) {} - - static void Destruct(void* user_data); - - static void WorkerThread(void* arg); - - bool success_ = false; - Thread thread_; - grpc_tls_certificate_verifier_external base_; - Mutex mu_; - std::deque<Request> queue_ Y_ABSL_GUARDED_BY(mu_); -}; - -} // namespace testing - -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/tracer_util.cc b/contrib/libs/grpc/test/core/util/tracer_util.cc deleted file mode 100644 index df42eb921e..0000000000 --- a/contrib/libs/grpc/test/core/util/tracer_util.cc +++ /dev/null @@ -1,28 +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. - * - */ - -#include "src/core/lib/debug/trace.h" -#include "test/core/util/test_config.h" - -namespace grpc_core { -namespace testing { - -void grpc_tracer_enable_flag(TraceFlag* flag) { flag->set_enabled(true); } - -} // namespace testing -} // namespace grpc_core diff --git a/contrib/libs/grpc/test/core/util/tracer_util.h b/contrib/libs/grpc/test/core/util/tracer_util.h deleted file mode 100644 index 7f9aa151ed..0000000000 --- a/contrib/libs/grpc/test/core/util/tracer_util.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_TRACER_UTIL_H -#define GRPC_TEST_CORE_UTIL_TRACER_UTIL_H - -namespace grpc_core { -class TraceFlag; - -namespace testing { -// enables the TraceFlag passed to it. Used for testing purposes. -void grpc_tracer_enable_flag(TraceFlag* flag); - -} // namespace testing -} // namespace grpc_core - -#endif /* GRPC_TEST_CORE_UTIL_TRACER_UTIL_H */ diff --git a/contrib/libs/grpc/test/cpp/end2end/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/test/cpp/end2end/.yandex_meta/licenses.list.txt deleted file mode 100644 index 4851cba93f..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,58 +0,0 @@ -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2019 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2019 The gRPC Authors - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. diff --git a/contrib/libs/grpc/test/cpp/end2end/admin_services_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/admin_services_end2end_test.cc deleted file mode 100644 index 79bac431ae..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/admin_services_end2end_test.cc +++ /dev/null @@ -1,101 +0,0 @@ -// -// -// 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. -// -// - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/strings/str_cat.h" - -#include <grpcpp/ext/admin_services.h> -#include <grpcpp/ext/proto_server_reflection_plugin.h> -#include <grpcpp/grpcpp.h> - -#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -namespace grpc { -namespace testing { - -class AdminServicesTest : public ::testing::Test { - public: - void SetUp() override { - TString address = - y_absl::StrCat("localhost:", grpc_pick_unused_port_or_die()); - // Create admin server - grpc::reflection::InitProtoReflectionServerBuilderPlugin(); - ServerBuilder builder; - builder.AddListeningPort(address, InsecureServerCredentials()); - ::grpc::AddAdminServices(&builder); - server_ = builder.BuildAndStart(); - // Create channel - auto reflection_stub = reflection::v1alpha::ServerReflection::NewStub( - CreateChannel(address, InsecureChannelCredentials())); - stream_ = reflection_stub->ServerReflectionInfo(&reflection_ctx_); - } - - std::vector<TString> GetServiceList() { - std::vector<TString> services; - reflection::v1alpha::ServerReflectionRequest request; - reflection::v1alpha::ServerReflectionResponse response; - request.set_list_services(""); - stream_->Write(request); - stream_->Read(&response); - for (auto& service : response.list_services_response().service()) { - services.push_back(service.name()); - } - return services; - } - - private: - std::unique_ptr<Server> server_; - ClientContext reflection_ctx_; - std::shared_ptr< - ClientReaderWriter<reflection::v1alpha::ServerReflectionRequest, - reflection::v1alpha::ServerReflectionResponse>> - stream_; -}; - -TEST_F(AdminServicesTest, ValidateRegisteredServices) { - // Using Contains here, because the server builder might register other - // services in certain environments. - EXPECT_THAT( - GetServiceList(), - ::testing::AllOf( - ::testing::Contains("grpc.channelz.v1.Channelz"), - ::testing::Contains("grpc.reflection.v1alpha.ServerReflection"))); -#if defined(GRPC_NO_XDS) || defined(DISABLED_XDS_PROTO_IN_CC) - EXPECT_THAT(GetServiceList(), - ::testing::Not(::testing::Contains( - "envoy.service.status.v3.ClientStatusDiscoveryService"))); -#else - EXPECT_THAT(GetServiceList(), - ::testing::Contains( - "envoy.service.status.v3.ClientStatusDiscoveryService")); -#endif // GRPC_NO_XDS or DISABLED_XDS_PROTO_IN_CC -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/async_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/async_end2end_test.cc deleted file mode 100644 index 24bc20fc17..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/async_end2end_test.cc +++ /dev/null @@ -1,1953 +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. - * - */ - -#include <cinttypes> -#include <memory> -#include <thread> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/health_check_service_server_builder_option.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/tls.h" -#include "src/core/lib/iomgr/port.h" -#include "src/proto/grpc/health/v1/health.grpc.pb.h" -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/string_ref_helper.h" -#include "test/cpp/util/test_credentials_provider.h" - -#ifdef GRPC_POSIX_SOCKET_EV -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET_EV - -#include <gtest/gtest.h> - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; -using std::chrono::system_clock; - -namespace grpc { -namespace testing { - -namespace { - -void* tag(int t) { return reinterpret_cast<void*>(t); } -int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); } - -class Verifier { - public: - Verifier() : lambda_run_(false) {} - // Expect sets the expected ok value for a specific tag - Verifier& Expect(int i, bool expect_ok) { - return ExpectUnless(i, expect_ok, false); - } - // ExpectUnless sets the expected ok value for a specific tag - // unless the tag was already marked seen (as a result of ExpectMaybe) - Verifier& ExpectUnless(int i, bool expect_ok, bool seen) { - if (!seen) { - expectations_[tag(i)] = expect_ok; - } - return *this; - } - // ExpectMaybe sets the expected ok value for a specific tag, but does not - // require it to appear - // If it does, sets *seen to true - Verifier& ExpectMaybe(int i, bool expect_ok, bool* seen) { - if (!*seen) { - maybe_expectations_[tag(i)] = MaybeExpect{expect_ok, seen}; - } - return *this; - } - - // Next waits for 1 async tag to complete, checks its - // expectations, and returns the tag - int Next(CompletionQueue* cq, bool ignore_ok) { - bool ok; - void* got_tag; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - GotTag(got_tag, ok, ignore_ok); - return detag(got_tag); - } - - template <typename T> - CompletionQueue::NextStatus DoOnceThenAsyncNext( - CompletionQueue* cq, void** got_tag, bool* ok, T deadline, - std::function<void(void)> lambda) { - if (lambda_run_) { - return cq->AsyncNext(got_tag, ok, deadline); - } else { - lambda_run_ = true; - return cq->DoThenAsyncNext(lambda, got_tag, ok, deadline); - } - } - - // Verify keeps calling Next until all currently set - // expected tags are complete - void Verify(CompletionQueue* cq) { Verify(cq, false); } - - // This version of Verify allows optionally ignoring the - // outcome of the expectation - void Verify(CompletionQueue* cq, bool ignore_ok) { - GPR_ASSERT(!expectations_.empty() || !maybe_expectations_.empty()); - while (!expectations_.empty()) { - Next(cq, ignore_ok); - } - maybe_expectations_.clear(); - } - - // This version of Verify stops after a certain deadline - void Verify(CompletionQueue* cq, - std::chrono::system_clock::time_point deadline) { - if (expectations_.empty()) { - bool ok; - void* got_tag; - EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), - CompletionQueue::TIMEOUT); - } else { - while (!expectations_.empty()) { - bool ok; - void* got_tag; - EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), - CompletionQueue::GOT_EVENT); - GotTag(got_tag, ok, false); - } - } - maybe_expectations_.clear(); - } - - // This version of Verify stops after a certain deadline, and uses the - // DoThenAsyncNext API - // to call the lambda - void Verify(CompletionQueue* cq, - std::chrono::system_clock::time_point deadline, - const std::function<void(void)>& lambda) { - if (expectations_.empty()) { - bool ok; - void* got_tag; - EXPECT_EQ(DoOnceThenAsyncNext(cq, &got_tag, &ok, deadline, lambda), - CompletionQueue::TIMEOUT); - } else { - while (!expectations_.empty()) { - bool ok; - void* got_tag; - EXPECT_EQ(DoOnceThenAsyncNext(cq, &got_tag, &ok, deadline, lambda), - CompletionQueue::GOT_EVENT); - GotTag(got_tag, ok, false); - } - } - maybe_expectations_.clear(); - } - - private: - void GotTag(void* got_tag, bool ok, bool ignore_ok) { - auto it = expectations_.find(got_tag); - if (it != expectations_.end()) { - if (!ignore_ok) { - EXPECT_EQ(it->second, ok); - } - expectations_.erase(it); - } else { - auto it2 = maybe_expectations_.find(got_tag); - if (it2 != maybe_expectations_.end()) { - if (it2->second.seen != nullptr) { - EXPECT_FALSE(*it2->second.seen); - *it2->second.seen = true; - } - if (!ignore_ok) { - EXPECT_EQ(it2->second.ok, ok); - } - maybe_expectations_.erase(it2); - } else { - gpr_log(GPR_ERROR, "Unexpected tag: %p", got_tag); - abort(); - } - } - } - - struct MaybeExpect { - bool ok; - bool* seen; - }; - - std::map<void*, bool> expectations_; - std::map<void*, MaybeExpect> maybe_expectations_; - bool lambda_run_; -}; - -bool plugin_has_sync_methods(std::unique_ptr<ServerBuilderPlugin>& plugin) { - return plugin->has_sync_methods(); -} - -// This class disables the server builder plugins that may add sync services to -// the server. If there are sync services, UnimplementedRpc test will triger -// the sync unknown rpc routine on the server side, rather than the async one -// that needs to be tested here. -class ServerBuilderSyncPluginDisabler : public ::grpc::ServerBuilderOption { - public: - void UpdateArguments(ChannelArguments* /*arg*/) override {} - - void UpdatePlugins( - std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) override { - plugins->erase(std::remove_if(plugins->begin(), plugins->end(), - plugin_has_sync_methods), - plugins->end()); - } -}; - -class TestScenario { - public: - TestScenario(bool inproc_stub, const TString& creds_type, bool hcs, - const TString& content) - : inproc(inproc_stub), - health_check_service(hcs), - credentials_type(creds_type), - message_content(content) {} - void Log() const; - bool inproc; - bool health_check_service; - const TString credentials_type; - const TString message_content; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{inproc=" << (scenario.inproc ? "true" : "false") - << ", credentials='" << scenario.credentials_type - << ", health_check_service=" - << (scenario.health_check_service ? "true" : "false") - << "', message_size=" << scenario.message_content.size() << "}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_DEBUG, "%s", out.str().c_str()); -} - -class HealthCheck : public health::v1::Health::Service {}; - -class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> { - protected: - AsyncEnd2endTest() { GetParam().Log(); } - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port_; - - // Setup server - BuildAndStartServer(); - } - - void TearDown() override { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cq_->Shutdown(); - while (cq_->Next(&ignored_tag, &ignored_ok)) { - } - stub_.reset(); - grpc_recycle_unused_port(port_); - } - - void BuildAndStartServer() { - ServerBuilder builder; - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - builder.AddListeningPort(server_address_.str(), server_creds); - service_ = - y_absl::make_unique<grpc::testing::EchoTestService::AsyncService>(); - builder.RegisterService(service_.get()); - if (GetParam().health_check_service) { - builder.RegisterService(&health_check_); - } - cq_ = builder.AddCompletionQueue(); - - // TODO(zyc): make a test option to choose wheather sync plugins should be - // deleted - std::unique_ptr<ServerBuilderOption> sync_plugin_disabler( - new ServerBuilderSyncPluginDisabler()); - builder.SetOption(move(sync_plugin_disabler)); - server_ = builder.BuildAndStart(); - } - - void ResetStub() { - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - std::shared_ptr<Channel> channel = - !(GetParam().inproc) ? ::grpc::CreateCustomChannel( - server_address_.str(), channel_creds, args) - : server_->InProcessChannel(args); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - void SendRpc(int num_rpcs) { - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, - cq_.get(), cq_.get(), tag(2)); - - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - } - - std::unique_ptr<ServerCompletionQueue> cq_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::unique_ptr<grpc::testing::EchoTestService::AsyncService> service_; - HealthCheck health_check_; - std::ostringstream server_address_; - int port_; -}; - -TEST_P(AsyncEnd2endTest, SimpleRpc) { - ResetStub(); - SendRpc(1); -} - -TEST_P(AsyncEnd2endTest, SimpleRpcWithExpectedError) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - ErrorStatus error_status; - - send_request.set_message(GetParam().message_content); - error_status.set_code(1); // CANCELLED - error_status.set_error_message("cancel error message"); - *send_request.mutable_param()->mutable_expected_error() = error_status; - - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - - srv_ctx.AsyncNotifyWhenDone(tag(5)); - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - response_writer.Finish( - send_response, - Status( - static_cast<StatusCode>(recv_request.param().expected_error().code()), - recv_request.param().expected_error().error_message()), - tag(3)); - Verifier().Expect(3, true).Expect(4, true).Expect(5, true).Verify(cq_.get()); - - EXPECT_EQ(recv_response.message(), ""); - EXPECT_EQ(recv_status.error_code(), error_status.code()); - EXPECT_EQ(recv_status.error_message(), error_status.error_message()); - EXPECT_FALSE(srv_ctx.IsCancelled()); -} - -TEST_P(AsyncEnd2endTest, SequentialRpcs) { - ResetStub(); - SendRpc(10); -} - -TEST_P(AsyncEnd2endTest, ReconnectChannel) { - // GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS is set to 100ms in main() - if (GetParam().inproc) { - return; - } - int poller_slowdown_factor = 1; -#ifdef GRPC_POSIX_SOCKET_EV - // It needs 2 pollset_works to reconnect the channel with polling engine - // "poll" - grpc_core::UniquePtr<char> poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { - poller_slowdown_factor = 2; - } -#endif // GRPC_POSIX_SOCKET_EV - ResetStub(); - SendRpc(1); - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cq_->Shutdown(); - while (cq_->Next(&ignored_tag, &ignored_ok)) { - } - BuildAndStartServer(); - // It needs more than GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS time to - // reconnect the channel. - gpr_sleep_until(gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis( - 300 * poller_slowdown_factor * grpc_test_slowdown_factor(), - GPR_TIMESPAN))); - SendRpc(1); -} - -// We do not need to protect notify because the use is synchronized. -void ServerWait(Server* server, int* notify) { - server->Wait(); - *notify = 1; -} -TEST_P(AsyncEnd2endTest, WaitAndShutdownTest) { - int notify = 0; - std::thread wait_thread(&ServerWait, server_.get(), ¬ify); - ResetStub(); - SendRpc(1); - EXPECT_EQ(0, notify); - server_->Shutdown(); - wait_thread.join(); - EXPECT_EQ(1, notify); -} - -TEST_P(AsyncEnd2endTest, ShutdownThenWait) { - ResetStub(); - SendRpc(1); - std::thread t([this]() { server_->Shutdown(); }); - server_->Wait(); - t.join(); -} - -// Test a simple RPC using the async version of Next -TEST_P(AsyncEnd2endTest, AsyncNextRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - - std::chrono::system_clock::time_point time_now( - std::chrono::system_clock::now()); - std::chrono::system_clock::time_point time_limit( - std::chrono::system_clock::now() + std::chrono::seconds(10)); - Verifier().Verify(cq_.get(), time_now); - Verifier().Verify(cq_.get(), time_now); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - Verifier().Expect(2, true).Verify(cq_.get(), time_limit); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify( - cq_.get(), std::chrono::system_clock::time_point::max()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -// Test a simple RPC using the async version of Next -TEST_P(AsyncEnd2endTest, DoThenAsyncNextRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - - std::chrono::system_clock::time_point time_now( - std::chrono::system_clock::now()); - std::chrono::system_clock::time_point time_limit( - std::chrono::system_clock::now() + std::chrono::seconds(10)); - Verifier().Verify(cq_.get(), time_now); - Verifier().Verify(cq_.get(), time_now); - - auto resp_writer_ptr = &response_writer; - auto lambda_2 = [&, this, resp_writer_ptr]() { - service_->RequestEcho(&srv_ctx, &recv_request, resp_writer_ptr, cq_.get(), - cq_.get(), tag(2)); - }; - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - Verifier().Expect(2, true).Verify(cq_.get(), time_limit, lambda_2); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - auto lambda_3 = [resp_writer_ptr, send_response]() { - resp_writer_ptr->Finish(send_response, Status::OK, tag(3)); - }; - Verifier().Expect(3, true).Expect(4, true).Verify( - cq_.get(), std::chrono::system_clock::time_point::max(), lambda_3); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -// Two pings and a final pong. -TEST_P(AsyncEnd2endTest, SimpleClientStreaming) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( - stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1))); - - service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - Verifier().Expect(2, true).Expect(1, true).Verify(cq_.get()); - - cli_stream->Write(send_request, tag(3)); - srv_stream.Read(&recv_request, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - cli_stream->Write(send_request, tag(5)); - srv_stream.Read(&recv_request, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - EXPECT_EQ(send_request.message(), recv_request.message()); - cli_stream->WritesDone(tag(7)); - srv_stream.Read(&recv_request, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - send_response.set_message(recv_request.message()); - srv_stream.Finish(send_response, Status::OK, tag(9)); - cli_stream->Finish(&recv_status, tag(10)); - Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -// Two pings and a final pong. -TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - cli_ctx.set_initial_metadata_corked(true); - // tag:1 never comes up since no op is performed - std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( - stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1))); - - service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - cli_stream->Write(send_request, tag(3)); - - bool seen3 = false; - - Verifier().Expect(2, true).ExpectMaybe(3, true, &seen3).Verify(cq_.get()); - - srv_stream.Read(&recv_request, tag(4)); - - Verifier().ExpectUnless(3, true, seen3).Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(send_request.message(), recv_request.message()); - - cli_stream->WriteLast(send_request, WriteOptions(), tag(5)); - srv_stream.Read(&recv_request, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - srv_stream.Read(&recv_request, tag(7)); - Verifier().Expect(7, false).Verify(cq_.get()); - - send_response.set_message(recv_request.message()); - srv_stream.Finish(send_response, Status::OK, tag(8)); - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(8, true).Expect(9, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, two pongs. -TEST_P(AsyncEnd2endTest, SimpleServerStreaming) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - srv_stream.Write(send_response, tag(3)); - cli_stream->Read(&recv_response, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - srv_stream.Write(send_response, tag(5)); - cli_stream->Read(&recv_response, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - srv_stream.Finish(Status::OK, tag(7)); - cli_stream->Read(&recv_response, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, two pongs. Using WriteAndFinish API -TEST_P(AsyncEnd2endTest, SimpleServerStreamingWithCoalescingApiWAF) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - srv_stream.Write(send_response, tag(3)); - cli_stream->Read(&recv_response, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - srv_stream.WriteAndFinish(send_response, WriteOptions(), Status::OK, tag(5)); - cli_stream->Read(&recv_response, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->Read(&recv_response, tag(7)); - Verifier().Expect(7, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(8)); - Verifier().Expect(8, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, two pongs. Using WriteLast API -TEST_P(AsyncEnd2endTest, SimpleServerStreamingWithCoalescingApiWL) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - srv_stream.Write(send_response, tag(3)); - cli_stream->Read(&recv_response, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - srv_stream.WriteLast(send_response, WriteOptions(), tag(5)); - cli_stream->Read(&recv_response, tag(6)); - srv_stream.Finish(Status::OK, tag(7)); - Verifier().Expect(5, true).Expect(6, true).Expect(7, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->Read(&recv_response, tag(8)); - Verifier().Expect(8, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, one pong. -TEST_P(AsyncEnd2endTest, SimpleBidiStreaming) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> - cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); - - service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - - cli_stream->Write(send_request, tag(3)); - srv_stream.Read(&recv_request, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - srv_stream.Write(send_response, tag(5)); - cli_stream->Read(&recv_response, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->WritesDone(tag(7)); - srv_stream.Read(&recv_request, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - srv_stream.Finish(Status::OK, tag(9)); - cli_stream->Finish(&recv_status, tag(10)); - Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, one pong. Using server:WriteAndFinish api -TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - cli_ctx.set_initial_metadata_corked(true); - std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> - cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); - - service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); - - bool seen3 = false; - - Verifier().Expect(2, true).ExpectMaybe(3, true, &seen3).Verify(cq_.get()); - - srv_stream.Read(&recv_request, tag(4)); - - Verifier().ExpectUnless(3, true, seen3).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - srv_stream.Read(&recv_request, tag(5)); - Verifier().Expect(5, false).Verify(cq_.get()); - - send_response.set_message(recv_request.message()); - srv_stream.WriteAndFinish(send_response, WriteOptions(), Status::OK, tag(6)); - cli_stream->Read(&recv_response, tag(7)); - Verifier().Expect(6, true).Expect(7, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->Finish(&recv_status, tag(8)); - Verifier().Expect(8, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// One ping, one pong. Using server:WriteLast api -TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - cli_ctx.set_initial_metadata_corked(true); - std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> - cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); - - service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); - - bool seen3 = false; - - Verifier().Expect(2, true).ExpectMaybe(3, true, &seen3).Verify(cq_.get()); - - srv_stream.Read(&recv_request, tag(4)); - - Verifier().ExpectUnless(3, true, seen3).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - srv_stream.Read(&recv_request, tag(5)); - Verifier().Expect(5, false).Verify(cq_.get()); - - send_response.set_message(recv_request.message()); - srv_stream.WriteLast(send_response, WriteOptions(), tag(6)); - srv_stream.Finish(Status::OK, tag(7)); - cli_stream->Read(&recv_response, tag(8)); - Verifier().Expect(6, true).Expect(7, true).Expect(8, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// Metadata tests -TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::pair<TString, TString> meta1("key1", "val1"); - std::pair<TString, TString> meta2("key2", "val2"); - std::pair<TString, TString> meta3("g.r.d-bin", "xyz"); - cli_ctx.AddMetadata(meta1.first, meta1.second); - cli_ctx.AddMetadata(meta2.first, meta2.second); - cli_ctx.AddMetadata(meta3.first, meta3.second); - - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - const auto& client_initial_metadata = srv_ctx.client_metadata(); - EXPECT_EQ(meta1.second, - ToString(client_initial_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(client_initial_metadata.find(meta2.first)->second)); - EXPECT_EQ(meta3.second, - ToString(client_initial_metadata.find(meta3.first)->second)); - EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -TEST_P(AsyncEnd2endTest, ServerInitialMetadataRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::pair<TString, TString> meta1("key1", "val1"); - std::pair<TString, TString> meta2("key2", "val2"); - - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->ReadInitialMetadata(tag(4)); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - srv_ctx.AddInitialMetadata(meta1.first, meta1.second); - srv_ctx.AddInitialMetadata(meta2.first, meta2.second); - response_writer.SendInitialMetadata(tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata(); - EXPECT_EQ(meta1.second, - ToString(server_initial_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(server_initial_metadata.find(meta2.first)->second)); - EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size()); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(5)); - response_reader->Finish(&recv_response, &recv_status, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -// 1 ping, 2 pongs. -TEST_P(AsyncEnd2endTest, ServerInitialMetadataServerStreaming) { - ResetStub(); - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - std::pair<::TString, ::TString> meta1("key1", "val1"); - std::pair<::TString, ::TString> meta2("key2", "val2"); - - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - cli_stream->ReadInitialMetadata(tag(11)); - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - - srv_ctx.AddInitialMetadata(meta1.first, meta1.second); - srv_ctx.AddInitialMetadata(meta2.first, meta2.second); - srv_stream.SendInitialMetadata(tag(10)); - Verifier().Expect(10, true).Expect(11, true).Verify(cq_.get()); - auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); - EXPECT_EQ(meta1.second, - ToString(server_initial_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(server_initial_metadata.find(meta2.first)->second)); - EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size()); - - srv_stream.Write(send_response, tag(3)); - - cli_stream->Read(&recv_response, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - - srv_stream.Write(send_response, tag(5)); - cli_stream->Read(&recv_response, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - srv_stream.Finish(Status::OK, tag(7)); - cli_stream->Read(&recv_response, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -// 1 ping, 2 pongs. -// Test for server initial metadata being sent implicitly -TEST_P(AsyncEnd2endTest, ServerInitialMetadataServerStreamingImplicit) { - ResetStub(); - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::pair<::TString, ::TString> meta1("key1", "val1"); - std::pair<::TString, ::TString> meta2("key2", "val2"); - - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - srv_ctx.AddInitialMetadata(meta1.first, meta1.second); - srv_ctx.AddInitialMetadata(meta2.first, meta2.second); - send_response.set_message(recv_request.message()); - srv_stream.Write(send_response, tag(3)); - - cli_stream->Read(&recv_response, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_response.message(), recv_response.message()); - - auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); - EXPECT_EQ(meta1.second, - ToString(server_initial_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(server_initial_metadata.find(meta2.first)->second)); - EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size()); - - srv_stream.Write(send_response, tag(5)); - cli_stream->Read(&recv_response, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - srv_stream.Finish(Status::OK, tag(7)); - cli_stream->Read(&recv_response, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status.ok()); -} - -TEST_P(AsyncEnd2endTest, ServerTrailingMetadataRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::pair<TString, TString> meta1("key1", "val1"); - std::pair<TString, TString> meta2("key2", "val2"); - - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->Finish(&recv_response, &recv_status, tag(5)); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - response_writer.SendInitialMetadata(tag(3)); - Verifier().Expect(3, true).Verify(cq_.get()); - - send_response.set_message(recv_request.message()); - srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); - srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); - response_writer.Finish(send_response, Status::OK, tag(4)); - - Verifier().Expect(4, true).Expect(5, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); - EXPECT_EQ(meta1.second, - ToString(server_trailing_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(server_trailing_metadata.find(meta2.first)->second)); - EXPECT_EQ(static_cast<size_t>(2), server_trailing_metadata.size()); -} - -TEST_P(AsyncEnd2endTest, MetadataRpc) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::pair<TString, TString> meta1("key1", "val1"); - std::pair<TString, TString> meta2( - "key2-bin", - TString("\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13)); - std::pair<TString, TString> meta3("key3", "val3"); - std::pair<TString, TString> meta6( - "key4-bin", - TString("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", - 14)); - std::pair<TString, TString> meta5("key5", "val5"); - std::pair<TString, TString> meta4( - "key6-bin", - TString( - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15)); - - cli_ctx.AddMetadata(meta1.first, meta1.second); - cli_ctx.AddMetadata(meta2.first, meta2.second); - - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->ReadInitialMetadata(tag(4)); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - const auto& client_initial_metadata = srv_ctx.client_metadata(); - EXPECT_EQ(meta1.second, - ToString(client_initial_metadata.find(meta1.first)->second)); - EXPECT_EQ(meta2.second, - ToString(client_initial_metadata.find(meta2.first)->second)); - EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); - - srv_ctx.AddInitialMetadata(meta3.first, meta3.second); - srv_ctx.AddInitialMetadata(meta4.first, meta4.second); - response_writer.SendInitialMetadata(tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata(); - EXPECT_EQ(meta3.second, - ToString(server_initial_metadata.find(meta3.first)->second)); - EXPECT_EQ(meta4.second, - ToString(server_initial_metadata.find(meta4.first)->second)); - EXPECT_GE(server_initial_metadata.size(), static_cast<size_t>(2)); - - send_response.set_message(recv_request.message()); - srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); - srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); - response_writer.Finish(send_response, Status::OK, tag(5)); - response_reader->Finish(&recv_response, &recv_status, tag(6)); - - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); - EXPECT_EQ(meta5.second, - ToString(server_trailing_metadata.find(meta5.first)->second)); - EXPECT_EQ(meta6.second, - ToString(server_trailing_metadata.find(meta6.first)->second)); - EXPECT_GE(server_trailing_metadata.size(), static_cast<size_t>(2)); -} - -// Server uses AsyncNotifyWhenDone API to check for cancellation -TEST_P(AsyncEnd2endTest, ServerCheckCancellation) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - srv_ctx.AsyncNotifyWhenDone(tag(5)); - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - cli_ctx.TryCancel(); - Verifier().Expect(5, true).Expect(4, true).Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - - EXPECT_EQ(StatusCode::CANCELLED, recv_status.error_code()); -} - -// Server uses AsyncNotifyWhenDone API to check for normal finish -TEST_P(AsyncEnd2endTest, ServerCheckDone) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - srv_ctx.AsyncNotifyWhenDone(tag(5)); - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), - cq_.get(), tag(2)); - - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Expect(5, true).Verify(cq_.get()); - EXPECT_FALSE(srv_ctx.IsCancelled()); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -TEST_P(AsyncEnd2endTest, UnimplementedRpc) { - ChannelArguments args; - const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - std::shared_ptr<Channel> channel = - !(GetParam().inproc) ? ::grpc::CreateCustomChannel(server_address_.str(), - channel_creds, args) - : server_->InProcessChannel(args); - std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub; - stub = grpc::testing::UnimplementedEchoService::NewStub(channel); - EchoRequest send_request; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - send_request.set_message(GetParam().message_content); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub->AsyncUnimplemented(&cli_ctx, send_request, cq_.get())); - - response_reader->Finish(&recv_response, &recv_status, tag(4)); - Verifier().Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(StatusCode::UNIMPLEMENTED, recv_status.error_code()); - EXPECT_EQ("", recv_status.error_message()); -} - -// This class is for testing scenarios where RPCs are cancelled on the server -// by calling ServerContext::TryCancel(). Server uses AsyncNotifyWhenDone -// API to check for cancellation -class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { - protected: - typedef enum { - DO_NOT_CANCEL = 0, - CANCEL_BEFORE_PROCESSING, - CANCEL_DURING_PROCESSING, - CANCEL_AFTER_PROCESSING - } ServerTryCancelRequestPhase; - - // Helper for testing client-streaming RPCs which are cancelled on the server. - // Depending on the value of server_try_cancel parameter, this will test one - // of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before reading - // any messages from the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while reading - // messages from the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after reading all - // messages from the client (but before sending any status back to the - // client) - void TestClientStreamingServerCancel( - ServerTryCancelRequestPhase server_try_cancel) { - ResetStub(); - - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - // Initiate the 'RequestStream' call on client - CompletionQueue cli_cq; - - std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( - stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq, tag(1))); - - // On the server, request to be notified of 'RequestStream' calls - // and receive the 'RequestStream' call just made by the client - srv_ctx.AsyncNotifyWhenDone(tag(11)); - service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - std::thread t1([&cli_cq] { Verifier().Expect(1, true).Verify(&cli_cq); }); - Verifier().Expect(2, true).Verify(cq_.get()); - t1.join(); - - bool expected_server_cq_result = true; - bool expected_client_cq_result = true; - - if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { - srv_ctx.TryCancel(); - Verifier().Expect(11, true).Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - - // Since cancellation is done before server reads any results, we know - // for sure that all server cq results will return false from this - // point forward - expected_server_cq_result = false; - expected_client_cq_result = false; - } - - bool ignore_client_cq_result = - (server_try_cancel == CANCEL_DURING_PROCESSING) || - (server_try_cancel == CANCEL_BEFORE_PROCESSING); - - std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result, - &ignore_client_cq_result] { - EchoRequest send_request; - // Client sends 3 messages (tags 3, 4 and 5) - for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { - send_request.set_message("Ping " + ToString(tag_idx)); - cli_stream->Write(send_request, tag(tag_idx)); - Verifier() - .Expect(tag_idx, expected_client_cq_result) - .Verify(&cli_cq, ignore_client_cq_result); - } - cli_stream->WritesDone(tag(6)); - // Ignore ok on WritesDone since cancel can affect it - Verifier() - .Expect(6, expected_client_cq_result) - .Verify(&cli_cq, ignore_client_cq_result); - }); - - bool ignore_cq_result = false; - bool want_done_tag = false; - std::thread* server_try_cancel_thd = nullptr; - - auto verif = Verifier(); - - if (server_try_cancel == CANCEL_DURING_PROCESSING) { - server_try_cancel_thd = - new std::thread([&srv_ctx] { srv_ctx.TryCancel(); }); - // Server will cancel the RPC in a parallel thread while reading the - // requests from the client. Since the cancellation can happen at anytime, - // some of the cq results (i.e those until cancellation) might be true but - // its non deterministic. So better to ignore the cq results - ignore_cq_result = true; - // Expect that we might possibly see the done tag that - // indicates cancellation completion in this case - want_done_tag = true; - verif.Expect(11, true); - } - - // Server reads 3 messages (tags 6, 7 and 8) - // But if want_done_tag is true, we might also see tag 11 - for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { - srv_stream.Read(&recv_request, tag(tag_idx)); - // Note that we'll add something to the verifier and verify that - // something was seen, but it might be tag 11 and not what we - // just added - int got_tag = verif.Expect(tag_idx, expected_server_cq_result) - .Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == tag_idx) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), tag_idx); - } - } - - cli_thread.join(); - - if (server_try_cancel_thd != nullptr) { - server_try_cancel_thd->join(); - delete server_try_cancel_thd; - } - - if (server_try_cancel == CANCEL_AFTER_PROCESSING) { - srv_ctx.TryCancel(); - want_done_tag = true; - verif.Expect(11, true); - } - - if (want_done_tag) { - verif.Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - } - - // The RPC has been cancelled at this point for sure (i.e irrespective of - // the value of `server_try_cancel` is). So, from this point forward, we - // know that cq results are supposed to return false on server. - - // Server sends the final message and cancelled status (but the RPC is - // already cancelled at this point. So we expect the operation to fail) - srv_stream.Finish(send_response, Status::CANCELLED, tag(9)); - Verifier().Expect(9, false).Verify(cq_.get()); - - // Client will see the cancellation - cli_stream->Finish(&recv_status, tag(10)); - Verifier().Expect(10, true).Verify(&cli_cq); - EXPECT_FALSE(recv_status.ok()); - EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); - - cli_cq.Shutdown(); - void* phony_tag; - bool phony_ok; - while (cli_cq.Next(&phony_tag, &phony_ok)) { - } - } - - // Helper for testing server-streaming RPCs which are cancelled on the server. - // Depending on the value of server_try_cancel parameter, this will test one - // of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before sending - // any messages to the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while sending - // messages to the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after sending all - // messages to the client (but before sending any status back to the - // client) - void TestServerStreamingServerCancel( - ServerTryCancelRequestPhase server_try_cancel) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - - send_request.set_message("Ping"); - // Initiate the 'ResponseStream' call on the client - CompletionQueue cli_cq; - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq, tag(1))); - // On the server, request to be notified of 'ResponseStream' calls and - // receive the call just made by the client - srv_ctx.AsyncNotifyWhenDone(tag(11)); - service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - std::thread t1([&cli_cq] { Verifier().Expect(1, true).Verify(&cli_cq); }); - Verifier().Expect(2, true).Verify(cq_.get()); - t1.join(); - - EXPECT_EQ(send_request.message(), recv_request.message()); - - bool expected_cq_result = true; - bool ignore_cq_result = false; - bool want_done_tag = false; - bool expected_client_cq_result = true; - bool ignore_client_cq_result = - (server_try_cancel != CANCEL_BEFORE_PROCESSING); - - if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { - srv_ctx.TryCancel(); - Verifier().Expect(11, true).Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - - // We know for sure that all cq results will be false from this point - // since the server cancelled the RPC - expected_cq_result = false; - expected_client_cq_result = false; - } - - std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result, - &ignore_client_cq_result] { - // Client attempts to read the three messages from the server - for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { - EchoResponse recv_response; - cli_stream->Read(&recv_response, tag(tag_idx)); - Verifier() - .Expect(tag_idx, expected_client_cq_result) - .Verify(&cli_cq, ignore_client_cq_result); - } - }); - - std::thread* server_try_cancel_thd = nullptr; - - auto verif = Verifier(); - - if (server_try_cancel == CANCEL_DURING_PROCESSING) { - server_try_cancel_thd = - new std::thread([&srv_ctx] { srv_ctx.TryCancel(); }); - - // Server will cancel the RPC in a parallel thread while writing responses - // to the client. Since the cancellation can happen at anytime, some of - // the cq results (i.e those until cancellation) might be true but it is - // non deterministic. So better to ignore the cq results - ignore_cq_result = true; - // Expect that we might possibly see the done tag that - // indicates cancellation completion in this case - want_done_tag = true; - verif.Expect(11, true); - } - - // Server sends three messages (tags 3, 4 and 5) - // But if want_done tag is true, we might also see tag 11 - for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { - send_response.set_message("Pong " + ToString(tag_idx)); - srv_stream.Write(send_response, tag(tag_idx)); - // Note that we'll add something to the verifier and verify that - // something was seen, but it might be tag 11 and not what we - // just added - int got_tag = verif.Expect(tag_idx, expected_cq_result) - .Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == tag_idx) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), tag_idx); - } - } - - if (server_try_cancel_thd != nullptr) { - server_try_cancel_thd->join(); - delete server_try_cancel_thd; - } - - if (server_try_cancel == CANCEL_AFTER_PROCESSING) { - srv_ctx.TryCancel(); - want_done_tag = true; - verif.Expect(11, true); - } - - if (want_done_tag) { - verif.Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - } - - cli_thread.join(); - - // The RPC has been cancelled at this point for sure (i.e irrespective of - // the value of `server_try_cancel` is). So, from this point forward, we - // know that cq results are supposed to return false on server. - - // Server finishes the stream (but the RPC is already cancelled) - srv_stream.Finish(Status::CANCELLED, tag(9)); - Verifier().Expect(9, false).Verify(cq_.get()); - - // Client will see the cancellation - cli_stream->Finish(&recv_status, tag(10)); - Verifier().Expect(10, true).Verify(&cli_cq); - EXPECT_FALSE(recv_status.ok()); - EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); - - cli_cq.Shutdown(); - void* phony_tag; - bool phony_ok; - while (cli_cq.Next(&phony_tag, &phony_ok)) { - } - } - - // Helper for testing bidirectinal-streaming RPCs which are cancelled on the - // server. - // - // Depending on the value of server_try_cancel parameter, this will - // test one of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before reading/ - // writing any messages from/to the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while reading - // messages from the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after reading all - // messages from the client (but before sending any status back to the - // client) - void TestBidiStreamingServerCancel( - ServerTryCancelRequestPhase server_try_cancel) { - ResetStub(); - - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - ServerContext srv_ctx; - ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - - // Initiate the call from the client side - std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> - cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); - - // On the server, request to be notified of the 'BidiStream' call and - // receive the call just made by the client - srv_ctx.AsyncNotifyWhenDone(tag(11)); - service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - - auto verif = Verifier(); - - // Client sends the first and the only message - send_request.set_message("Ping"); - cli_stream->Write(send_request, tag(3)); - verif.Expect(3, true); - - bool expected_cq_result = true; - bool ignore_cq_result = false; - bool want_done_tag = false; - - int got_tag, got_tag2; - bool tag_3_done = false; - - if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { - srv_ctx.TryCancel(); - verif.Expect(11, true); - // We know for sure that all server cq results will be false from - // this point since the server cancelled the RPC. However, we can't - // say for sure about the client - expected_cq_result = false; - ignore_cq_result = true; - - do { - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT(((got_tag == 3) && !tag_3_done) || (got_tag == 11)); - if (got_tag == 3) { - tag_3_done = true; - } - } while (got_tag != 11); - EXPECT_TRUE(srv_ctx.IsCancelled()); - } - - std::thread* server_try_cancel_thd = nullptr; - - if (server_try_cancel == CANCEL_DURING_PROCESSING) { - server_try_cancel_thd = - new std::thread([&srv_ctx] { srv_ctx.TryCancel(); }); - - // Since server is going to cancel the RPC in a parallel thread, some of - // the cq results (i.e those until the cancellation) might be true. Since - // that number is non-deterministic, it is better to ignore the cq results - ignore_cq_result = true; - // Expect that we might possibly see the done tag that - // indicates cancellation completion in this case - want_done_tag = true; - verif.Expect(11, true); - } - - srv_stream.Read(&recv_request, tag(4)); - verif.Expect(4, expected_cq_result); - got_tag = tag_3_done ? 3 : verif.Next(cq_.get(), ignore_cq_result); - got_tag2 = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 3) || (got_tag == 4) || - (got_tag == 11 && want_done_tag)); - GPR_ASSERT((got_tag2 == 3) || (got_tag2 == 4) || - (got_tag2 == 11 && want_done_tag)); - // If we get 3 and 4, we don't need to wait for 11, but if - // we get 11, we should also clear 3 and 4 - if (got_tag + got_tag2 != 7) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 3) || (got_tag == 4)); - } - - send_response.set_message("Pong"); - srv_stream.Write(send_response, tag(5)); - verif.Expect(5, expected_cq_result); - - cli_stream->Read(&recv_response, tag(6)); - verif.Expect(6, expected_cq_result); - got_tag = verif.Next(cq_.get(), ignore_cq_result); - got_tag2 = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 5) || (got_tag == 6) || - (got_tag == 11 && want_done_tag)); - GPR_ASSERT((got_tag2 == 5) || (got_tag2 == 6) || - (got_tag2 == 11 && want_done_tag)); - // If we get 5 and 6, we don't need to wait for 11, but if - // we get 11, we should also clear 5 and 6 - if (got_tag + got_tag2 != 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 5) || (got_tag == 6)); - } - - // This is expected to succeed in all cases - cli_stream->WritesDone(tag(7)); - verif.Expect(7, true); - // TODO(vjpai): Consider whether the following is too flexible - // or whether it should just be reset to ignore_cq_result - bool ignore_cq_wd_result = - ignore_cq_result || (server_try_cancel == CANCEL_BEFORE_PROCESSING); - got_tag = verif.Next(cq_.get(), ignore_cq_wd_result); - GPR_ASSERT((got_tag == 7) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_wd_result), 7); - } - - // This is expected to fail in all cases i.e for all values of - // server_try_cancel. This is because at this point, either there are no - // more msgs from the client (because client called WritesDone) or the RPC - // is cancelled on the server - srv_stream.Read(&recv_request, tag(8)); - verif.Expect(8, false); - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 8) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 8); - } - - if (server_try_cancel_thd != nullptr) { - server_try_cancel_thd->join(); - delete server_try_cancel_thd; - } - - if (server_try_cancel == CANCEL_AFTER_PROCESSING) { - srv_ctx.TryCancel(); - want_done_tag = true; - verif.Expect(11, true); - } - - if (want_done_tag) { - verif.Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - } - - // The RPC has been cancelled at this point for sure (i.e irrespective of - // the value of `server_try_cancel` is). So, from this point forward, we - // know that cq results are supposed to return false on server. - - srv_stream.Finish(Status::CANCELLED, tag(9)); - Verifier().Expect(9, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status, tag(10)); - Verifier().Expect(10, true).Verify(cq_.get()); - EXPECT_FALSE(recv_status.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, recv_status.error_code()); - } -}; - -TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelBefore) { - TestClientStreamingServerCancel(CANCEL_BEFORE_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelDuring) { - TestClientStreamingServerCancel(CANCEL_DURING_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelAfter) { - TestClientStreamingServerCancel(CANCEL_AFTER_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelBefore) { - TestServerStreamingServerCancel(CANCEL_BEFORE_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelDuring) { - TestServerStreamingServerCancel(CANCEL_DURING_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelAfter) { - TestServerStreamingServerCancel(CANCEL_AFTER_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelBefore) { - TestBidiStreamingServerCancel(CANCEL_BEFORE_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelDuring) { - TestBidiStreamingServerCancel(CANCEL_DURING_PROCESSING); -} - -TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelAfter) { - TestBidiStreamingServerCancel(CANCEL_AFTER_PROCESSING); -} - -std::vector<TestScenario> CreateTestScenarios(bool /*test_secure*/, - bool test_message_size_limit) { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types; - std::vector<TString> messages; - - auto insec_ok = [] { - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - return GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr; - }; - - if (insec_ok()) { - credentials_types.push_back(kInsecureCredentialsType); - } - auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); - for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { - credentials_types.push_back(*sec); - } - GPR_ASSERT(!credentials_types.empty()); - - messages.push_back("Hello"); - if (test_message_size_limit) { - for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; - k *= 32) { - TString big_msg; - for (size_t i = 0; i < k * 1024; ++i) { - char c = 'a' + (i % 26); - big_msg += c; - } - messages.push_back(big_msg); - } - if (!BuiltUnderMsan()) { - // 4MB message processing with SSL is very slow under msan - // (causes timeouts) and doesn't really increase the signal from tests. - // Reserve 100 bytes for other fields of the message proto. - messages.push_back( - TString(GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH - 100, 'a')); - } - } - - // TODO (sreek) Renable tests with health check service after the issue - // https://github.com/grpc/grpc/issues/11223 is resolved - for (auto health_check_service : {false}) { - for (auto msg = messages.begin(); msg != messages.end(); msg++) { - for (auto cred = credentials_types.begin(); - cred != credentials_types.end(); ++cred) { - scenarios.emplace_back(false, *cred, health_check_service, *msg); - } - if (insec_ok()) { - scenarios.emplace_back(true, kInsecureCredentialsType, - health_check_service, *msg); - } - } - } - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P(AsyncEnd2end, AsyncEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios(true, true))); -INSTANTIATE_TEST_SUITE_P(AsyncEnd2endServerTryCancel, - AsyncEnd2endServerTryCancelTest, - ::testing::ValuesIn(CreateTestScenarios(false, - false))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - // Change the backup poll interval from 5s to 100ms to speed up the - // ReconnectChannel test - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 100); - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/cfstream_test.cc b/contrib/libs/grpc/test/cpp/end2end/cfstream_test.cc deleted file mode 100644 index 8a8dcd4804..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/cfstream_test.cc +++ /dev/null @@ -1,478 +0,0 @@ -/* - * - * Copyright 2019 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <memory> -#include <mutex> -#include <random> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/health_check_service_interface.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/core/lib/backoff/backoff.h" -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/port.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_credentials_provider.h" - -#ifdef GRPC_CFSTREAM -using grpc::ClientAsyncResponseReader; -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; -using grpc::testing::RequestParams; -using std::chrono::system_clock; - -namespace grpc { -namespace testing { -namespace { - -struct TestScenario { - TestScenario(const TString& creds_type, const TString& content) - : credentials_type(creds_type), message_content(content) {} - const TString credentials_type; - const TString message_content; -}; - -class CFStreamTest : public ::testing::TestWithParam<TestScenario> { - protected: - CFStreamTest() - : server_host_("grpctest"), - interface_("lo0"), - ipv4_address_("10.0.0.1") {} - - void DNSUp() { - std::ostringstream cmd; - // Add DNS entry for server_host_ in /etc/hosts - cmd << "echo '" << ipv4_address_ << " " << server_host_ - << " ' | sudo tee -a /etc/hosts"; - std::system(cmd.str().c_str()); - } - - void DNSDown() { - std::ostringstream cmd; - // Remove DNS entry for server_host_ in /etc/hosts - cmd << "sudo sed -i '.bak' '/" << server_host_ << "/d' /etc/hosts"; - std::system(cmd.str().c_str()); - } - - void InterfaceUp() { - std::ostringstream cmd; - cmd << "sudo /sbin/ifconfig " << interface_ << " alias " << ipv4_address_; - std::system(cmd.str().c_str()); - } - - void InterfaceDown() { - std::ostringstream cmd; - cmd << "sudo /sbin/ifconfig " << interface_ << " -alias " << ipv4_address_; - std::system(cmd.str().c_str()); - } - - void NetworkUp() { - gpr_log(GPR_DEBUG, "Bringing network up"); - InterfaceUp(); - DNSUp(); - } - - void NetworkDown() { - gpr_log(GPR_DEBUG, "Bringing network down"); - InterfaceDown(); - DNSDown(); - } - - void SetUp() override { - NetworkUp(); - grpc_init(); - StartServer(); - } - - void TearDown() override { - NetworkDown(); - StopServer(); - grpc_shutdown(); - } - - void StartServer() { - port_ = grpc_pick_unused_port_or_die(); - server_.reset(new ServerData(port_, GetParam().credentials_type)); - server_->Start(server_host_); - } - void StopServer() { server_->Shutdown(); } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> BuildStub( - const std::shared_ptr<Channel>& channel) { - return grpc::testing::EchoTestService::NewStub(channel); - } - - std::shared_ptr<Channel> BuildChannel() { - std::ostringstream server_address; - server_address << server_host_ << ":" << port_; - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - return CreateCustomChannel(server_address.str(), channel_creds, args); - } - - void SendRpc( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - bool expect_success = false) { - auto response = std::unique_ptr<EchoResponse>(new EchoResponse()); - EchoRequest request; - auto& msg = GetParam().message_content; - request.set_message(msg); - ClientContext context; - Status status = stub->Echo(&context, request, response.get()); - if (status.ok()) { - gpr_log(GPR_DEBUG, "RPC with succeeded"); - EXPECT_EQ(msg, response->message()); - } else { - gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str()); - } - if (expect_success) { - EXPECT_TRUE(status.ok()); - } - } - void SendAsyncRpc( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - RequestParams param = RequestParams()) { - EchoRequest request; - request.set_message(GetParam().message_content); - *request.mutable_param() = std::move(param); - AsyncClientCall* call = new AsyncClientCall; - - call->response_reader = - stub->PrepareAsyncEcho(&call->context, request, &cq_); - - call->response_reader->StartCall(); - call->response_reader->Finish(&call->reply, &call->status, (void*)call); - } - - void ShutdownCQ() { cq_.Shutdown(); } - - bool CQNext(void** tag, bool* ok) { - auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(10); - auto ret = cq_.AsyncNext(tag, ok, deadline); - if (ret == grpc::CompletionQueue::GOT_EVENT) { - return true; - } else if (ret == grpc::CompletionQueue::SHUTDOWN) { - return false; - } else { - GPR_ASSERT(ret == grpc::CompletionQueue::TIMEOUT); - // This can happen if we hit the Apple CFStream bug which results in the - // read stream freezing. We are ignoring hangs and timeouts, but these - // tests are still useful as they can catch memory memory corruptions, - // crashes and other bugs that don't result in test freeze/timeout. - return false; - } - } - - bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(false /* try_to_connect */)) == - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - bool WaitForChannelReady(Channel* channel, int timeout_seconds = 10) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(true /* try_to_connect */)) != - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - struct AsyncClientCall { - EchoResponse reply; - ClientContext context; - Status status; - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader; - }; - - private: - struct ServerData { - int port_; - const TString creds_; - std::unique_ptr<Server> server_; - TestServiceImpl service_; - std::unique_ptr<std::thread> thread_; - bool server_ready_ = false; - - ServerData(int port, const TString& creds) - : port_(port), creds_(creds) {} - - void Start(const TString& server_host) { - gpr_log(GPR_INFO, "starting server on port %d", port_); - std::mutex mu; - std::unique_lock<std::mutex> lock(mu); - std::condition_variable cond; - thread_.reset(new std::thread( - std::bind(&ServerData::Serve, this, server_host, &mu, &cond))); - cond.wait(lock, [this] { return server_ready_; }); - server_ready_ = false; - gpr_log(GPR_INFO, "server startup complete"); - } - - void Serve(const TString& server_host, std::mutex* mu, - std::condition_variable* cond) { - std::ostringstream server_address; - server_address << server_host << ":" << port_; - ServerBuilder builder; - auto server_creds = - GetCredentialsProvider()->GetServerCredentials(creds_); - builder.AddListeningPort(server_address.str(), server_creds); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - std::lock_guard<std::mutex> lock(*mu); - server_ready_ = true; - cond->notify_one(); - } - - void Shutdown(bool join = true) { - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - if (join) thread_->join(); - } - }; - - CompletionQueue cq_; - const TString server_host_; - const TString interface_; - const TString ipv4_address_; - std::unique_ptr<ServerData> server_; - int port_; -}; - -std::vector<TestScenario> CreateTestScenarios() { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types; - std::vector<TString> messages; - - credentials_types.push_back(kInsecureCredentialsType); - auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); - for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { - credentials_types.push_back(*sec); - } - - messages.push_back("🖖"); - for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; k *= 32) { - TString big_msg; - for (size_t i = 0; i < k * 1024; ++i) { - char c = 'a' + (i % 26); - big_msg += c; - } - messages.push_back(big_msg); - } - for (auto cred = credentials_types.begin(); cred != credentials_types.end(); - ++cred) { - for (auto msg = messages.begin(); msg != messages.end(); msg++) { - scenarios.emplace_back(*cred, *msg); - } - } - - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P(CFStreamTest, CFStreamTest, - ::testing::ValuesIn(CreateTestScenarios())); - -// gRPC should automatically detech network flaps (without enabling keepalives) -// when CFStream is enabled -TEST_P(CFStreamTest, NetworkTransition) { - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - SendRpc(stub, /*expect_success=*/true); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - std::atomic_bool shutdown{false}; - std::thread sender = std::thread([this, &stub, &shutdown]() { - while (true) { - if (shutdown.load()) { - return; - } - SendRpc(stub); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - }); - - // bring down network - NetworkDown(); - - // network going down should be detected by cfstream - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - - // bring network interface back up - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - NetworkUp(); - - // channel should reconnect - EXPECT_TRUE(WaitForChannelReady(channel.get())); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - shutdown.store(true); - sender.join(); -} - -// Network flaps while RPCs are in flight -TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) { - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - std::atomic_int rpcs_sent{0}; - - // Channel should be in READY state after we send some RPCs - for (int i = 0; i < 10; ++i) { - RequestParams param; - param.set_skip_cancelled_check(true); - SendAsyncRpc(stub, param); - ++rpcs_sent; - } - EXPECT_TRUE(WaitForChannelReady(channel.get())); - - // Bring down the network - NetworkDown(); - - std::thread thd = std::thread([this, &rpcs_sent]() { - void* got_tag; - bool ok = false; - bool network_down = true; - int total_completions = 0; - - while (CQNext(&got_tag, &ok)) { - ++total_completions; - GPR_ASSERT(ok); - AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag); - if (!call->status.ok()) { - gpr_log(GPR_DEBUG, "RPC failed with error: %s", - call->status.error_message().c_str()); - // Bring network up when RPCs start failing - if (network_down) { - NetworkUp(); - network_down = false; - } - } else { - gpr_log(GPR_DEBUG, "RPC succeeded"); - } - delete call; - } - // Remove line below and uncomment the following line after Apple CFStream - // bug has been fixed. - (void)rpcs_sent; - // EXPECT_EQ(total_completions, rpcs_sent); - }); - - for (int i = 0; i < 100; ++i) { - RequestParams param; - param.set_skip_cancelled_check(true); - SendAsyncRpc(stub, param); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - ++rpcs_sent; - } - - ShutdownCQ(); - - thd.join(); -} - -// Send a bunch of RPCs, some of which are expected to fail. -// We should get back a response for all RPCs -TEST_P(CFStreamTest, ConcurrentRpc) { - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - std::atomic_int rpcs_sent{0}; - std::thread thd = std::thread([this, &rpcs_sent]() { - void* got_tag; - bool ok = false; - int total_completions = 0; - - while (CQNext(&got_tag, &ok)) { - ++total_completions; - GPR_ASSERT(ok); - AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag); - if (!call->status.ok()) { - gpr_log(GPR_DEBUG, "RPC failed with error: %s", - call->status.error_message().c_str()); - // Bring network up when RPCs start failing - } else { - gpr_log(GPR_DEBUG, "RPC succeeded"); - } - delete call; - } - // Remove line below and uncomment the following line after Apple CFStream - // bug has been fixed. - (void)rpcs_sent; - // EXPECT_EQ(total_completions, rpcs_sent); - }); - - for (int i = 0; i < 10; ++i) { - if (i % 3 == 0) { - RequestParams param; - ErrorStatus* error = param.mutable_expected_error(); - error->set_code(StatusCode::INTERNAL); - error->set_error_message("internal error"); - SendAsyncRpc(stub, param); - } else if (i % 5 == 0) { - RequestParams param; - param.set_echo_metadata(true); - DebugInfo* info = param.mutable_debug_info(); - info->add_stack_entries("stack_entry1"); - info->add_stack_entries("stack_entry2"); - info->set_detail("detailed debug info"); - SendAsyncRpc(stub, param); - } else { - SendAsyncRpc(stub); - } - ++rpcs_sent; - } - - ShutdownCQ(); - - thd.join(); -} - -} // namespace -} // namespace testing -} // namespace grpc -#endif // GRPC_CFSTREAM - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - gpr_setenv("grpc_cfstream", "1"); - const auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/channelz_service_test.cc b/contrib/libs/grpc/test/cpp/end2end/channelz_service_test.cc deleted file mode 100644 index a52533280a..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/channelz_service_test.cc +++ /dev/null @@ -1,937 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/support/port_platform.h> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/grpc_security.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/channelz_service_plugin.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/load_file.h" -#include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h" -#include "src/core/lib/security/security_connector/ssl_utils.h" -#include "src/core/lib/slice/slice_utils.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/proto/grpc/channelz/channelz.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_credentials_provider.h" - -using grpc::channelz::v1::Address; -using grpc::channelz::v1::GetChannelRequest; -using grpc::channelz::v1::GetChannelResponse; -using grpc::channelz::v1::GetServerRequest; -using grpc::channelz::v1::GetServerResponse; -using grpc::channelz::v1::GetServerSocketsRequest; -using grpc::channelz::v1::GetServerSocketsResponse; -using grpc::channelz::v1::GetServersRequest; -using grpc::channelz::v1::GetServersResponse; -using grpc::channelz::v1::GetSocketRequest; -using grpc::channelz::v1::GetSocketResponse; -using grpc::channelz::v1::GetSubchannelRequest; -using grpc::channelz::v1::GetSubchannelResponse; -using grpc::channelz::v1::GetTopChannelsRequest; -using grpc::channelz::v1::GetTopChannelsResponse; - -namespace grpc { -namespace testing { -namespace { - -bool ValidateAddress(const Address& address) { - if (address.address_case() != Address::kTcpipAddress) { - return true; - } - return address.tcpip_address().ip_address().size() == 4 || - address.tcpip_address().ip_address().size() == 16; -} - -// Proxy service supports N backends. Sends RPC to backend dictated by -// request->backend_channel_idx(). -class Proxy : public ::grpc::testing::EchoTestService::Service { - public: - Proxy() {} - - void AddChannelToBackend(const std::shared_ptr<Channel>& channel) { - stubs_.push_back(grpc::testing::EchoTestService::NewStub(channel)); - } - - Status Echo(ServerContext* server_context, const EchoRequest* request, - EchoResponse* response) override { - std::unique_ptr<ClientContext> client_context = - ClientContext::FromServerContext(*server_context); - size_t idx = request->param().backend_channel_idx(); - GPR_ASSERT(idx < stubs_.size()); - return stubs_[idx]->Echo(client_context.get(), *request, response); - } - - Status BidiStream(ServerContext* server_context, - ServerReaderWriter<EchoResponse, EchoRequest>* - stream_from_client) override { - EchoRequest request; - EchoResponse response; - std::unique_ptr<ClientContext> client_context = - ClientContext::FromServerContext(*server_context); - - // always use the first proxy for streaming - auto stream_to_backend = stubs_[0]->BidiStream(client_context.get()); - while (stream_from_client->Read(&request)) { - stream_to_backend->Write(request); - stream_to_backend->Read(&response); - stream_from_client->Write(response); - } - - stream_to_backend->WritesDone(); - return stream_to_backend->Finish(); - } - - private: - std::vector<std::unique_ptr<::grpc::testing::EchoTestService::Stub>> stubs_; -}; - -enum class CredentialsType { - kInsecure = 0, - kTls = 1, - kMtls = 2, -}; - -constexpr char kCaCertPath[] = "src/core/tsi/test_creds/ca.pem"; -constexpr char kServerCertPath[] = "src/core/tsi/test_creds/server1.pem"; -constexpr char kServerKeyPath[] = "src/core/tsi/test_creds/server1.key"; -constexpr char kClientCertPath[] = "src/core/tsi/test_creds/client.pem"; -constexpr char kClientKeyPath[] = "src/core/tsi/test_creds/client.key"; - -TString ReadFile(const char* file_path) { - grpc_slice slice; - GPR_ASSERT( - GRPC_LOG_IF_ERROR("load_file", grpc_load_file(file_path, 0, &slice))); - TString file_contents(grpc_core::StringViewFromSlice(slice)); - grpc_slice_unref(slice); - return file_contents; -} - -grpc_core::PemKeyCertPairList ReadTlsIdentityPair(const char* key_path, - const char* cert_path) { - return grpc_core::PemKeyCertPairList{ - grpc_core::PemKeyCertPair(ReadFile(key_path), ReadFile(cert_path))}; -} - -std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials( - CredentialsType type, ChannelArguments* args) { - if (type == CredentialsType::kInsecure) { - return InsecureChannelCredentials(); - } - args->SetSslTargetNameOverride("foo.test.google.fr"); - std::vector<experimental::IdentityKeyCertPair> identity_key_cert_pairs = { - {ReadFile(kClientKeyPath), ReadFile(kClientCertPath)}}; - grpc::experimental::TlsChannelCredentialsOptions options; - options.set_certificate_provider( - std::make_shared<grpc::experimental::StaticDataCertificateProvider>( - ReadFile(kCaCertPath), identity_key_cert_pairs)); - if (type == CredentialsType::kMtls) { - options.watch_identity_key_cert_pairs(); - } - options.watch_root_certs(); - return grpc::experimental::TlsCredentials(options); -} - -std::shared_ptr<grpc::ServerCredentials> GetServerCredentials( - CredentialsType type) { - if (type == CredentialsType::kInsecure) { - return InsecureServerCredentials(); - } - std::vector<experimental::IdentityKeyCertPair> identity_key_cert_pairs = { - {ReadFile(kServerKeyPath), ReadFile(kServerCertPath)}}; - auto certificate_provider = - std::make_shared<grpc::experimental::StaticDataCertificateProvider>( - ReadFile(kCaCertPath), identity_key_cert_pairs); - grpc::experimental::TlsServerCredentialsOptions options(certificate_provider); - options.watch_root_certs(); - options.watch_identity_key_cert_pairs(); - options.set_cert_request_type(GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY); - return grpc::experimental::TlsServerCredentials(options); -} - -TString RemoveWhitespaces(TString input) { - input.erase(remove_if(input.begin(), input.end(), isspace), input.end()); - return input; -} - -class ChannelzServerTest : public ::testing::TestWithParam<CredentialsType> { - public: - ChannelzServerTest() {} - static void SetUpTestCase() { -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - } - void SetUp() override { - // ensure channel server is brought up on all severs we build. - ::grpc::channelz::experimental::InitChannelzService(); - - // We set up a proxy server with channelz enabled. - proxy_port_ = grpc_pick_unused_port_or_die(); - ServerBuilder proxy_builder; - TString proxy_server_address = "localhost:" + to_string(proxy_port_); - proxy_builder.AddListeningPort(proxy_server_address, - GetServerCredentials(GetParam())); - // forces channelz and channel tracing to be enabled. - proxy_builder.AddChannelArgument(GRPC_ARG_ENABLE_CHANNELZ, 1); - proxy_builder.AddChannelArgument( - GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE, 1024); - proxy_builder.RegisterService(&proxy_service_); - proxy_server_ = proxy_builder.BuildAndStart(); - } - - // Sets the proxy up to have an arbitrary number of backends. - void ConfigureProxy(size_t num_backends) { - backends_.resize(num_backends); - for (size_t i = 0; i < num_backends; ++i) { - // create a new backend. - backends_[i].port = grpc_pick_unused_port_or_die(); - ServerBuilder backend_builder; - TString backend_server_address = - "localhost:" + to_string(backends_[i].port); - backend_builder.AddListeningPort(backend_server_address, - GetServerCredentials(GetParam())); - backends_[i].service = y_absl::make_unique<TestServiceImpl>(); - // ensure that the backend itself has channelz disabled. - backend_builder.AddChannelArgument(GRPC_ARG_ENABLE_CHANNELZ, 0); - backend_builder.RegisterService(backends_[i].service.get()); - backends_[i].server = backend_builder.BuildAndStart(); - // set up a channel to the backend. We ensure that this channel has - // channelz enabled since these channels (proxy outbound to backends) - // are the ones that our test will actually be validating. - ChannelArguments args; - args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 1); - args.SetInt(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE, 1024); - std::shared_ptr<Channel> channel_to_backend = ::grpc::CreateCustomChannel( - backend_server_address, GetChannelCredentials(GetParam(), &args), - args); - proxy_service_.AddChannelToBackend(channel_to_backend); - } - } - - void ResetStubs() { - string target = "dns:localhost:" + to_string(proxy_port_); - ChannelArguments args; - // disable channelz. We only want to focus on proxy to backend outbound. - args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 0); - std::shared_ptr<Channel> channel = ::grpc::CreateCustomChannel( - target, GetChannelCredentials(GetParam(), &args), args); - channelz_stub_ = grpc::channelz::v1::Channelz::NewStub(channel); - echo_stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> NewEchoStub() { - string target = "dns:localhost:" + to_string(proxy_port_); - ChannelArguments args; - // disable channelz. We only want to focus on proxy to backend outbound. - args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 0); - // This ensures that gRPC will not do connection sharing. - args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, true); - std::shared_ptr<Channel> channel = ::grpc::CreateCustomChannel( - target, GetChannelCredentials(GetParam(), &args), args); - return grpc::testing::EchoTestService::NewStub(channel); - } - - void SendSuccessfulEcho(int channel_idx) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello channelz"); - request.mutable_param()->set_backend_channel_idx(channel_idx); - ClientContext context; - Status s = echo_stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - } - - void SendSuccessfulStream(int num_messages) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello channelz"); - ClientContext context; - auto stream_to_proxy = echo_stub_->BidiStream(&context); - for (int i = 0; i < num_messages; ++i) { - EXPECT_TRUE(stream_to_proxy->Write(request)); - EXPECT_TRUE(stream_to_proxy->Read(&response)); - } - stream_to_proxy->WritesDone(); - Status s = stream_to_proxy->Finish(); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - } - - void SendFailedEcho(int channel_idx) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello channelz"); - request.mutable_param()->set_backend_channel_idx(channel_idx); - auto* error = request.mutable_param()->mutable_expected_error(); - error->set_code(13); // INTERNAL - error->set_error_message("error"); - ClientContext context; - Status s = echo_stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - } - - // Uses GetTopChannels to return the channel_id of a particular channel, - // so that the unit tests may test GetChannel call. - intptr_t GetChannelId(int channel_idx) { - GetTopChannelsRequest request; - GetTopChannelsResponse response; - request.set_start_channel_id(0); - ClientContext context; - Status s = channelz_stub_->GetTopChannels(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_GT(response.channel_size(), channel_idx); - return response.channel(channel_idx).ref().channel_id(); - } - - static string to_string(const int number) { - std::stringstream strs; - strs << number; - return strs.str(); - } - - protected: - // package of data needed for each backend server. - struct BackendData { - std::unique_ptr<Server> server; - int port; - std::unique_ptr<TestServiceImpl> service; - }; - - std::unique_ptr<grpc::channelz::v1::Channelz::Stub> channelz_stub_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> echo_stub_; - - // proxy server to ping with channelz requests. - std::unique_ptr<Server> proxy_server_; - int proxy_port_; - Proxy proxy_service_; - - // backends. All implement the echo service. - std::vector<BackendData> backends_; -}; - -TEST_P(ChannelzServerTest, BasicTest) { - ResetStubs(); - ConfigureProxy(1); - GetTopChannelsRequest request; - GetTopChannelsResponse response; - request.set_start_channel_id(0); - ClientContext context; - Status s = channelz_stub_->GetTopChannels(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel_size(), 1); -} - -TEST_P(ChannelzServerTest, HighStartId) { - ResetStubs(); - ConfigureProxy(1); - GetTopChannelsRequest request; - GetTopChannelsResponse response; - request.set_start_channel_id(10000); - ClientContext context; - Status s = channelz_stub_->GetTopChannels(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel_size(), 0); -} - -TEST_P(ChannelzServerTest, SuccessfulRequestTest) { - ResetStubs(); - ConfigureProxy(1); - SendSuccessfulEcho(0); - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(0)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), 1); - EXPECT_EQ(response.channel().data().calls_succeeded(), 1); - EXPECT_EQ(response.channel().data().calls_failed(), 0); -} - -TEST_P(ChannelzServerTest, FailedRequestTest) { - ResetStubs(); - ConfigureProxy(1); - SendFailedEcho(0); - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(0)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), 1); - EXPECT_EQ(response.channel().data().calls_succeeded(), 0); - EXPECT_EQ(response.channel().data().calls_failed(), 1); -} - -TEST_P(ChannelzServerTest, ManyRequestsTest) { - ResetStubs(); - ConfigureProxy(1); - // send some RPCs - const int kNumSuccess = 10; - const int kNumFailed = 11; - for (int i = 0; i < kNumSuccess; ++i) { - SendSuccessfulEcho(0); - } - for (int i = 0; i < kNumFailed; ++i) { - SendFailedEcho(0); - } - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(0)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), - kNumSuccess + kNumFailed); - EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess); - EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed); -} - -TEST_P(ChannelzServerTest, ManyChannels) { - ResetStubs(); - const int kNumChannels = 4; - ConfigureProxy(kNumChannels); - GetTopChannelsRequest request; - GetTopChannelsResponse response; - request.set_start_channel_id(0); - ClientContext context; - Status s = channelz_stub_->GetTopChannels(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel_size(), kNumChannels); -} - -TEST_P(ChannelzServerTest, ManyRequestsManyChannels) { - ResetStubs(); - const int kNumChannels = 4; - ConfigureProxy(kNumChannels); - const int kNumSuccess = 10; - const int kNumFailed = 11; - for (int i = 0; i < kNumSuccess; ++i) { - SendSuccessfulEcho(0); - SendSuccessfulEcho(2); - } - for (int i = 0; i < kNumFailed; ++i) { - SendFailedEcho(1); - SendFailedEcho(2); - } - - // the first channel saw only successes - { - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(0)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), kNumSuccess); - EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess); - EXPECT_EQ(response.channel().data().calls_failed(), 0); - } - - // the second channel saw only failures - { - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(1)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), kNumFailed); - EXPECT_EQ(response.channel().data().calls_succeeded(), 0); - EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed); - } - - // the third channel saw both - { - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(2)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), - kNumSuccess + kNumFailed); - EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess); - EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed); - } - - // the fourth channel saw nothing - { - GetChannelRequest request; - GetChannelResponse response; - request.set_channel_id(GetChannelId(3)); - ClientContext context; - Status s = channelz_stub_->GetChannel(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.channel().data().calls_started(), 0); - EXPECT_EQ(response.channel().data().calls_succeeded(), 0); - EXPECT_EQ(response.channel().data().calls_failed(), 0); - } -} - -TEST_P(ChannelzServerTest, ManySubchannels) { - ResetStubs(); - const int kNumChannels = 4; - ConfigureProxy(kNumChannels); - const int kNumSuccess = 10; - const int kNumFailed = 11; - for (int i = 0; i < kNumSuccess; ++i) { - SendSuccessfulEcho(0); - SendSuccessfulEcho(2); - } - for (int i = 0; i < kNumFailed; ++i) { - SendFailedEcho(1); - SendFailedEcho(2); - } - GetTopChannelsRequest gtc_request; - GetTopChannelsResponse gtc_response; - gtc_request.set_start_channel_id(0); - ClientContext context; - Status s = - channelz_stub_->GetTopChannels(&context, gtc_request, >c_response); - EXPECT_TRUE(s.ok()) << s.error_message(); - EXPECT_EQ(gtc_response.channel_size(), kNumChannels); - for (int i = 0; i < gtc_response.channel_size(); ++i) { - // if the channel sent no RPCs, then expect no subchannels to have been - // created. - if (gtc_response.channel(i).data().calls_started() == 0) { - EXPECT_EQ(gtc_response.channel(i).subchannel_ref_size(), 0); - continue; - } - // The resolver must return at least one address. - ASSERT_GT(gtc_response.channel(i).subchannel_ref_size(), 0); - GetSubchannelRequest gsc_request; - GetSubchannelResponse gsc_response; - gsc_request.set_subchannel_id( - gtc_response.channel(i).subchannel_ref(0).subchannel_id()); - ClientContext context; - Status s = - channelz_stub_->GetSubchannel(&context, gsc_request, &gsc_response); - EXPECT_TRUE(s.ok()) << s.error_message(); - EXPECT_EQ(gtc_response.channel(i).data().calls_started(), - gsc_response.subchannel().data().calls_started()); - EXPECT_EQ(gtc_response.channel(i).data().calls_succeeded(), - gsc_response.subchannel().data().calls_succeeded()); - EXPECT_EQ(gtc_response.channel(i).data().calls_failed(), - gsc_response.subchannel().data().calls_failed()); - } -} - -TEST_P(ChannelzServerTest, BasicServerTest) { - ResetStubs(); - ConfigureProxy(1); - GetServersRequest request; - GetServersResponse response; - request.set_start_server_id(0); - ClientContext context; - Status s = channelz_stub_->GetServers(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.server_size(), 1); -} - -TEST_P(ChannelzServerTest, BasicGetServerTest) { - ResetStubs(); - ConfigureProxy(1); - GetServersRequest get_servers_request; - GetServersResponse get_servers_response; - get_servers_request.set_start_server_id(0); - ClientContext get_servers_context; - Status s = channelz_stub_->GetServers( - &get_servers_context, get_servers_request, &get_servers_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_servers_response.server_size(), 1); - GetServerRequest get_server_request; - GetServerResponse get_server_response; - get_server_request.set_server_id( - get_servers_response.server(0).ref().server_id()); - ClientContext get_server_context; - s = channelz_stub_->GetServer(&get_server_context, get_server_request, - &get_server_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_servers_response.server(0).ref().server_id(), - get_server_response.server().ref().server_id()); -} - -TEST_P(ChannelzServerTest, ServerCallTest) { - ResetStubs(); - ConfigureProxy(1); - const int kNumSuccess = 10; - const int kNumFailed = 11; - for (int i = 0; i < kNumSuccess; ++i) { - SendSuccessfulEcho(0); - } - for (int i = 0; i < kNumFailed; ++i) { - SendFailedEcho(0); - } - GetServersRequest request; - GetServersResponse response; - request.set_start_server_id(0); - ClientContext context; - Status s = channelz_stub_->GetServers(&context, request, &response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(response.server_size(), 1); - EXPECT_EQ(response.server(0).data().calls_succeeded(), kNumSuccess); - EXPECT_EQ(response.server(0).data().calls_failed(), kNumFailed); - // This is success+failure+1 because the call that retrieved this information - // will be counted as started. It will not track success/failure until after - // it has returned, so that is not included in the response. - EXPECT_EQ(response.server(0).data().calls_started(), - kNumSuccess + kNumFailed + 1); -} - -TEST_P(ChannelzServerTest, ManySubchannelsAndSockets) { - ResetStubs(); - const int kNumChannels = 4; - ConfigureProxy(kNumChannels); - const int kNumSuccess = 10; - const int kNumFailed = 11; - for (int i = 0; i < kNumSuccess; ++i) { - SendSuccessfulEcho(0); - SendSuccessfulEcho(2); - } - for (int i = 0; i < kNumFailed; ++i) { - SendFailedEcho(1); - SendFailedEcho(2); - } - GetTopChannelsRequest gtc_request; - GetTopChannelsResponse gtc_response; - gtc_request.set_start_channel_id(0); - ClientContext context; - Status s = - channelz_stub_->GetTopChannels(&context, gtc_request, >c_response); - EXPECT_TRUE(s.ok()) << s.error_message(); - EXPECT_EQ(gtc_response.channel_size(), kNumChannels); - for (int i = 0; i < gtc_response.channel_size(); ++i) { - // if the channel sent no RPCs, then expect no subchannels to have been - // created. - if (gtc_response.channel(i).data().calls_started() == 0) { - EXPECT_EQ(gtc_response.channel(i).subchannel_ref_size(), 0); - continue; - } - // The resolver must return at least one address. - ASSERT_GT(gtc_response.channel(i).subchannel_ref_size(), 0); - // First grab the subchannel - GetSubchannelRequest get_subchannel_req; - GetSubchannelResponse get_subchannel_resp; - get_subchannel_req.set_subchannel_id( - gtc_response.channel(i).subchannel_ref(0).subchannel_id()); - ClientContext get_subchannel_ctx; - Status s = channelz_stub_->GetSubchannel( - &get_subchannel_ctx, get_subchannel_req, &get_subchannel_resp); - EXPECT_TRUE(s.ok()) << s.error_message(); - EXPECT_EQ(get_subchannel_resp.subchannel().socket_ref_size(), 1); - // Now grab the socket. - GetSocketRequest get_socket_req; - GetSocketResponse get_socket_resp; - ClientContext get_socket_ctx; - get_socket_req.set_socket_id( - get_subchannel_resp.subchannel().socket_ref(0).socket_id()); - s = channelz_stub_->GetSocket(&get_socket_ctx, get_socket_req, - &get_socket_resp); - EXPECT_TRUE( - get_subchannel_resp.subchannel().socket_ref(0).name().find("http")); - EXPECT_TRUE(s.ok()) << s.error_message(); - // calls started == streams started AND stream succeeded. Since none of - // these RPCs were canceled, all of the streams will succeeded even though - // the RPCs they represent might have failed. - EXPECT_EQ(get_subchannel_resp.subchannel().data().calls_started(), - get_socket_resp.socket().data().streams_started()); - EXPECT_EQ(get_subchannel_resp.subchannel().data().calls_started(), - get_socket_resp.socket().data().streams_succeeded()); - // All of the calls were unary, so calls started == messages sent. - EXPECT_EQ(get_subchannel_resp.subchannel().data().calls_started(), - get_socket_resp.socket().data().messages_sent()); - // We only get responses when the RPC was successful, so - // calls succeeded == messages received. - EXPECT_EQ(get_subchannel_resp.subchannel().data().calls_succeeded(), - get_socket_resp.socket().data().messages_received()); - switch (GetParam()) { - case CredentialsType::kInsecure: - EXPECT_FALSE(get_socket_resp.socket().has_security()); - break; - case CredentialsType::kTls: - case CredentialsType::kMtls: - EXPECT_TRUE(get_socket_resp.socket().has_security()); - EXPECT_TRUE(get_socket_resp.socket().security().has_tls()); - EXPECT_EQ( - RemoveWhitespaces( - get_socket_resp.socket().security().tls().remote_certificate()), - RemoveWhitespaces(ReadFile(kServerCertPath))); - break; - } - } -} - -TEST_P(ChannelzServerTest, StreamingRPC) { - ResetStubs(); - ConfigureProxy(1); - const int kNumMessages = 5; - SendSuccessfulStream(kNumMessages); - // Get the channel - GetChannelRequest get_channel_request; - GetChannelResponse get_channel_response; - get_channel_request.set_channel_id(GetChannelId(0)); - ClientContext get_channel_context; - Status s = channelz_stub_->GetChannel( - &get_channel_context, get_channel_request, &get_channel_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_channel_response.channel().data().calls_started(), 1); - EXPECT_EQ(get_channel_response.channel().data().calls_succeeded(), 1); - EXPECT_EQ(get_channel_response.channel().data().calls_failed(), 0); - // Get the subchannel - ASSERT_GT(get_channel_response.channel().subchannel_ref_size(), 0); - GetSubchannelRequest get_subchannel_request; - GetSubchannelResponse get_subchannel_response; - ClientContext get_subchannel_context; - get_subchannel_request.set_subchannel_id( - get_channel_response.channel().subchannel_ref(0).subchannel_id()); - s = channelz_stub_->GetSubchannel(&get_subchannel_context, - get_subchannel_request, - &get_subchannel_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_subchannel_response.subchannel().data().calls_started(), 1); - EXPECT_EQ(get_subchannel_response.subchannel().data().calls_succeeded(), 1); - EXPECT_EQ(get_subchannel_response.subchannel().data().calls_failed(), 0); - // Get the socket - ASSERT_GT(get_subchannel_response.subchannel().socket_ref_size(), 0); - GetSocketRequest get_socket_request; - GetSocketResponse get_socket_response; - ClientContext get_socket_context; - get_socket_request.set_socket_id( - get_subchannel_response.subchannel().socket_ref(0).socket_id()); - EXPECT_TRUE( - get_subchannel_response.subchannel().socket_ref(0).name().find("http")); - s = channelz_stub_->GetSocket(&get_socket_context, get_socket_request, - &get_socket_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_socket_response.socket().data().streams_started(), 1); - EXPECT_EQ(get_socket_response.socket().data().streams_succeeded(), 1); - EXPECT_EQ(get_socket_response.socket().data().streams_failed(), 0); - EXPECT_EQ(get_socket_response.socket().data().messages_sent(), kNumMessages); - EXPECT_EQ(get_socket_response.socket().data().messages_received(), - kNumMessages); - switch (GetParam()) { - case CredentialsType::kInsecure: - EXPECT_FALSE(get_socket_response.socket().has_security()); - break; - case CredentialsType::kTls: - case CredentialsType::kMtls: - EXPECT_TRUE(get_socket_response.socket().has_security()); - EXPECT_TRUE(get_socket_response.socket().security().has_tls()); - EXPECT_EQ(RemoveWhitespaces(get_socket_response.socket() - .security() - .tls() - .remote_certificate()), - RemoveWhitespaces(ReadFile(kServerCertPath))); - break; - } -} - -TEST_P(ChannelzServerTest, GetServerSocketsTest) { - ResetStubs(); - ConfigureProxy(1); - GetServersRequest get_server_request; - GetServersResponse get_server_response; - get_server_request.set_start_server_id(0); - ClientContext get_server_context; - Status s = channelz_stub_->GetServers(&get_server_context, get_server_request, - &get_server_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_server_response.server_size(), 1); - GetServerSocketsRequest get_server_sockets_request; - GetServerSocketsResponse get_server_sockets_response; - get_server_sockets_request.set_server_id( - get_server_response.server(0).ref().server_id()); - get_server_sockets_request.set_start_socket_id(0); - ClientContext get_server_sockets_context; - s = channelz_stub_->GetServerSockets(&get_server_sockets_context, - get_server_sockets_request, - &get_server_sockets_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_server_sockets_response.socket_ref_size(), 1); - EXPECT_TRUE(get_server_sockets_response.socket_ref(0).name().find("http")); - // Get the socket to verify security information. - GetSocketRequest get_socket_request; - GetSocketResponse get_socket_response; - ClientContext get_socket_context; - get_socket_request.set_socket_id( - get_server_sockets_response.socket_ref(0).socket_id()); - s = channelz_stub_->GetSocket(&get_socket_context, get_socket_request, - &get_socket_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_TRUE(ValidateAddress(get_socket_response.socket().remote())); - EXPECT_TRUE(ValidateAddress(get_socket_response.socket().local())); - switch (GetParam()) { - case CredentialsType::kInsecure: - EXPECT_FALSE(get_socket_response.socket().has_security()); - break; - case CredentialsType::kTls: - case CredentialsType::kMtls: - EXPECT_TRUE(get_socket_response.socket().has_security()); - EXPECT_TRUE(get_socket_response.socket().security().has_tls()); - if (GetParam() == CredentialsType::kMtls) { - EXPECT_EQ(RemoveWhitespaces(get_socket_response.socket() - .security() - .tls() - .remote_certificate()), - RemoveWhitespaces(ReadFile(kClientCertPath))); - } else { - EXPECT_TRUE(get_socket_response.socket() - .security() - .tls() - .remote_certificate() - .empty()); - } - break; - } -} - -TEST_P(ChannelzServerTest, GetServerSocketsPaginationTest) { - ResetStubs(); - ConfigureProxy(1); - std::vector<std::unique_ptr<grpc::testing::EchoTestService::Stub>> stubs; - const int kNumServerSocketsCreated = 20; - for (int i = 0; i < kNumServerSocketsCreated; ++i) { - stubs.push_back(NewEchoStub()); - EchoRequest request; - EchoResponse response; - request.set_message("Hello channelz"); - request.mutable_param()->set_backend_channel_idx(0); - ClientContext context; - Status s = stubs.back()->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - } - GetServersRequest get_server_request; - GetServersResponse get_server_response; - get_server_request.set_start_server_id(0); - ClientContext get_server_context; - Status s = channelz_stub_->GetServers(&get_server_context, get_server_request, - &get_server_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_server_response.server_size(), 1); - // Make a request that gets all of the serversockets - { - GetServerSocketsRequest get_server_sockets_request; - GetServerSocketsResponse get_server_sockets_response; - get_server_sockets_request.set_server_id( - get_server_response.server(0).ref().server_id()); - get_server_sockets_request.set_start_socket_id(0); - ClientContext get_server_sockets_context; - s = channelz_stub_->GetServerSockets(&get_server_sockets_context, - get_server_sockets_request, - &get_server_sockets_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - // We add one to account the channelz stub that will end up creating - // a serversocket. - EXPECT_EQ(get_server_sockets_response.socket_ref_size(), - kNumServerSocketsCreated + 1); - EXPECT_TRUE(get_server_sockets_response.end()); - } - // Now we make a request that exercises pagination. - { - GetServerSocketsRequest get_server_sockets_request; - GetServerSocketsResponse get_server_sockets_response; - get_server_sockets_request.set_server_id( - get_server_response.server(0).ref().server_id()); - get_server_sockets_request.set_start_socket_id(0); - const int kMaxResults = 10; - get_server_sockets_request.set_max_results(kMaxResults); - ClientContext get_server_sockets_context; - s = channelz_stub_->GetServerSockets(&get_server_sockets_context, - get_server_sockets_request, - &get_server_sockets_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_server_sockets_response.socket_ref_size(), kMaxResults); - EXPECT_FALSE(get_server_sockets_response.end()); - } -} - -TEST_P(ChannelzServerTest, GetServerListenSocketsTest) { - ResetStubs(); - ConfigureProxy(1); - GetServersRequest get_server_request; - GetServersResponse get_server_response; - get_server_request.set_start_server_id(0); - ClientContext get_server_context; - Status s = channelz_stub_->GetServers(&get_server_context, get_server_request, - &get_server_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - EXPECT_EQ(get_server_response.server_size(), 1); - // The resolver might return one or two addresses depending on the - // configuration, one for ipv4 and one for ipv6. - int listen_socket_size = get_server_response.server(0).listen_socket_size(); - EXPECT_TRUE(listen_socket_size == 1 || listen_socket_size == 2); - GetSocketRequest get_socket_request; - GetSocketResponse get_socket_response; - get_socket_request.set_socket_id( - get_server_response.server(0).listen_socket(0).socket_id()); - EXPECT_TRUE( - get_server_response.server(0).listen_socket(0).name().find("http")); - ClientContext get_socket_context_1; - s = channelz_stub_->GetSocket(&get_socket_context_1, get_socket_request, - &get_socket_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - - EXPECT_TRUE(ValidateAddress(get_socket_response.socket().remote())); - EXPECT_TRUE(ValidateAddress(get_socket_response.socket().local())); - if (listen_socket_size == 2) { - get_socket_request.set_socket_id( - get_server_response.server(0).listen_socket(1).socket_id()); - ClientContext get_socket_context_2; - EXPECT_TRUE( - get_server_response.server(0).listen_socket(1).name().find("http")); - s = channelz_stub_->GetSocket(&get_socket_context_2, get_socket_request, - &get_socket_response); - EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message(); - } -} - -INSTANTIATE_TEST_SUITE_P(ChannelzServer, ChannelzServerTest, - ::testing::ValuesIn(std::vector<CredentialsType>( - {CredentialsType::kInsecure, CredentialsType::kTls, - CredentialsType::kMtls}))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/client_callback_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/client_callback_end2end_test.cc deleted file mode 100644 index 157dcfa94a..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/client_callback_end2end_test.cc +++ /dev/null @@ -1,1577 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <condition_variable> -#include <functional> -#include <mutex> -#include <sstream> -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/generic/generic_stub.h> -#include <grpcpp/impl/codegen/proto_utils.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/client_callback.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/iomgr.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/interceptors_util.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" -#include "test/cpp/util/string_ref_helper.h" -#include "test/cpp/util/test_credentials_provider.h" - -namespace grpc { -namespace testing { -namespace { - -enum class Protocol { INPROC, TCP }; - -class TestScenario { - public: - TestScenario(bool serve_callback, Protocol protocol, bool intercept, - const TString& creds_type) - : callback_server(serve_callback), - protocol(protocol), - use_interceptors(intercept), - credentials_type(creds_type) {} - void Log() const; - bool callback_server; - Protocol protocol; - bool use_interceptors; - const TString credentials_type; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{callback_server=" - << (scenario.callback_server ? "true" : "false") << ",protocol=" - << (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP") - << ",intercept=" << (scenario.use_interceptors ? "true" : "false") - << ",creds=" << scenario.credentials_type << "}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_DEBUG, "%s", out.str().c_str()); -} - -class ClientCallbackEnd2endTest - : public ::testing::TestWithParam<TestScenario> { - protected: - ClientCallbackEnd2endTest() { GetParam().Log(); } - - void SetUp() override { - ServerBuilder builder; - - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - // TODO(vjpai): Support testing of AuthMetadataProcessor - - if (GetParam().protocol == Protocol::TCP) { - picked_port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << picked_port_; - builder.AddListeningPort(server_address_.str(), server_creds); - } - if (!GetParam().callback_server) { - builder.RegisterService(&service_); - } else { - builder.RegisterService(&callback_service_); - } - - if (GetParam().use_interceptors) { - std::vector< - std::unique_ptr<experimental::ServerInterceptorFactoryInterface>> - creators; - // Add 20 phony server interceptors - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - builder.experimental().SetInterceptorCreators(std::move(creators)); - } - - server_ = builder.BuildAndStart(); - is_server_started_ = true; - } - - void ResetStub( - std::unique_ptr<experimental::ClientInterceptorFactoryInterface> - interceptor = nullptr) { - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - auto interceptors = CreatePhonyClientInterceptors(); - if (interceptor != nullptr) interceptors.push_back(std::move(interceptor)); - switch (GetParam().protocol) { - case Protocol::TCP: - if (!GetParam().use_interceptors) { - channel_ = ::grpc::CreateCustomChannel(server_address_.str(), - channel_creds, args); - } else { - channel_ = CreateCustomChannelWithInterceptors( - server_address_.str(), channel_creds, args, - std::move(interceptors)); - } - break; - case Protocol::INPROC: - if (!GetParam().use_interceptors) { - channel_ = server_->InProcessChannel(args); - } else { - channel_ = server_->experimental().InProcessChannelWithInterceptors( - args, std::move(interceptors)); - } - break; - default: - assert(false); - } - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - generic_stub_ = y_absl::make_unique<GenericStub>(channel_); - PhonyInterceptor::Reset(); - } - - void TearDown() override { - if (is_server_started_) { - // Although we would normally do an explicit shutdown, the server - // should also work correctly with just a destructor call. The regular - // end2end test uses explicit shutdown, so let this one just do reset. - server_.reset(); - } - if (picked_port_ > 0) { - grpc_recycle_unused_port(picked_port_); - } - } - - void SendRpcs(int num_rpcs, bool with_binary_metadata) { - TString test_string(""); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - - test_string += "Hello world. "; - request.set_message(test_string); - TString val; - if (with_binary_metadata) { - request.mutable_param()->set_echo_metadata(true); - char bytes[8] = {'\0', '\1', '\2', '\3', - '\4', '\5', '\6', static_cast<char>(i)}; - val = TString(bytes, 8); - cli_ctx.AddMetadata("custom-bin", val); - } - - cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->Echo( - &cli_ctx, &request, &response, - [&cli_ctx, &request, &response, &done, &mu, &cv, val, - with_binary_metadata](Status s) { - GPR_ASSERT(s.ok()); - - EXPECT_EQ(request.message(), response.message()); - if (with_binary_metadata) { - EXPECT_EQ( - 1u, cli_ctx.GetServerTrailingMetadata().count("custom-bin")); - EXPECT_EQ(val, ToString(cli_ctx.GetServerTrailingMetadata() - .find("custom-bin") - ->second)); - } - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } - } - } - - void SendRpcsGeneric(int num_rpcs, bool maybe_except, - const char* suffix_for_stats) { - const TString kMethodName("/grpc.testing.EchoTestService/Echo"); - TString test_string(""); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest request; - std::unique_ptr<ByteBuffer> send_buf; - ByteBuffer recv_buf; - ClientContext cli_ctx; - - test_string += "Hello world. "; - request.set_message(test_string); - send_buf = SerializeToByteBuffer(&request); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - StubOptions options(suffix_for_stats); - generic_stub_->UnaryCall( - &cli_ctx, kMethodName, options, send_buf.get(), &recv_buf, - [&request, &recv_buf, &done, &mu, &cv, maybe_except](Status s) { - GPR_ASSERT(s.ok()); - - EchoResponse response; - EXPECT_TRUE(ParseFromByteBuffer(&recv_buf, &response)); - EXPECT_EQ(request.message(), response.message()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); -#if GRPC_ALLOW_EXCEPTIONS - if (maybe_except) { - throw -1; - } -#else - GPR_ASSERT(!maybe_except); -#endif - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } - } - } - - void SendGenericEchoAsBidi(int num_rpcs, int reuses, bool do_writes_done, - const char* suffix_for_stats) { - const TString kMethodName("/grpc.testing.EchoTestService/Echo"); - TString test_string(""); - for (int i = 0; i < num_rpcs; i++) { - test_string += "Hello world. "; - class Client : public grpc::ClientBidiReactor<ByteBuffer, ByteBuffer> { - public: - Client(ClientCallbackEnd2endTest* test, const TString& method_name, - const char* suffix_for_stats, const TString& test_str, - int reuses, bool do_writes_done) - : reuses_remaining_(reuses), do_writes_done_(do_writes_done) { - activate_ = [this, test, method_name, suffix_for_stats, test_str] { - if (reuses_remaining_ > 0) { - cli_ctx_ = y_absl::make_unique<ClientContext>(); - reuses_remaining_--; - StubOptions options(suffix_for_stats); - test->generic_stub_->PrepareBidiStreamingCall( - cli_ctx_.get(), method_name, options, this); - request_.set_message(test_str); - send_buf_ = SerializeToByteBuffer(&request_); - StartWrite(send_buf_.get()); - StartRead(&recv_buf_); - StartCall(); - } else { - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - }; - activate_(); - } - void OnWriteDone(bool /*ok*/) override { - if (do_writes_done_) { - StartWritesDone(); - } - } - void OnReadDone(bool /*ok*/) override { - EchoResponse response; - EXPECT_TRUE(ParseFromByteBuffer(&recv_buf_, &response)); - EXPECT_EQ(request_.message(), response.message()); - }; - void OnDone(const Status& s) override { - EXPECT_TRUE(s.ok()); - activate_(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - EchoRequest request_; - std::unique_ptr<ByteBuffer> send_buf_; - ByteBuffer recv_buf_; - std::unique_ptr<ClientContext> cli_ctx_; - int reuses_remaining_; - std::function<void()> activate_; - std::mutex mu_; - std::condition_variable cv_; - bool done_ = false; - const bool do_writes_done_; - }; - - Client rpc(this, kMethodName, suffix_for_stats, test_string, reuses, - do_writes_done); - - rpc.Await(); - } - } - bool is_server_started_{false}; - int picked_port_{0}; - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<grpc::GenericStub> generic_stub_; - TestServiceImpl service_; - CallbackTestServiceImpl callback_service_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; -}; - -TEST_P(ClientCallbackEnd2endTest, SimpleRpc) { - ResetStub(); - SendRpcs(1, false); -} - -TEST_P(ClientCallbackEnd2endTest, SimpleRpcExpectedError) { - ResetStub(); - - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - ErrorStatus error_status; - - request.set_message("Hello failure"); - error_status.set_code(1); // CANCELLED - error_status.set_error_message("cancel error message"); - *request.mutable_param()->mutable_expected_error() = error_status; - - std::mutex mu; - std::condition_variable cv; - bool done = false; - - stub_->async()->Echo(&cli_ctx, &request, &response, - [&response, &done, &mu, &cv, &error_status](Status s) { - EXPECT_EQ("", response.message()); - EXPECT_EQ(error_status.code(), s.error_code()); - EXPECT_EQ(error_status.error_message(), - s.error_message()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } -} - -TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) { - ResetStub(); - - // The request/response state associated with an RPC and the synchronization - // variables needed to notify its completion. - struct RpcState { - std::mutex mu; - std::condition_variable cv; - bool done = false; - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - - RpcState() = default; - ~RpcState() { - // Grab the lock to prevent destruction while another is still holding - // lock - std::lock_guard<std::mutex> lock(mu); - } - }; - std::vector<RpcState> rpc_state(3); - for (size_t i = 0; i < rpc_state.size(); i++) { - TString message = "Hello locked world"; - message += ToString(i); - rpc_state[i].request.set_message(message); - } - - // Grab a lock and then start an RPC whose callback grabs the same lock and - // then calls this function to start the next RPC under lock (up to a limit of - // the size of the rpc_state vector). - std::function<void(int)> nested_call = [this, &nested_call, - &rpc_state](int index) { - std::lock_guard<std::mutex> l(rpc_state[index].mu); - stub_->async()->Echo(&rpc_state[index].cli_ctx, &rpc_state[index].request, - &rpc_state[index].response, - [index, &nested_call, &rpc_state](Status s) { - std::lock_guard<std::mutex> l1(rpc_state[index].mu); - EXPECT_TRUE(s.ok()); - rpc_state[index].done = true; - rpc_state[index].cv.notify_all(); - // Call the next level of nesting if possible - if (index + 1 < int(rpc_state.size())) { - nested_call(index + 1); - } - }); - }; - - nested_call(0); - - // Wait for completion notifications from all RPCs. Order doesn't matter. - for (RpcState& state : rpc_state) { - std::unique_lock<std::mutex> l(state.mu); - while (!state.done) { - state.cv.wait(l); - } - EXPECT_EQ(state.request.message(), state.response.message()); - } -} - -TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) { - ResetStub(); - std::mutex mu; - std::condition_variable cv; - bool done = false; - EchoRequest request; - request.set_message("Hello locked world."); - EchoResponse response; - ClientContext cli_ctx; - { - std::lock_guard<std::mutex> l(mu); - stub_->async()->Echo(&cli_ctx, &request, &response, - [&mu, &cv, &done, &request, &response](Status s) { - std::lock_guard<std::mutex> l(mu); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(request.message(), response.message()); - done = true; - cv.notify_one(); - }); - } - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } -} - -TEST_P(ClientCallbackEnd2endTest, SequentialRpcs) { - ResetStub(); - SendRpcs(10, false); -} - -TEST_P(ClientCallbackEnd2endTest, SendClientInitialMetadata) { - ResetStub(); - SimpleRequest request; - SimpleResponse response; - ClientContext cli_ctx; - - cli_ctx.AddMetadata(kCheckClientInitialMetadataKey, - kCheckClientInitialMetadataVal); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->CheckClientInitialMetadata( - &cli_ctx, &request, &response, [&done, &mu, &cv](Status s) { - GPR_ASSERT(s.ok()); - - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } -} - -TEST_P(ClientCallbackEnd2endTest, SimpleRpcWithBinaryMetadata) { - ResetStub(); - SendRpcs(1, true); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialRpcsWithVariedBinaryMetadataValue) { - ResetStub(); - SendRpcs(10, true); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcs) { - ResetStub(y_absl::make_unique<TestInterceptorFactory>( - "/grpc.testing.EchoTestService/Echo", nullptr)); - SendRpcsGeneric(10, false, /*suffix_for_stats=*/nullptr); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsWithSuffix) { - ResetStub(y_absl::make_unique<TestInterceptorFactory>( - "/grpc.testing.EchoTestService/Echo", "TestSuffix")); - SendRpcsGeneric(10, false, "TestSuffix"); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidi) { - ResetStub(y_absl::make_unique<TestInterceptorFactory>( - "/grpc.testing.EchoTestService/Echo", nullptr)); - SendGenericEchoAsBidi(10, 1, /*do_writes_done=*/true, - /*suffix_for_stats=*/nullptr); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidiWithSuffix) { - ResetStub(y_absl::make_unique<TestInterceptorFactory>( - "/grpc.testing.EchoTestService/Echo", "TestSuffix")); - SendGenericEchoAsBidi(10, 1, /*do_writes_done=*/true, "TestSuffix"); -} - -TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidiWithReactorReuse) { - ResetStub(); - SendGenericEchoAsBidi(10, 10, /*do_writes_done=*/true, - /*suffix_for_stats=*/nullptr); -} - -TEST_P(ClientCallbackEnd2endTest, GenericRpcNoWritesDone) { - ResetStub(); - SendGenericEchoAsBidi(1, 1, /*do_writes_done=*/false, - /*suffix_for_stats=*/nullptr); -} - -#if GRPC_ALLOW_EXCEPTIONS -TEST_P(ClientCallbackEnd2endTest, ExceptingRpc) { - ResetStub(); - SendRpcsGeneric(10, true, nullptr); -} -#endif - -TEST_P(ClientCallbackEnd2endTest, MultipleRpcsWithVariedBinaryMetadataValue) { - ResetStub(); - std::vector<std::thread> threads; - threads.reserve(10); - for (int i = 0; i < 10; ++i) { - threads.emplace_back([this] { SendRpcs(10, true); }); - } - for (int i = 0; i < 10; ++i) { - threads[i].join(); - } -} - -TEST_P(ClientCallbackEnd2endTest, MultipleRpcs) { - ResetStub(); - std::vector<std::thread> threads; - threads.reserve(10); - for (int i = 0; i < 10; ++i) { - threads.emplace_back([this] { SendRpcs(10, false); }); - } - for (int i = 0; i < 10; ++i) { - threads[i].join(); - } -} - -TEST_P(ClientCallbackEnd2endTest, CancelRpcBeforeStart) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - context.TryCancel(); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->Echo(&context, &request, &response, - [&response, &done, &mu, &cv](Status s) { - EXPECT_EQ("", response.message()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, RequestEchoServerCancel) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - context.AddMetadata(kServerTryCancelRequest, - ToString(CANCEL_BEFORE_PROCESSING)); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->Echo(&context, &request, &response, - [&done, &mu, &cv](Status s) { - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } -} - -struct ClientCancelInfo { - bool cancel{false}; - int ops_before_cancel; - - ClientCancelInfo() : cancel{false} {} - explicit ClientCancelInfo(int ops) : cancel{true}, ops_before_cancel{ops} {} -}; - -class WriteClient : public grpc::ClientWriteReactor<EchoRequest> { - public: - WriteClient(grpc::testing::EchoTestService::Stub* stub, - ServerTryCancelRequestPhase server_try_cancel, - int num_msgs_to_send, ClientCancelInfo client_cancel = {}) - : server_try_cancel_(server_try_cancel), - num_msgs_to_send_(num_msgs_to_send), - client_cancel_{client_cancel} { - TString msg{"Hello server."}; - for (int i = 0; i < num_msgs_to_send; i++) { - desired_ += msg; - } - if (server_try_cancel != DO_NOT_CANCEL) { - // Send server_try_cancel value in the client metadata - context_.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - } - context_.set_initial_metadata_corked(true); - stub->async()->RequestStream(&context_, &response_, this); - StartCall(); - request_.set_message(msg); - MaybeWrite(); - } - void OnWriteDone(bool ok) override { - if (ok) { - num_msgs_sent_++; - MaybeWrite(); - } - } - void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Sent %d messages", num_msgs_sent_); - int num_to_send = - (client_cancel_.cancel) - ? std::min(num_msgs_to_send_, client_cancel_.ops_before_cancel) - : num_msgs_to_send_; - switch (server_try_cancel_) { - case CANCEL_BEFORE_PROCESSING: - case CANCEL_DURING_PROCESSING: - // If the RPC is canceled by server before / during messages from the - // client, it means that the client most likely did not get a chance to - // send all the messages it wanted to send. i.e num_msgs_sent <= - // num_msgs_to_send - EXPECT_LE(num_msgs_sent_, num_to_send); - break; - case DO_NOT_CANCEL: - case CANCEL_AFTER_PROCESSING: - // If the RPC was not canceled or canceled after all messages were read - // by the server, the client did get a chance to send all its messages - EXPECT_EQ(num_msgs_sent_, num_to_send); - break; - default: - assert(false); - break; - } - if ((server_try_cancel_ == DO_NOT_CANCEL) && !client_cancel_.cancel) { - EXPECT_TRUE(s.ok()); - EXPECT_EQ(response_.message(), desired_); - } else { - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - } - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - void MaybeWrite() { - if (client_cancel_.cancel && - num_msgs_sent_ == client_cancel_.ops_before_cancel) { - context_.TryCancel(); - } else if (num_msgs_to_send_ > num_msgs_sent_ + 1) { - StartWrite(&request_); - } else if (num_msgs_to_send_ == num_msgs_sent_ + 1) { - StartWriteLast(&request_, WriteOptions()); - } - } - EchoRequest request_; - EchoResponse response_; - ClientContext context_; - const ServerTryCancelRequestPhase server_try_cancel_; - int num_msgs_sent_{0}; - const int num_msgs_to_send_; - TString desired_; - const ClientCancelInfo client_cancel_; - std::mutex mu_; - std::condition_variable cv_; - bool done_ = false; -}; - -TEST_P(ClientCallbackEnd2endTest, RequestStream) { - ResetStub(); - WriteClient test{stub_.get(), DO_NOT_CANCEL, 3}; - test.Await(); - // Make sure that the server interceptors were not notified to cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, ClientCancelsRequestStream) { - ResetStub(); - WriteClient test{stub_.get(), DO_NOT_CANCEL, 3, ClientCancelInfo{2}}; - test.Await(); - // Make sure that the server interceptors got the cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel before doing reading the request -TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelBeforeReads) { - ResetStub(); - WriteClient test{stub_.get(), CANCEL_BEFORE_PROCESSING, 1}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel while reading a request from the stream in parallel -TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelDuringRead) { - ResetStub(); - WriteClient test{stub_.get(), CANCEL_DURING_PROCESSING, 10}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel after reading all the requests but before returning to the -// client -TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelAfterReads) { - ResetStub(); - WriteClient test{stub_.get(), CANCEL_AFTER_PROCESSING, 4}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, UnaryReactor) { - ResetStub(); - class UnaryClient : public grpc::ClientUnaryReactor { - public: - explicit UnaryClient(grpc::testing::EchoTestService::Stub* stub) { - cli_ctx_.AddMetadata("key1", "val1"); - cli_ctx_.AddMetadata("key2", "val2"); - request_.mutable_param()->set_echo_metadata_initially(true); - request_.set_message("Hello metadata"); - stub->async()->Echo(&cli_ctx_, &request_, &response_, this); - StartCall(); - } - void OnReadInitialMetadataDone(bool ok) override { - EXPECT_TRUE(ok); - EXPECT_EQ(1u, cli_ctx_.GetServerInitialMetadata().count("key1")); - EXPECT_EQ( - "val1", - ToString(cli_ctx_.GetServerInitialMetadata().find("key1")->second)); - EXPECT_EQ(1u, cli_ctx_.GetServerInitialMetadata().count("key2")); - EXPECT_EQ( - "val2", - ToString(cli_ctx_.GetServerInitialMetadata().find("key2")->second)); - initial_metadata_done_ = true; - } - void OnDone(const Status& s) override { - EXPECT_TRUE(initial_metadata_done_); - EXPECT_EQ(0u, cli_ctx_.GetServerTrailingMetadata().size()); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(request_.message(), response_.message()); - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - EchoRequest request_; - EchoResponse response_; - ClientContext cli_ctx_; - std::mutex mu_; - std::condition_variable cv_; - bool done_{false}; - bool initial_metadata_done_{false}; - }; - - UnaryClient test{stub_.get()}; - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, GenericUnaryReactor) { - const TString kMethodName("/grpc.testing.EchoTestService/Echo"); - constexpr char kSuffixForStats[] = "TestSuffixForStats"; - ResetStub( - y_absl::make_unique<TestInterceptorFactory>(kMethodName, kSuffixForStats)); - class UnaryClient : public grpc::ClientUnaryReactor { - public: - UnaryClient(grpc::GenericStub* stub, const TString& method_name, - const char* suffix_for_stats) { - cli_ctx_.AddMetadata("key1", "val1"); - cli_ctx_.AddMetadata("key2", "val2"); - request_.mutable_param()->set_echo_metadata_initially(true); - request_.set_message("Hello metadata"); - send_buf_ = SerializeToByteBuffer(&request_); - - StubOptions options(suffix_for_stats); - stub->PrepareUnaryCall(&cli_ctx_, method_name, options, send_buf_.get(), - &recv_buf_, this); - StartCall(); - } - void OnReadInitialMetadataDone(bool ok) override { - EXPECT_TRUE(ok); - EXPECT_EQ(1u, cli_ctx_.GetServerInitialMetadata().count("key1")); - EXPECT_EQ( - "val1", - ToString(cli_ctx_.GetServerInitialMetadata().find("key1")->second)); - EXPECT_EQ(1u, cli_ctx_.GetServerInitialMetadata().count("key2")); - EXPECT_EQ( - "val2", - ToString(cli_ctx_.GetServerInitialMetadata().find("key2")->second)); - initial_metadata_done_ = true; - } - void OnDone(const Status& s) override { - EXPECT_TRUE(initial_metadata_done_); - EXPECT_EQ(0u, cli_ctx_.GetServerTrailingMetadata().size()); - EXPECT_TRUE(s.ok()); - EchoResponse response; - EXPECT_TRUE(ParseFromByteBuffer(&recv_buf_, &response)); - EXPECT_EQ(request_.message(), response.message()); - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - EchoRequest request_; - std::unique_ptr<ByteBuffer> send_buf_; - ByteBuffer recv_buf_; - ClientContext cli_ctx_; - std::mutex mu_; - std::condition_variable cv_; - bool done_{false}; - bool initial_metadata_done_{false}; - }; - - UnaryClient test{generic_stub_.get(), kMethodName, kSuffixForStats}; - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -class ReadClient : public grpc::ClientReadReactor<EchoResponse> { - public: - ReadClient(grpc::testing::EchoTestService::Stub* stub, - ServerTryCancelRequestPhase server_try_cancel, - ClientCancelInfo client_cancel = {}) - : server_try_cancel_(server_try_cancel), client_cancel_{client_cancel} { - if (server_try_cancel_ != DO_NOT_CANCEL) { - // Send server_try_cancel value in the client metadata - context_.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - } - request_.set_message("Hello client "); - stub->async()->ResponseStream(&context_, &request_, this); - if (client_cancel_.cancel && - reads_complete_ == client_cancel_.ops_before_cancel) { - context_.TryCancel(); - } - // Even if we cancel, read until failure because there might be responses - // pending - StartRead(&response_); - StartCall(); - } - void OnReadDone(bool ok) override { - if (!ok) { - if (server_try_cancel_ == DO_NOT_CANCEL && !client_cancel_.cancel) { - EXPECT_EQ(reads_complete_, kServerDefaultResponseStreamsToSend); - } - } else { - EXPECT_LE(reads_complete_, kServerDefaultResponseStreamsToSend); - EXPECT_EQ(response_.message(), - request_.message() + ToString(reads_complete_)); - reads_complete_++; - if (client_cancel_.cancel && - reads_complete_ == client_cancel_.ops_before_cancel) { - context_.TryCancel(); - } - // Even if we cancel, read until failure because there might be responses - // pending - StartRead(&response_); - } - } - void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Read %d messages", reads_complete_); - switch (server_try_cancel_) { - case DO_NOT_CANCEL: - if (!client_cancel_.cancel || client_cancel_.ops_before_cancel > - kServerDefaultResponseStreamsToSend) { - EXPECT_TRUE(s.ok()); - EXPECT_EQ(reads_complete_, kServerDefaultResponseStreamsToSend); - } else { - EXPECT_GE(reads_complete_, client_cancel_.ops_before_cancel); - EXPECT_LE(reads_complete_, kServerDefaultResponseStreamsToSend); - // Status might be ok or cancelled depending on whether server - // sent status before client cancel went through - if (!s.ok()) { - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - } - } - break; - case CANCEL_BEFORE_PROCESSING: - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ(reads_complete_, 0); - break; - case CANCEL_DURING_PROCESSING: - case CANCEL_AFTER_PROCESSING: - // If server canceled while writing messages, client must have read - // less than or equal to the expected number of messages. Even if the - // server canceled after writing all messages, the RPC may be canceled - // before the Client got a chance to read all the messages. - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - EXPECT_LE(reads_complete_, kServerDefaultResponseStreamsToSend); - break; - default: - assert(false); - } - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - EchoRequest request_; - EchoResponse response_; - ClientContext context_; - const ServerTryCancelRequestPhase server_try_cancel_; - int reads_complete_{0}; - const ClientCancelInfo client_cancel_; - std::mutex mu_; - std::condition_variable cv_; - bool done_ = false; -}; - -TEST_P(ClientCallbackEnd2endTest, ResponseStream) { - ResetStub(); - ReadClient test{stub_.get(), DO_NOT_CANCEL}; - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, ClientCancelsResponseStream) { - ResetStub(); - ReadClient test{stub_.get(), DO_NOT_CANCEL, ClientCancelInfo{2}}; - test.Await(); - // Because cancel in this case races with server finish, we can't be sure that - // server interceptors even see cancellation -} - -// Server to cancel before sending any response messages -TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelBefore) { - ResetStub(); - ReadClient test{stub_.get(), CANCEL_BEFORE_PROCESSING}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel while writing a response to the stream in parallel -TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelDuring) { - ResetStub(); - ReadClient test{stub_.get(), CANCEL_DURING_PROCESSING}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel after writing all the respones to the stream but before -// returning to the client -TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelAfter) { - ResetStub(); - ReadClient test{stub_.get(), CANCEL_AFTER_PROCESSING}; - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -class BidiClient : public grpc::ClientBidiReactor<EchoRequest, EchoResponse> { - public: - BidiClient(grpc::testing::EchoTestService::Stub* stub, - ServerTryCancelRequestPhase server_try_cancel, - int num_msgs_to_send, bool cork_metadata, bool first_write_async, - ClientCancelInfo client_cancel = {}) - : server_try_cancel_(server_try_cancel), - msgs_to_send_{num_msgs_to_send}, - client_cancel_{client_cancel} { - if (server_try_cancel_ != DO_NOT_CANCEL) { - // Send server_try_cancel value in the client metadata - context_.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - } - request_.set_message("Hello fren "); - context_.set_initial_metadata_corked(cork_metadata); - stub->async()->BidiStream(&context_, this); - MaybeAsyncWrite(first_write_async); - StartRead(&response_); - StartCall(); - } - void OnReadDone(bool ok) override { - if (!ok) { - if (server_try_cancel_ == DO_NOT_CANCEL) { - if (!client_cancel_.cancel) { - EXPECT_EQ(reads_complete_, msgs_to_send_); - } else { - EXPECT_LE(reads_complete_, writes_complete_); - } - } - } else { - EXPECT_LE(reads_complete_, msgs_to_send_); - EXPECT_EQ(response_.message(), request_.message()); - reads_complete_++; - StartRead(&response_); - } - } - void OnWriteDone(bool ok) override { - if (async_write_thread_.joinable()) { - async_write_thread_.join(); - RemoveHold(); - } - if (server_try_cancel_ == DO_NOT_CANCEL) { - EXPECT_TRUE(ok); - } else if (!ok) { - return; - } - writes_complete_++; - MaybeWrite(); - } - void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Sent %d messages", writes_complete_); - gpr_log(GPR_INFO, "Read %d messages", reads_complete_); - switch (server_try_cancel_) { - case DO_NOT_CANCEL: - if (!client_cancel_.cancel || - client_cancel_.ops_before_cancel > msgs_to_send_) { - EXPECT_TRUE(s.ok()); - EXPECT_EQ(writes_complete_, msgs_to_send_); - EXPECT_EQ(reads_complete_, writes_complete_); - } else { - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ(writes_complete_, client_cancel_.ops_before_cancel); - EXPECT_LE(reads_complete_, writes_complete_); - } - break; - case CANCEL_BEFORE_PROCESSING: - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - // The RPC is canceled before the server did any work or returned any - // reads, but it's possible that some writes took place first from the - // client - EXPECT_LE(writes_complete_, msgs_to_send_); - EXPECT_EQ(reads_complete_, 0); - break; - case CANCEL_DURING_PROCESSING: - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - EXPECT_LE(writes_complete_, msgs_to_send_); - EXPECT_LE(reads_complete_, writes_complete_); - break; - case CANCEL_AFTER_PROCESSING: - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ(writes_complete_, msgs_to_send_); - // The Server canceled after reading the last message and after writing - // the message to the client. However, the RPC cancellation might have - // taken effect before the client actually read the response. - EXPECT_LE(reads_complete_, writes_complete_); - break; - default: - assert(false); - } - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - void MaybeAsyncWrite(bool first_write_async) { - if (first_write_async) { - // Make sure that we have a write to issue. - // TODO(vjpai): Make this work with 0 writes case as well. - assert(msgs_to_send_ >= 1); - - AddHold(); - async_write_thread_ = std::thread([this] { - std::unique_lock<std::mutex> lock(async_write_thread_mu_); - async_write_thread_cv_.wait( - lock, [this] { return async_write_thread_start_; }); - MaybeWrite(); - }); - std::lock_guard<std::mutex> lock(async_write_thread_mu_); - async_write_thread_start_ = true; - async_write_thread_cv_.notify_one(); - return; - } - MaybeWrite(); - } - void MaybeWrite() { - if (client_cancel_.cancel && - writes_complete_ == client_cancel_.ops_before_cancel) { - context_.TryCancel(); - } else if (writes_complete_ == msgs_to_send_) { - StartWritesDone(); - } else { - StartWrite(&request_); - } - } - EchoRequest request_; - EchoResponse response_; - ClientContext context_; - const ServerTryCancelRequestPhase server_try_cancel_; - int reads_complete_{0}; - int writes_complete_{0}; - const int msgs_to_send_; - const ClientCancelInfo client_cancel_; - std::mutex mu_; - std::condition_variable cv_; - bool done_ = false; - std::thread async_write_thread_; - bool async_write_thread_start_ = false; - std::mutex async_write_thread_mu_; - std::condition_variable async_write_thread_cv_; -}; - -TEST_P(ClientCallbackEnd2endTest, BidiStream) { - ResetStub(); - BidiClient test(stub_.get(), DO_NOT_CANCEL, - kServerDefaultResponseStreamsToSend, - /*cork_metadata=*/false, /*first_write_async=*/false); - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, BidiStreamFirstWriteAsync) { - ResetStub(); - BidiClient test(stub_.get(), DO_NOT_CANCEL, - kServerDefaultResponseStreamsToSend, - /*cork_metadata=*/false, /*first_write_async=*/true); - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, BidiStreamCorked) { - ResetStub(); - BidiClient test(stub_.get(), DO_NOT_CANCEL, - kServerDefaultResponseStreamsToSend, - /*cork_metadata=*/true, /*first_write_async=*/false); - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, BidiStreamCorkedFirstWriteAsync) { - ResetStub(); - BidiClient test(stub_.get(), DO_NOT_CANCEL, - kServerDefaultResponseStreamsToSend, - /*cork_metadata=*/true, /*first_write_async=*/true); - test.Await(); - // Make sure that the server interceptors were not notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(0, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, ClientCancelsBidiStream) { - ResetStub(); - BidiClient test(stub_.get(), DO_NOT_CANCEL, - kServerDefaultResponseStreamsToSend, - /*cork_metadata=*/false, /*first_write_async=*/false, - ClientCancelInfo(2)); - test.Await(); - // Make sure that the server interceptors were notified of a cancel - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel before reading/writing any requests/responses on the stream -TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelBefore) { - ResetStub(); - BidiClient test(stub_.get(), CANCEL_BEFORE_PROCESSING, /*num_msgs_to_send=*/2, - /*cork_metadata=*/false, /*first_write_async=*/false); - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel while reading/writing requests/responses on the stream in -// parallel -TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelDuring) { - ResetStub(); - BidiClient test(stub_.get(), CANCEL_DURING_PROCESSING, - /*num_msgs_to_send=*/10, /*cork_metadata=*/false, - /*first_write_async=*/false); - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Server to cancel after reading/writing all requests/responses on the stream -// but before returning to the client -TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelAfter) { - ResetStub(); - BidiClient test(stub_.get(), CANCEL_AFTER_PROCESSING, /*num_msgs_to_send=*/5, - /*cork_metadata=*/false, /*first_write_async=*/false); - test.Await(); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(ClientCallbackEnd2endTest, SimultaneousReadAndWritesDone) { - ResetStub(); - class Client : public grpc::ClientBidiReactor<EchoRequest, EchoResponse> { - public: - explicit Client(grpc::testing::EchoTestService::Stub* stub) { - request_.set_message("Hello bidi "); - stub->async()->BidiStream(&context_, this); - StartWrite(&request_); - StartCall(); - } - void OnReadDone(bool ok) override { - EXPECT_TRUE(ok); - EXPECT_EQ(response_.message(), request_.message()); - } - void OnWriteDone(bool ok) override { - EXPECT_TRUE(ok); - // Now send out the simultaneous Read and WritesDone - StartWritesDone(); - StartRead(&response_); - } - void OnDone(const Status& s) override { - EXPECT_TRUE(s.ok()); - EXPECT_EQ(response_.message(), request_.message()); - std::unique_lock<std::mutex> l(mu_); - done_ = true; - cv_.notify_one(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - cv_.wait(l); - } - } - - private: - EchoRequest request_; - EchoResponse response_; - ClientContext context_; - std::mutex mu_; - std::condition_variable cv_; - bool done_ = false; - } test{stub_.get()}; - - test.Await(); -} - -TEST_P(ClientCallbackEnd2endTest, UnimplementedRpc) { - ChannelArguments args; - const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - std::shared_ptr<Channel> channel = - (GetParam().protocol == Protocol::TCP) - ? ::grpc::CreateCustomChannel(server_address_.str(), channel_creds, - args) - : server_->InProcessChannel(args); - std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub; - stub = grpc::testing::UnimplementedEchoService::NewStub(channel); - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - request.set_message("Hello world."); - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub->async()->Unimplemented( - &cli_ctx, &request, &response, [&done, &mu, &cv](Status s) { - EXPECT_EQ(StatusCode::UNIMPLEMENTED, s.error_code()); - EXPECT_EQ("", s.error_message()); - - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } -} - -TEST_P(ClientCallbackEnd2endTest, TestTrailersOnlyOnError) { - // Note that trailers-only is an HTTP/2 concept so we shouldn't do this test - // for any other transport such as inproc. - if (GetParam().protocol != Protocol::TCP) { - return; - } - - ResetStub(); - class Reactor : public grpc::ClientBidiReactor<EchoRequest, EchoResponse> { - public: - explicit Reactor(grpc::testing::EchoTestService::Stub* stub) { - stub->async()->UnimplementedBidi(&context_, this); - StartCall(); - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - done_cv_.wait(l); - } - } - - private: - void OnReadInitialMetadataDone(bool ok) override { EXPECT_FALSE(ok); } - void OnDone(const Status& s) override { - EXPECT_EQ(s.error_code(), grpc::StatusCode::UNIMPLEMENTED); - EXPECT_EQ(s.error_message(), ""); - std::unique_lock<std::mutex> l(mu_); - done_ = true; - done_cv_.notify_one(); - } - - ClientContext context_; - std::mutex mu_; - std::condition_variable done_cv_; - bool done_ = false; - } client(stub_.get()); - - client.Await(); -} - -TEST_P(ClientCallbackEnd2endTest, - ResponseStreamExtraReactionFlowReadsUntilDone) { - ResetStub(); - class ReadAllIncomingDataClient - : public grpc::ClientReadReactor<EchoResponse> { - public: - explicit ReadAllIncomingDataClient( - grpc::testing::EchoTestService::Stub* stub) { - request_.set_message("Hello client "); - stub->async()->ResponseStream(&context_, &request_, this); - } - bool WaitForReadDone() { - std::unique_lock<std::mutex> l(mu_); - while (!read_done_) { - read_cv_.wait(l); - } - read_done_ = false; - return read_ok_; - } - void Await() { - std::unique_lock<std::mutex> l(mu_); - while (!done_) { - done_cv_.wait(l); - } - } - // RemoveHold under the same lock used for OnDone to make sure that we don't - // call OnDone directly or indirectly from the RemoveHold function. - void RemoveHoldUnderLock() { - std::unique_lock<std::mutex> l(mu_); - RemoveHold(); - } - const Status& status() { - std::unique_lock<std::mutex> l(mu_); - return status_; - } - - private: - void OnReadDone(bool ok) override { - std::unique_lock<std::mutex> l(mu_); - read_ok_ = ok; - read_done_ = true; - read_cv_.notify_one(); - } - void OnDone(const Status& s) override { - std::unique_lock<std::mutex> l(mu_); - done_ = true; - status_ = s; - done_cv_.notify_one(); - } - - EchoRequest request_; - EchoResponse response_; - ClientContext context_; - bool read_ok_ = false; - bool read_done_ = false; - std::mutex mu_; - std::condition_variable read_cv_; - std::condition_variable done_cv_; - bool done_ = false; - Status status_; - } client{stub_.get()}; - - int reads_complete = 0; - client.AddHold(); - client.StartCall(); - - EchoResponse response; - bool read_ok = true; - while (read_ok) { - client.StartRead(&response); - read_ok = client.WaitForReadDone(); - if (read_ok) { - ++reads_complete; - } - } - client.RemoveHoldUnderLock(); - client.Await(); - - EXPECT_EQ(kServerDefaultResponseStreamsToSend, reads_complete); - EXPECT_EQ(client.status().error_code(), grpc::StatusCode::OK); -} - -std::vector<TestScenario> CreateTestScenarios(bool test_insecure) { -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types{ - GetCredentialsProvider()->GetSecureCredentialsTypeList()}; - auto insec_ok = [] { - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - return GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr; - }; - if (test_insecure && insec_ok()) { - credentials_types.push_back(kInsecureCredentialsType); - } - GPR_ASSERT(!credentials_types.empty()); - - bool barr[]{false, true}; - Protocol parr[]{Protocol::INPROC, Protocol::TCP}; - for (Protocol p : parr) { - for (const auto& cred : credentials_types) { - // TODO(vjpai): Test inproc with secure credentials when feasible - if (p == Protocol::INPROC && - (cred != kInsecureCredentialsType || !insec_ok())) { - continue; - } - for (bool callback_server : barr) { - for (bool use_interceptors : barr) { - scenarios.emplace_back(callback_server, p, use_interceptors, cred); - } - } - } - } - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P(ClientCallbackEnd2endTest, ClientCallbackEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios(true))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - grpc_init(); - int ret = RUN_ALL_TESTS(); - grpc_shutdown(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/client_crash_test.cc b/contrib/libs/grpc/test/cpp/end2end/client_crash_test.cc deleted file mode 100644 index bdb10d476e..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/client_crash_test.cc +++ /dev/null @@ -1,148 +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. - * - */ - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/subprocess.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -static TString g_root; - -namespace grpc { -namespace testing { - -namespace { - -class CrashTest : public ::testing::Test { - protected: - CrashTest() {} - - std::unique_ptr<grpc::testing::EchoTestService::Stub> CreateServerAndStub() { - auto port = grpc_pick_unused_port_or_die(); - std::ostringstream addr_stream; - addr_stream << "localhost:" << port; - auto addr = addr_stream.str(); - server_ = y_absl::make_unique<SubProcess>(std::vector<TString>({ - g_root + "/client_crash_test_server", - "--address=" + addr, - })); - GPR_ASSERT(server_); - return grpc::testing::EchoTestService::NewStub( - grpc::CreateChannel(addr, InsecureChannelCredentials())); - } - - void KillServer() { server_.reset(); } - - private: - std::unique_ptr<SubProcess> server_; -}; - -TEST_F(CrashTest, KillBeforeWrite) { - auto stub = CreateServerAndStub(); - - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_wait_for_ready(true); - - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - KillServer(); - - request.set_message("You should be dead"); - // This may succeed or fail depending on the state of the TCP connection - stream->Write(request); - // But the read will definitely fail - EXPECT_FALSE(stream->Read(&response)); - - EXPECT_FALSE(stream->Finish().ok()); -} - -TEST_F(CrashTest, KillAfterWrite) { - auto stub = CreateServerAndStub(); - - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_wait_for_ready(true); - - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message("I'm going to kill you"); - EXPECT_TRUE(stream->Write(request)); - - KillServer(); - - // This may succeed or fail depending on how quick the server was - stream->Read(&response); - - EXPECT_FALSE(stream->Finish().ok()); -} - -} // namespace - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - TString me = argv[0]; - auto lslash = me.rfind('/'); - if (lslash != TString::npos) { - g_root = me.substr(0, lslash); - } else { - g_root = "."; - } - - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - // Order seems to matter on these tests: run three times to eliminate that - for (int i = 0; i < 3; i++) { - if (RUN_ALL_TESTS() != 0) { - return 1; - } - } - return 0; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/client_crash_test_server.cc b/contrib/libs/grpc/test/cpp/end2end/client_crash_test_server.cc deleted file mode 100644 index d08d296430..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/client_crash_test_server.cc +++ /dev/null @@ -1,76 +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. - * - */ - -#include <iostream> -#include <memory> -#include <util/generic/string.h> - -#include "y_absl/flags/flag.h" - -#include <grpc/support/log.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/cpp/util/test_config.h" - -Y_ABSL_FLAG(TString, address, "", "Address to bind to"); - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { - -class ServiceImpl final : public ::grpc::testing::EchoTestService::Service { - Status BidiStream( - ServerContext* /*context*/, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - EchoRequest request; - EchoResponse response; - while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); - response.set_message(request.message()); - stream->Write(response); - } - return Status::OK; - } -}; - -void RunServer() { - ServiceImpl service; - - ServerBuilder builder; - builder.AddListeningPort(y_absl::GetFlag(FLAGS_address), - grpc::InsecureServerCredentials()); - builder.RegisterService(&service); - std::unique_ptr<Server> server(builder.BuildAndStart()); - std::cout << "Server listening on " << y_absl::GetFlag(FLAGS_address) - << std::endl; - server->Wait(); -} -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::InitTest(&argc, &argv, true); - grpc::testing::RunServer(); - - return 0; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/client_interceptors_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/client_interceptors_end2end_test.cc deleted file mode 100644 index 4b9a030227..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/client_interceptors_end2end_test.cc +++ /dev/null @@ -1,1244 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <memory> -#include <vector> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/create_channel_posix.h> -#include <grpcpp/generic/generic_stub.h> -#include <grpcpp/impl/codegen/proto_utils.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/server_posix.h> -#include <grpcpp/support/client_interceptor.h> - -#include "src/core/lib/iomgr/port.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/interceptors_util.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" -#include "test/cpp/util/string_ref_helper.h" - -#ifdef GRPC_POSIX_SOCKET -#include <fcntl.h> - -#include "src/core/lib/iomgr/socket_utils_posix.h" -#endif /* GRPC_POSIX_SOCKET */ - -namespace grpc { -namespace testing { -namespace { - -enum class RPCType { - kSyncUnary, - kSyncClientStreaming, - kSyncServerStreaming, - kSyncBidiStreaming, - kAsyncCQUnary, - kAsyncCQClientStreaming, - kAsyncCQServerStreaming, - kAsyncCQBidiStreaming, -}; - -enum class ChannelType { - kHttpChannel, - kFdChannel, -}; - -/* Hijacks Echo RPC and fills in the expected values */ -class HijackingInterceptor : public experimental::Interceptor { - public: - explicit HijackingInterceptor(experimental::ClientRpcInfo* info) { - info_ = info; - // Make sure it is the right method - EXPECT_EQ(strcmp("/grpc.testing.EchoTestService/Echo", info->method()), 0); - EXPECT_EQ(info->suffix_for_stats(), nullptr); - EXPECT_EQ(info->type(), experimental::ClientRpcInfo::Type::UNARY); - } - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - bool hijack = false; - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - auto* map = methods->GetSendInitialMetadata(); - // Check that we can see the test metadata - ASSERT_EQ(map->size(), static_cast<unsigned>(1)); - auto iterator = map->begin(); - EXPECT_EQ("testkey", iterator->first); - EXPECT_EQ("testvalue", iterator->second); - hijack = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - EchoRequest req; - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_EQ(req.message(), "Hello"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { - // Got nothing to do here for now - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { - auto* map = methods->GetRecvInitialMetadata(); - // Got nothing better to do here for now - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - // Check that we got the hijacked message, and re-insert the expected - // message - EXPECT_EQ(resp->message(), "Hello1"); - resp->set_message("Hello"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - bool found = false; - // Check that we received the metadata as an echo - for (const auto& pair : *map) { - found = pair.first.starts_with("testkey") && - pair.second.starts_with("testvalue"); - if (found) break; - } - EXPECT_EQ(found, true); - auto* status = methods->GetRecvStatus(); - EXPECT_EQ(status->ok(), true); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA)) { - auto* map = methods->GetRecvInitialMetadata(); - // Got nothing better to do here at the moment - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) { - // Insert a different message than expected - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - resp->set_message("Hello1"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - // insert the metadata that we want - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - map->insert(std::make_pair("testkey", "testvalue")); - auto* status = methods->GetRecvStatus(); - *status = Status(StatusCode::OK, ""); - } - if (hijack) { - methods->Hijack(); - } else { - methods->Proceed(); - } - } - - private: - experimental::ClientRpcInfo* info_; -}; - -class HijackingInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new HijackingInterceptor(info); - } -}; - -class HijackingInterceptorMakesAnotherCall : public experimental::Interceptor { - public: - explicit HijackingInterceptorMakesAnotherCall( - experimental::ClientRpcInfo* info) { - info_ = info; - // Make sure it is the right method - EXPECT_EQ(strcmp("/grpc.testing.EchoTestService/Echo", info->method()), 0); - EXPECT_EQ(strcmp("TestSuffixForStats", info->suffix_for_stats()), 0); - } - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - auto* map = methods->GetSendInitialMetadata(); - // Check that we can see the test metadata - ASSERT_EQ(map->size(), static_cast<unsigned>(1)); - auto iterator = map->begin(); - EXPECT_EQ("testkey", iterator->first); - EXPECT_EQ("testvalue", iterator->second); - // Make a copy of the map - metadata_map_ = *map; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - EchoRequest req; - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_EQ(req.message(), "Hello"); - req_ = req; - stub_ = grpc::testing::EchoTestService::NewStub( - methods->GetInterceptedChannel()); - ctx_.AddMetadata(metadata_map_.begin()->first, - metadata_map_.begin()->second); - stub_->async()->Echo(&ctx_, &req_, &resp_, [this, methods](Status s) { - EXPECT_EQ(s.ok(), true); - EXPECT_EQ(resp_.message(), "Hello"); - methods->Hijack(); - }); - // This is a Unary RPC and we have got nothing interesting to do in the - // PRE_SEND_CLOSE interception hook point for this interceptor, so let's - // return here. (We do not want to call methods->Proceed(). When the new - // RPC returns, we will call methods->Hijack() instead.) - return; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { - // Got nothing to do here for now - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { - auto* map = methods->GetRecvInitialMetadata(); - // Got nothing better to do here for now - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - // Check that we got the hijacked message, and re-insert the expected - // message - EXPECT_EQ(resp->message(), "Hello"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - bool found = false; - // Check that we received the metadata as an echo - for (const auto& pair : *map) { - found = pair.first.starts_with("testkey") && - pair.second.starts_with("testvalue"); - if (found) break; - } - EXPECT_EQ(found, true); - auto* status = methods->GetRecvStatus(); - EXPECT_EQ(status->ok(), true); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA)) { - auto* map = methods->GetRecvInitialMetadata(); - // Got nothing better to do here at the moment - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) { - // Insert a different message than expected - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - resp->set_message(resp_.message()); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - // insert the metadata that we want - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - map->insert(std::make_pair("testkey", "testvalue")); - auto* status = methods->GetRecvStatus(); - *status = Status(StatusCode::OK, ""); - } - - methods->Proceed(); - } - - private: - experimental::ClientRpcInfo* info_; - std::multimap<TString, TString> metadata_map_; - ClientContext ctx_; - EchoRequest req_; - EchoResponse resp_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; -}; - -class HijackingInterceptorMakesAnotherCallFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new HijackingInterceptorMakesAnotherCall(info); - } -}; - -class BidiStreamingRpcHijackingInterceptor : public experimental::Interceptor { - public: - explicit BidiStreamingRpcHijackingInterceptor( - experimental::ClientRpcInfo* info) { - info_ = info; - EXPECT_EQ(info->suffix_for_stats(), nullptr); - } - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - bool hijack = false; - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - CheckMetadata(*methods->GetSendInitialMetadata(), "testkey", "testvalue"); - hijack = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - EchoRequest req; - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_EQ(req.message().find("Hello"), 0u); - msg = req.message(); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { - // Got nothing to do here for now - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_STATUS)) { - CheckMetadata(*methods->GetRecvTrailingMetadata(), "testkey", - "testvalue"); - auto* status = methods->GetRecvStatus(); - EXPECT_EQ(status->ok(), true); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) { - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - resp->set_message(msg); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { - EXPECT_EQ(static_cast<EchoResponse*>(methods->GetRecvMessage()) - ->message() - .find("Hello"), - 0u); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - // insert the metadata that we want - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - map->insert(std::make_pair("testkey", "testvalue")); - auto* status = methods->GetRecvStatus(); - *status = Status(StatusCode::OK, ""); - } - if (hijack) { - methods->Hijack(); - } else { - methods->Proceed(); - } - } - - private: - experimental::ClientRpcInfo* info_; - TString msg; -}; - -class ClientStreamingRpcHijackingInterceptor - : public experimental::Interceptor { - public: - explicit ClientStreamingRpcHijackingInterceptor( - experimental::ClientRpcInfo* info) { - info_ = info; - EXPECT_EQ( - strcmp("/grpc.testing.EchoTestService/RequestStream", info->method()), - 0); - EXPECT_EQ(strcmp("TestSuffixForStats", info->suffix_for_stats()), 0); - } - void Intercept(experimental::InterceptorBatchMethods* methods) override { - bool hijack = false; - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - hijack = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - if (++count_ > 10) { - methods->FailHijackedSendMessage(); - } - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_SEND_MESSAGE)) { - EXPECT_FALSE(got_failed_send_); - got_failed_send_ = !methods->GetSendMessageStatus(); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_STATUS)) { - auto* status = methods->GetRecvStatus(); - *status = Status(StatusCode::UNAVAILABLE, "Done sending 10 messages"); - } - if (hijack) { - methods->Hijack(); - } else { - methods->Proceed(); - } - } - - static bool GotFailedSend() { return got_failed_send_; } - - private: - experimental::ClientRpcInfo* info_; - int count_ = 0; - static bool got_failed_send_; -}; - -bool ClientStreamingRpcHijackingInterceptor::got_failed_send_ = false; - -class ClientStreamingRpcHijackingInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new ClientStreamingRpcHijackingInterceptor(info); - } -}; - -class ServerStreamingRpcHijackingInterceptor - : public experimental::Interceptor { - public: - explicit ServerStreamingRpcHijackingInterceptor( - experimental::ClientRpcInfo* info) { - info_ = info; - got_failed_message_ = false; - EXPECT_EQ(info->suffix_for_stats(), nullptr); - } - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - bool hijack = false; - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - auto* map = methods->GetSendInitialMetadata(); - // Check that we can see the test metadata - ASSERT_EQ(map->size(), static_cast<unsigned>(1)); - auto iterator = map->begin(); - EXPECT_EQ("testkey", iterator->first); - EXPECT_EQ("testvalue", iterator->second); - hijack = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - EchoRequest req; - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_EQ(req.message(), "Hello"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { - // Got nothing to do here for now - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - bool found = false; - // Check that we received the metadata as an echo - for (const auto& pair : *map) { - found = pair.first.starts_with("testkey") && - pair.second.starts_with("testvalue"); - if (found) break; - } - EXPECT_EQ(found, true); - auto* status = methods->GetRecvStatus(); - EXPECT_EQ(status->ok(), true); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) { - if (++count_ > 10) { - methods->FailHijackedRecvMessage(); - } - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - resp->set_message("Hello"); - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { - // Only the last message will be a failure - EXPECT_FALSE(got_failed_message_); - got_failed_message_ = methods->GetRecvMessage() == nullptr; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - // insert the metadata that we want - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - map->insert(std::make_pair("testkey", "testvalue")); - auto* status = methods->GetRecvStatus(); - *status = Status(StatusCode::OK, ""); - } - if (hijack) { - methods->Hijack(); - } else { - methods->Proceed(); - } - } - - static bool GotFailedMessage() { return got_failed_message_; } - - private: - experimental::ClientRpcInfo* info_; - static bool got_failed_message_; - int count_ = 0; -}; - -bool ServerStreamingRpcHijackingInterceptor::got_failed_message_ = false; - -class ServerStreamingRpcHijackingInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new ServerStreamingRpcHijackingInterceptor(info); - } -}; - -class BidiStreamingRpcHijackingInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new BidiStreamingRpcHijackingInterceptor(info); - } -}; - -// The logging interceptor is for testing purposes only. It is used to verify -// that all the appropriate hook points are invoked for an RPC. The counts are -// reset each time a new object of LoggingInterceptor is created, so only a -// single RPC should be made on the channel before calling the Verify methods. -class LoggingInterceptor : public experimental::Interceptor { - public: - explicit LoggingInterceptor(experimental::ClientRpcInfo* /*info*/) { - pre_send_initial_metadata_ = false; - pre_send_message_count_ = 0; - pre_send_close_ = false; - post_recv_initial_metadata_ = false; - post_recv_message_count_ = 0; - post_recv_status_ = false; - } - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - auto* map = methods->GetSendInitialMetadata(); - // Check that we can see the test metadata - ASSERT_EQ(map->size(), static_cast<unsigned>(1)); - auto iterator = map->begin(); - EXPECT_EQ("testkey", iterator->first); - EXPECT_EQ("testvalue", iterator->second); - ASSERT_FALSE(pre_send_initial_metadata_); - pre_send_initial_metadata_ = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) { - EchoRequest req; - auto* send_msg = methods->GetSendMessage(); - if (send_msg == nullptr) { - // We did not get the non-serialized form of the message. Get the - // serialized form. - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EchoRequest req; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_EQ(req.message(), "Hello"); - } else { - EXPECT_EQ( - static_cast<const EchoRequest*>(send_msg)->message().find("Hello"), - 0u); - } - auto* buffer = methods->GetSerializedSendMessage(); - auto copied_buffer = *buffer; - EXPECT_TRUE( - SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req) - .ok()); - EXPECT_TRUE(req.message().find("Hello") == 0u); - pre_send_message_count_++; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) { - // Got nothing to do here for now - pre_send_close_ = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA)) { - auto* map = methods->GetRecvInitialMetadata(); - // Got nothing better to do here for now - EXPECT_EQ(map->size(), static_cast<unsigned>(0)); - post_recv_initial_metadata_ = true; - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) { - EchoResponse* resp = - static_cast<EchoResponse*>(methods->GetRecvMessage()); - if (resp != nullptr) { - EXPECT_TRUE(resp->message().find("Hello") == 0u); - post_recv_message_count_++; - } - } - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::POST_RECV_STATUS)) { - auto* map = methods->GetRecvTrailingMetadata(); - bool found = false; - // Check that we received the metadata as an echo - for (const auto& pair : *map) { - found = pair.first.starts_with("testkey") && - pair.second.starts_with("testvalue"); - if (found) break; - } - EXPECT_EQ(found, true); - auto* status = methods->GetRecvStatus(); - EXPECT_EQ(status->ok(), true); - post_recv_status_ = true; - } - methods->Proceed(); - } - - static void VerifyCall(RPCType type) { - switch (type) { - case RPCType::kSyncUnary: - case RPCType::kAsyncCQUnary: - VerifyUnaryCall(); - break; - case RPCType::kSyncClientStreaming: - case RPCType::kAsyncCQClientStreaming: - VerifyClientStreamingCall(); - break; - case RPCType::kSyncServerStreaming: - case RPCType::kAsyncCQServerStreaming: - VerifyServerStreamingCall(); - break; - case RPCType::kSyncBidiStreaming: - case RPCType::kAsyncCQBidiStreaming: - VerifyBidiStreamingCall(); - break; - } - } - - static void VerifyCallCommon() { - EXPECT_TRUE(pre_send_initial_metadata_); - EXPECT_TRUE(pre_send_close_); - EXPECT_TRUE(post_recv_initial_metadata_); - EXPECT_TRUE(post_recv_status_); - } - - static void VerifyUnaryCall() { - VerifyCallCommon(); - EXPECT_EQ(pre_send_message_count_, 1); - EXPECT_EQ(post_recv_message_count_, 1); - } - - static void VerifyClientStreamingCall() { - VerifyCallCommon(); - EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); - EXPECT_EQ(post_recv_message_count_, 1); - } - - static void VerifyServerStreamingCall() { - VerifyCallCommon(); - EXPECT_EQ(pre_send_message_count_, 1); - EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); - } - - static void VerifyBidiStreamingCall() { - VerifyCallCommon(); - EXPECT_EQ(pre_send_message_count_, kNumStreamingMessages); - EXPECT_EQ(post_recv_message_count_, kNumStreamingMessages); - } - - private: - static bool pre_send_initial_metadata_; - static int pre_send_message_count_; - static bool pre_send_close_; - static bool post_recv_initial_metadata_; - static int post_recv_message_count_; - static bool post_recv_status_; -}; - -bool LoggingInterceptor::pre_send_initial_metadata_; -int LoggingInterceptor::pre_send_message_count_; -bool LoggingInterceptor::pre_send_close_; -bool LoggingInterceptor::post_recv_initial_metadata_; -int LoggingInterceptor::post_recv_message_count_; -bool LoggingInterceptor::post_recv_status_; - -class LoggingInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - public: - experimental::Interceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new LoggingInterceptor(info); - } -}; - -class TestScenario { - public: - explicit TestScenario(const ChannelType& channel_type, - const RPCType& rpc_type) - : channel_type_(channel_type), rpc_type_(rpc_type) {} - - ChannelType channel_type() const { return channel_type_; } - - RPCType rpc_type() const { return rpc_type_; } - - private: - const ChannelType channel_type_; - const RPCType rpc_type_; -}; - -std::vector<TestScenario> CreateTestScenarios() { - std::vector<TestScenario> scenarios; - std::vector<RPCType> rpc_types; - rpc_types.emplace_back(RPCType::kSyncUnary); - rpc_types.emplace_back(RPCType::kSyncClientStreaming); - rpc_types.emplace_back(RPCType::kSyncServerStreaming); - rpc_types.emplace_back(RPCType::kSyncBidiStreaming); - rpc_types.emplace_back(RPCType::kAsyncCQUnary); - rpc_types.emplace_back(RPCType::kAsyncCQServerStreaming); - for (const auto& rpc_type : rpc_types) { - scenarios.emplace_back(ChannelType::kHttpChannel, rpc_type); -// TODO(yashykt): Maybe add support for non-posix sockets too -#ifdef GRPC_POSIX_SOCKET - scenarios.emplace_back(ChannelType::kFdChannel, rpc_type); -#endif /* GRPC_POSIX_SOCKET */ - } - return scenarios; -} - -class ParameterizedClientInterceptorsEnd2endTest - : public ::testing::TestWithParam<TestScenario> { - protected: - ParameterizedClientInterceptorsEnd2endTest() { - ServerBuilder builder; - builder.RegisterService(&service_); - if (GetParam().channel_type() == ChannelType::kHttpChannel) { - int port = grpc_pick_unused_port_or_die(); - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - server_ = builder.BuildAndStart(); - } -#ifdef GRPC_POSIX_SOCKET - else if (GetParam().channel_type() == ChannelType::kFdChannel) { - int flags; - GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv_) == 0); - flags = fcntl(sv_[0], F_GETFL, 0); - GPR_ASSERT(fcntl(sv_[0], F_SETFL, flags | O_NONBLOCK) == 0); - flags = fcntl(sv_[1], F_GETFL, 0); - GPR_ASSERT(fcntl(sv_[1], F_SETFL, flags | O_NONBLOCK) == 0); - GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv_[0]) == - GRPC_ERROR_NONE); - GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv_[1]) == - GRPC_ERROR_NONE); - server_ = builder.BuildAndStart(); - AddInsecureChannelFromFd(server_.get(), sv_[1]); - } -#endif /* GRPC_POSIX_SOCKET */ - } - - ~ParameterizedClientInterceptorsEnd2endTest() override { - server_->Shutdown(); - } - - std::shared_ptr<grpc::Channel> CreateClientChannel( - std::vector<std::unique_ptr< - grpc::experimental::ClientInterceptorFactoryInterface>> - creators) { - if (GetParam().channel_type() == ChannelType::kHttpChannel) { - return experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), ChannelArguments(), - std::move(creators)); - } -#ifdef GRPC_POSIX_SOCKET - else if (GetParam().channel_type() == ChannelType::kFdChannel) { - return experimental::CreateCustomInsecureChannelWithInterceptorsFromFd( - "", sv_[0], ChannelArguments(), std::move(creators)); - } -#endif /* GRPC_POSIX_SOCKET */ - return nullptr; - } - - void SendRPC(const std::shared_ptr<Channel>& channel) { - switch (GetParam().rpc_type()) { - case RPCType::kSyncUnary: - MakeCall(channel); - break; - case RPCType::kSyncClientStreaming: - MakeClientStreamingCall(channel); - break; - case RPCType::kSyncServerStreaming: - MakeServerStreamingCall(channel); - break; - case RPCType::kSyncBidiStreaming: - MakeBidiStreamingCall(channel); - break; - case RPCType::kAsyncCQUnary: - MakeAsyncCQCall(channel); - break; - case RPCType::kAsyncCQClientStreaming: - // TODO(yashykt) : Fill this out - break; - case RPCType::kAsyncCQServerStreaming: - MakeAsyncCQServerStreamingCall(channel); - break; - case RPCType::kAsyncCQBidiStreaming: - // TODO(yashykt) : Fill this out - break; - } - } - - TString server_address_; - int sv_[2]; - EchoTestServiceStreamingImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_P(ParameterizedClientInterceptorsEnd2endTest, - ClientInterceptorLoggingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = CreateClientChannel(std::move(creators)); - SendRPC(channel); - LoggingInterceptor::VerifyCall(GetParam().rpc_type()); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -INSTANTIATE_TEST_SUITE_P(ParameterizedClientInterceptorsEnd2end, - ParameterizedClientInterceptorsEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios())); - -class ClientInterceptorsEnd2endTest - : public ::testing::TestWithParam<TestScenario> { - protected: - ClientInterceptorsEnd2endTest() { - int port = grpc_pick_unused_port_or_die(); - - ServerBuilder builder; - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - ~ClientInterceptorsEnd2endTest() override { server_->Shutdown(); } - - TString server_address_; - TestServiceImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_F(ClientInterceptorsEnd2endTest, - LameChannelClientInterceptorHijackingTest) { - ChannelArguments args; - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<HijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, nullptr, args, std::move(creators)); - MakeCall(channel); -} - -TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorHijackingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - // Add 20 phony interceptors before hijacking interceptor - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - creators.push_back(y_absl::make_unique<HijackingInterceptorFactory>()); - // Add 20 phony interceptors after hijacking interceptor - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); - // Make sure only 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -TEST_F(ClientInterceptorsEnd2endTest, ClientInterceptorLogThenHijackTest) { - ChannelArguments args; - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - creators.push_back(y_absl::make_unique<HijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); - LoggingInterceptor::VerifyUnaryCall(); -} - -TEST_F(ClientInterceptorsEnd2endTest, - ClientInterceptorHijackingMakesAnotherCallTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - // Add 5 phony interceptors before hijacking interceptor - creators.reserve(5); - for (auto i = 0; i < 5; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - creators.push_back( - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>( - new HijackingInterceptorMakesAnotherCallFactory())); - // Add 7 phony interceptors after hijacking interceptor - for (auto i = 0; i < 7; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = server_->experimental().InProcessChannelWithInterceptors( - args, std::move(creators)); - - MakeCall(channel, StubOptions("TestSuffixForStats")); - // Make sure all interceptors were run once, since the hijacking interceptor - // makes an RPC on the intercepted channel - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 12); -} - -class ClientInterceptorsCallbackEnd2endTest : public ::testing::Test { - protected: - ClientInterceptorsCallbackEnd2endTest() { - int port = grpc_pick_unused_port_or_die(); - - ServerBuilder builder; - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - ~ClientInterceptorsCallbackEnd2endTest() override { server_->Shutdown(); } - - TString server_address_; - TestServiceImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_F(ClientInterceptorsCallbackEnd2endTest, - ClientInterceptorLoggingTestWithCallback) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = server_->experimental().InProcessChannelWithInterceptors( - args, std::move(creators)); - MakeCallbackCall(channel); - LoggingInterceptor::VerifyUnaryCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -TEST_F(ClientInterceptorsCallbackEnd2endTest, - ClientInterceptorFactoryAllowsNullptrReturn) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors and 20 null interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - creators.push_back(y_absl::make_unique<NullInterceptorFactory>()); - } - auto channel = server_->experimental().InProcessChannelWithInterceptors( - args, std::move(creators)); - MakeCallbackCall(channel); - LoggingInterceptor::VerifyUnaryCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -class ClientInterceptorsStreamingEnd2endTest : public ::testing::Test { - protected: - ClientInterceptorsStreamingEnd2endTest() { - int port = grpc_pick_unused_port_or_die(); - - ServerBuilder builder; - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - ~ClientInterceptorsStreamingEnd2endTest() override { server_->Shutdown(); } - - TString server_address_; - EchoTestServiceStreamingImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeClientStreamingCall(channel); - LoggingInterceptor::VerifyClientStreamingCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeServerStreamingCall(channel); - LoggingInterceptor::VerifyServerStreamingCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingHijackingTest) { - ChannelArguments args; - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back( - y_absl::make_unique<ClientStreamingRpcHijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - - auto stub = grpc::testing::EchoTestService::NewStub( - channel, StubOptions("TestSuffixForStats")); - ClientContext ctx; - EchoRequest req; - EchoResponse resp; - req.mutable_param()->set_echo_metadata(true); - req.set_message("Hello"); - string expected_resp = ""; - auto writer = stub->RequestStream(&ctx, &resp); - for (int i = 0; i < 10; i++) { - EXPECT_TRUE(writer->Write(req)); - expected_resp += "Hello"; - } - // The interceptor will reject the 11th message - writer->Write(req); - Status s = writer->Finish(); - EXPECT_EQ(s.ok(), false); - EXPECT_TRUE(ClientStreamingRpcHijackingInterceptor::GotFailedSend()); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingHijackingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back( - y_absl::make_unique<ServerStreamingRpcHijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeServerStreamingCall(channel); - EXPECT_TRUE(ServerStreamingRpcHijackingInterceptor::GotFailedMessage()); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, - AsyncCQServerStreamingHijackingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back( - y_absl::make_unique<ServerStreamingRpcHijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeAsyncCQServerStreamingCall(channel); - EXPECT_TRUE(ServerStreamingRpcHijackingInterceptor::GotFailedMessage()); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingHijackingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back( - y_absl::make_unique<BidiStreamingRpcHijackingInterceptorFactory>()); - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeBidiStreamingCall(channel); -} - -TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingTest) { - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - creators.push_back(y_absl::make_unique<LoggingInterceptorFactory>()); - // Add 20 phony interceptors - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeBidiStreamingCall(channel); - LoggingInterceptor::VerifyBidiStreamingCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); -} - -class ClientGlobalInterceptorEnd2endTest : public ::testing::Test { - protected: - ClientGlobalInterceptorEnd2endTest() { - int port = grpc_pick_unused_port_or_die(); - - ServerBuilder builder; - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - ~ClientGlobalInterceptorEnd2endTest() override { server_->Shutdown(); } - - TString server_address_; - TestServiceImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_F(ClientGlobalInterceptorEnd2endTest, PhonyGlobalInterceptor) { - // We should ideally be registering a global interceptor only once per - // process, but for the purposes of testing, it should be fine to modify the - // registered global interceptor when there are no ongoing gRPC operations - PhonyInterceptorFactory global_factory; - experimental::RegisterGlobalClientInterceptorFactory(&global_factory); - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - // Add 20 phony interceptors - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); - // Make sure all 20 phony interceptors were run with the global interceptor - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 21); - experimental::TestOnlyResetGlobalClientInterceptorFactory(); -} - -TEST_F(ClientGlobalInterceptorEnd2endTest, LoggingGlobalInterceptor) { - // We should ideally be registering a global interceptor only once per - // process, but for the purposes of testing, it should be fine to modify the - // registered global interceptor when there are no ongoing gRPC operations - LoggingInterceptorFactory global_factory; - experimental::RegisterGlobalClientInterceptorFactory(&global_factory); - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - // Add 20 phony interceptors - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); - LoggingInterceptor::VerifyUnaryCall(); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); - experimental::TestOnlyResetGlobalClientInterceptorFactory(); -} - -TEST_F(ClientGlobalInterceptorEnd2endTest, HijackingGlobalInterceptor) { - // We should ideally be registering a global interceptor only once per - // process, but for the purposes of testing, it should be fine to modify the - // registered global interceptor when there are no ongoing gRPC operations - HijackingInterceptorFactory global_factory; - experimental::RegisterGlobalClientInterceptorFactory(&global_factory); - ChannelArguments args; - PhonyInterceptor::Reset(); - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - creators; - // Add 20 phony interceptors - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - auto channel = experimental::CreateCustomChannelWithInterceptors( - server_address_, InsecureChannelCredentials(), args, std::move(creators)); - MakeCall(channel); - // Make sure all 20 phony interceptors were run - EXPECT_EQ(PhonyInterceptor::GetNumTimesRun(), 20); - experimental::TestOnlyResetGlobalClientInterceptorFactory(); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/client_lb_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/client_lb_end2end_test.cc deleted file mode 100644 index 31bac68e6d..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/client_lb_end2end_test.cc +++ /dev/null @@ -1,2023 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <memory> -#include <mutex> -#include <random> -#include <set> -#include <util/generic/string.h> -#include <thread> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" -#include "y_absl/strings/str_cat.h" -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_join.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/health_check_service_interface.h> -#include <grpcpp/impl/codegen/sync.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/ext/filters/client_channel/global_subchannel_pool.h" -#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/ext/service_config/service_config.h" -#include "src/core/lib/address_utils/parse_address.h" -#include "src/core/lib/backoff/backoff.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/gprpp/debug_location.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/tcp_client.h" -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/cpp/server/secure_server_credentials.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "src/proto/grpc/testing/xds/v3/orca_load_report.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/resolve_localhost_ip46.h" -#include "test/core/util/test_config.h" -#include "test/core/util/test_lb_policies.h" -#include "test/cpp/end2end/test_service_impl.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -// defined in tcp_client.cc -extern grpc_tcp_client_vtable* grpc_tcp_client_impl; - -static grpc_tcp_client_vtable* default_client_impl; - -namespace grpc { -namespace testing { -namespace { - -gpr_atm g_connection_delay_ms; - -void tcp_client_connect_with_delay(grpc_closure* closure, grpc_endpoint** ep, - grpc_pollset_set* interested_parties, - const grpc_channel_args* channel_args, - const grpc_resolved_address* addr, - grpc_millis deadline) { - const int delay_ms = gpr_atm_acq_load(&g_connection_delay_ms); - if (delay_ms > 0) { - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(delay_ms)); - } - default_client_impl->connect(closure, ep, interested_parties, channel_args, - addr, deadline + delay_ms); -} - -grpc_tcp_client_vtable delayed_connect = {tcp_client_connect_with_delay}; - -// Subclass of TestServiceImpl that increments a request counter for -// every call to the Echo RPC. -class MyTestServiceImpl : public TestServiceImpl { - public: - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - const xds::data::orca::v3::OrcaLoadReport* load_report = nullptr; - { - grpc::internal::MutexLock lock(&mu_); - ++request_count_; - load_report = load_report_; - } - AddClient(context->peer().c_str()); - if (load_report != nullptr) { - // TODO(roth): Once we provide a more standard server-side API for - // populating this data, use that API here. - context->AddTrailingMetadata("x-endpoint-load-metrics-bin", - load_report->SerializeAsString()); - } - return TestServiceImpl::Echo(context, request, response); - } - - int request_count() { - grpc::internal::MutexLock lock(&mu_); - return request_count_; - } - - void ResetCounters() { - grpc::internal::MutexLock lock(&mu_); - request_count_ = 0; - } - - std::set<TString> clients() { - grpc::internal::MutexLock lock(&clients_mu_); - return clients_; - } - - void set_load_report(xds::data::orca::v3::OrcaLoadReport* load_report) { - grpc::internal::MutexLock lock(&mu_); - load_report_ = load_report; - } - - private: - void AddClient(const TString& client) { - grpc::internal::MutexLock lock(&clients_mu_); - clients_.insert(client); - } - - grpc::internal::Mutex mu_; - int request_count_ = 0; - const xds::data::orca::v3::OrcaLoadReport* load_report_ = nullptr; - grpc::internal::Mutex clients_mu_; - std::set<TString> clients_; -}; - -class FakeResolverResponseGeneratorWrapper { - public: - explicit FakeResolverResponseGeneratorWrapper(bool ipv6_only) - : ipv6_only_(ipv6_only), - response_generator_(grpc_core::MakeRefCounted< - grpc_core::FakeResolverResponseGenerator>()) {} - - FakeResolverResponseGeneratorWrapper( - FakeResolverResponseGeneratorWrapper&& other) noexcept { - ipv6_only_ = other.ipv6_only_; - response_generator_ = std::move(other.response_generator_); - } - - void SetNextResolution( - const std::vector<int>& ports, const char* service_config_json = nullptr, - const char* attribute_key = nullptr, - std::unique_ptr<grpc_core::ServerAddress::AttributeInterface> attribute = - nullptr) { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetResponse( - BuildFakeResults(ipv6_only_, ports, service_config_json, attribute_key, - std::move(attribute))); - } - - void SetNextResolutionUponError(const std::vector<int>& ports) { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetReresolutionResponse( - BuildFakeResults(ipv6_only_, ports)); - } - - void SetFailureOnReresolution() { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetFailureOnReresolution(); - } - - grpc_core::FakeResolverResponseGenerator* Get() const { - return response_generator_.get(); - } - - private: - static grpc_core::Resolver::Result BuildFakeResults( - bool ipv6_only, const std::vector<int>& ports, - const char* service_config_json = nullptr, - const char* attribute_key = nullptr, - std::unique_ptr<grpc_core::ServerAddress::AttributeInterface> attribute = - nullptr) { - grpc_core::Resolver::Result result; - for (const int& port : ports) { - y_absl::StatusOr<grpc_core::URI> lb_uri = grpc_core::URI::Parse( - y_absl::StrCat(ipv6_only ? "ipv6:[::1]:" : "ipv4:127.0.0.1:", port)); - GPR_ASSERT(lb_uri.ok()); - grpc_resolved_address address; - GPR_ASSERT(grpc_parse_uri(*lb_uri, &address)); - std::map<const char*, - std::unique_ptr<grpc_core::ServerAddress::AttributeInterface>> - attributes; - if (attribute != nullptr) { - attributes[attribute_key] = attribute->Copy(); - } - result.addresses.emplace_back(address.addr, address.len, - nullptr /* args */, std::move(attributes)); - } - if (service_config_json != nullptr) { - result.service_config = grpc_core::ServiceConfig::Create( - nullptr, service_config_json, &result.service_config_error); - GPR_ASSERT(result.service_config != nullptr); - } - return result; - } - - bool ipv6_only_ = false; - grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> - response_generator_; -}; - -class ClientLbEnd2endTest : public ::testing::Test { - protected: - ClientLbEnd2endTest() - : server_host_("localhost"), - kRequestMessage_("Live long and prosper."), - creds_(new SecureChannelCredentials( - grpc_fake_transport_security_credentials_create())) {} - - static void SetUpTestCase() { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - } - - void SetUp() override { - grpc_init(); - bool localhost_resolves_to_ipv4 = false; - bool localhost_resolves_to_ipv6 = false; - grpc_core::LocalhostResolves(&localhost_resolves_to_ipv4, - &localhost_resolves_to_ipv6); - ipv6_only_ = !localhost_resolves_to_ipv4 && localhost_resolves_to_ipv6; - } - - void TearDown() override { - for (size_t i = 0; i < servers_.size(); ++i) { - servers_[i]->Shutdown(); - } - servers_.clear(); - creds_.reset(); - grpc_shutdown(); - } - - void CreateServers(size_t num_servers, - std::vector<int> ports = std::vector<int>()) { - servers_.clear(); - for (size_t i = 0; i < num_servers; ++i) { - int port = 0; - if (ports.size() == num_servers) port = ports[i]; - servers_.emplace_back(new ServerData(port)); - } - } - - void StartServer(size_t index) { servers_[index]->Start(server_host_); } - - void StartServers(size_t num_servers, - std::vector<int> ports = std::vector<int>()) { - CreateServers(num_servers, std::move(ports)); - for (size_t i = 0; i < num_servers; ++i) { - StartServer(i); - } - } - - std::vector<int> GetServersPorts(size_t start_index = 0) { - std::vector<int> ports; - for (size_t i = start_index; i < servers_.size(); ++i) { - ports.push_back(servers_[i]->port_); - } - return ports; - } - - FakeResolverResponseGeneratorWrapper BuildResolverResponseGenerator() { - return FakeResolverResponseGeneratorWrapper(ipv6_only_); - } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> BuildStub( - const std::shared_ptr<Channel>& channel) { - return grpc::testing::EchoTestService::NewStub(channel); - } - - std::shared_ptr<Channel> BuildChannel( - const TString& lb_policy_name, - const FakeResolverResponseGeneratorWrapper& response_generator, - ChannelArguments args = ChannelArguments()) { - if (!lb_policy_name.empty()) { - args.SetLoadBalancingPolicyName(lb_policy_name); - } // else, default to pick first - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator.Get()); - return ::grpc::CreateCustomChannel("fake:///", creds_, args); - } - - bool SendRpc( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - EchoResponse* response = nullptr, int timeout_ms = 1000, - Status* result = nullptr, bool wait_for_ready = false) { - const bool local_response = (response == nullptr); - if (local_response) response = new EchoResponse; - EchoRequest request; - request.set_message(kRequestMessage_); - request.mutable_param()->set_echo_metadata(true); - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); - if (wait_for_ready) context.set_wait_for_ready(true); - context.AddMetadata("foo", "1"); - context.AddMetadata("bar", "2"); - context.AddMetadata("baz", "3"); - Status status = stub->Echo(&context, request, response); - if (result != nullptr) *result = status; - if (local_response) delete response; - return status.ok(); - } - - void CheckRpcSendOk( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - const grpc_core::DebugLocation& location, bool wait_for_ready = false) { - EchoResponse response; - Status status; - const bool success = - SendRpc(stub, &response, 2000, &status, wait_for_ready); - ASSERT_TRUE(success) << "From " << location.file() << ":" << location.line() - << "\n" - << "Error: " << status.error_message() << " " - << status.error_details(); - ASSERT_EQ(response.message(), kRequestMessage_) - << "From " << location.file() << ":" << location.line(); - if (!success) abort(); - } - - void CheckRpcSendFailure( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub) { - const bool success = SendRpc(stub); - EXPECT_FALSE(success); - } - - struct ServerData { - const int port_; - std::unique_ptr<Server> server_; - MyTestServiceImpl service_; - std::unique_ptr<std::thread> thread_; - - grpc::internal::Mutex mu_; - grpc::internal::CondVar cond_; - bool server_ready_ Y_ABSL_GUARDED_BY(mu_) = false; - bool started_ Y_ABSL_GUARDED_BY(mu_) = false; - - explicit ServerData(int port = 0) - : port_(port > 0 ? port : 5100) {} - - void Start(const TString& server_host) { - gpr_log(GPR_INFO, "starting server on port %d", port_); - grpc::internal::MutexLock lock(&mu_); - started_ = true; - thread_ = y_absl::make_unique<std::thread>( - std::bind(&ServerData::Serve, this, server_host)); - while (!server_ready_) { - cond_.Wait(&mu_); - } - server_ready_ = false; - gpr_log(GPR_INFO, "server startup complete"); - } - - void Serve(const TString& server_host) { - std::ostringstream server_address; - server_address << server_host << ":" << port_; - ServerBuilder builder; - std::shared_ptr<ServerCredentials> creds(new SecureServerCredentials( - grpc_fake_transport_security_server_credentials_create())); - builder.AddListeningPort(server_address.str(), std::move(creds)); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - grpc::internal::MutexLock lock(&mu_); - server_ready_ = true; - cond_.Signal(); - } - - void Shutdown() { - grpc::internal::MutexLock lock(&mu_); - if (!started_) return; - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - thread_->join(); - started_ = false; - } - - void SetServingStatus(const TString& service, bool serving) { - server_->GetHealthCheckService()->SetServingStatus(service, serving); - } - }; - - void ResetCounters() { - for (const auto& server : servers_) server->service_.ResetCounters(); - } - - void WaitForServer( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - size_t server_idx, const grpc_core::DebugLocation& location, - bool ignore_failure = false) { - do { - if (ignore_failure) { - SendRpc(stub); - } else { - CheckRpcSendOk(stub, location, true); - } - } while (servers_[server_idx]->service_.request_count() == 0); - ResetCounters(); - } - - bool WaitForChannelState( - Channel* channel, - const std::function<bool(grpc_connectivity_state)>& predicate, - bool try_to_connect = false, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - while (true) { - grpc_connectivity_state state = channel->GetState(try_to_connect); - if (predicate(state)) break; - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { - auto predicate = [](grpc_connectivity_state state) { - return state != GRPC_CHANNEL_READY; - }; - return WaitForChannelState(channel, predicate, false, timeout_seconds); - } - - bool WaitForChannelReady(Channel* channel, int timeout_seconds = 5) { - auto predicate = [](grpc_connectivity_state state) { - return state == GRPC_CHANNEL_READY; - }; - return WaitForChannelState(channel, predicate, true, timeout_seconds); - } - - bool SeenAllServers() { - for (const auto& server : servers_) { - if (server->service_.request_count() == 0) return false; - } - return true; - } - - // Updates \a connection_order by appending to it the index of the newly - // connected server. Must be called after every single RPC. - void UpdateConnectionOrder( - const std::vector<std::unique_ptr<ServerData>>& servers, - std::vector<int>* connection_order) { - for (size_t i = 0; i < servers.size(); ++i) { - if (servers[i]->service_.request_count() == 1) { - // Was the server index known? If not, update connection_order. - const auto it = - std::find(connection_order->begin(), connection_order->end(), i); - if (it == connection_order->end()) { - connection_order->push_back(i); - return; - } - } - } - } - - const TString server_host_; - std::vector<std::unique_ptr<ServerData>> servers_; - const TString kRequestMessage_; - std::shared_ptr<ChannelCredentials> creds_; - bool ipv6_only_ = false; -}; - -TEST_F(ClientLbEnd2endTest, ChannelStateConnectingWhenResolving) { - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("", response_generator); - auto stub = BuildStub(channel); - // Initial state should be IDLE. - EXPECT_EQ(channel->GetState(false /* try_to_connect */), GRPC_CHANNEL_IDLE); - // Tell the channel to try to connect. - // Note that this call also returns IDLE, since the state change has - // not yet occurred; it just gets triggered by this call. - EXPECT_EQ(channel->GetState(true /* try_to_connect */), GRPC_CHANNEL_IDLE); - // Now that the channel is trying to connect, we should be in state - // CONNECTING. - EXPECT_EQ(channel->GetState(false /* try_to_connect */), - GRPC_CHANNEL_CONNECTING); - // Return a resolver result, which allows the connection attempt to proceed. - response_generator.SetNextResolution(GetServersPorts()); - // We should eventually transition into state READY. - EXPECT_TRUE(WaitForChannelReady(channel.get())); -} - -TEST_F(ClientLbEnd2endTest, PickFirst) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel( - "", response_generator); // test that pick first is the default. - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // All requests should have gone to a single server. - bool found = false; - for (size_t i = 0; i < servers_.size(); ++i) { - const int request_count = servers_[i]->service_.request_count(); - if (request_count == kNumServers) { - found = true; - } else { - EXPECT_EQ(0, request_count); - } - } - EXPECT_TRUE(found); - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstProcessPending) { - StartServers(1); // Single server - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel( - "", response_generator); // test that pick first is the default. - auto stub = BuildStub(channel); - response_generator.SetNextResolution({servers_[0]->port_}); - WaitForServer(stub, 0, DEBUG_LOCATION); - // Create a new channel and its corresponding PF LB policy, which will pick - // the subchannels in READY state from the previous RPC against the same - // target (even if it happened over a different channel, because subchannels - // are globally reused). Progress should happen without any transition from - // this READY state. - auto second_response_generator = BuildResolverResponseGenerator(); - auto second_channel = BuildChannel("", second_response_generator); - auto second_stub = BuildStub(second_channel); - second_response_generator.SetNextResolution({servers_[0]->port_}); - CheckRpcSendOk(second_stub, DEBUG_LOCATION); -} - -TEST_F(ClientLbEnd2endTest, PickFirstSelectsReadyAtStartup) { - ChannelArguments args; - constexpr int kInitialBackOffMs = 5000; - args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); - // Create 2 servers, but start only the second one. - std::vector<int> ports = { 5101, // grpc_pick_unused_port_or_die(), - 5102}; // grpc_pick_unused_port_or_die()}; - CreateServers(2, ports); - StartServer(1); - auto response_generator1 = BuildResolverResponseGenerator(); - auto channel1 = BuildChannel("pick_first", response_generator1, args); - auto stub1 = BuildStub(channel1); - response_generator1.SetNextResolution(ports); - // Wait for second server to be ready. - WaitForServer(stub1, 1, DEBUG_LOCATION); - // Create a second channel with the same addresses. Its PF instance - // should immediately pick the second subchannel, since it's already - // in READY state. - auto response_generator2 = BuildResolverResponseGenerator(); - auto channel2 = BuildChannel("pick_first", response_generator2, args); - response_generator2.SetNextResolution(ports); - // Check that the channel reports READY without waiting for the - // initial backoff. - EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1 /* timeout_seconds */)); -} - -TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) { - ChannelArguments args; - constexpr int kInitialBackOffMs = 100; - args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); - const std::vector<int> ports = {5103}; // {grpc_pick_unused_port_or_die()}; - const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - // The channel won't become connected (there's no server). - ASSERT_FALSE(channel->WaitForConnected( - grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2))); - // Bring up a server on the chosen port. - StartServers(1, ports); - // Now it will. - ASSERT_TRUE(channel->WaitForConnected( - grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2))); - const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); - const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); - gpr_log(GPR_DEBUG, "Waited %" PRId64 " milliseconds", waited_ms); - // We should have waited at least kInitialBackOffMs. We substract one to - // account for test and precision accuracy drift. - EXPECT_GE(waited_ms, kInitialBackOffMs - 1); - // But not much more. - EXPECT_GT( - gpr_time_cmp( - grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 1.10), t1), - 0); -} - -TEST_F(ClientLbEnd2endTest, PickFirstBackOffMinReconnect) { - ChannelArguments args; - constexpr int kMinReconnectBackOffMs = 1000; - args.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, kMinReconnectBackOffMs); - const std::vector<int> ports = {5104}; // {grpc_pick_unused_port_or_die()}; - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - // Make connection delay a 10% longer than it's willing to in order to make - // sure we are hitting the codepath that waits for the min reconnect backoff. - gpr_atm_rel_store(&g_connection_delay_ms, kMinReconnectBackOffMs * 1.10); - default_client_impl = grpc_tcp_client_impl; - grpc_set_tcp_client_impl(&delayed_connect); - const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - channel->WaitForConnected( - grpc_timeout_milliseconds_to_deadline(kMinReconnectBackOffMs * 2)); - const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); - const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); - gpr_log(GPR_DEBUG, "Waited %" PRId64 " ms", waited_ms); - // We should have waited at least kMinReconnectBackOffMs. We substract one to - // account for test and precision accuracy drift. - EXPECT_GE(waited_ms, kMinReconnectBackOffMs - 1); - gpr_atm_rel_store(&g_connection_delay_ms, 0); -} - -TEST_F(ClientLbEnd2endTest, PickFirstResetConnectionBackoff) { - ChannelArguments args; - constexpr int kInitialBackOffMs = 1000; - args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); - const std::vector<int> ports = {5105}; // {grpc_pick_unused_port_or_die()}; - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - // The channel won't become connected (there's no server). - EXPECT_FALSE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10))); - // Bring up a server on the chosen port. - StartServers(1, ports); - const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - // Wait for connect, but not long enough. This proves that we're - // being throttled by initial backoff. - EXPECT_FALSE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10))); - // Reset connection backoff. - experimental::ChannelResetConnectionBackoff(channel.get()); - // Wait for connect. Should happen as soon as the client connects to - // the newly started server, which should be before the initial - // backoff timeout elapses. - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(20))); - const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); - const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); - gpr_log(GPR_DEBUG, "Waited %" PRId64 " milliseconds", waited_ms); - // We should have waited less than kInitialBackOffMs. - EXPECT_LT(waited_ms, kInitialBackOffMs); -} - -TEST_F(ClientLbEnd2endTest, - PickFirstResetConnectionBackoffNextAttemptStartsImmediately) { - ChannelArguments args; - constexpr int kInitialBackOffMs = 1000; - args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); - const std::vector<int> ports = {5106}; // {grpc_pick_unused_port_or_die()}; - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - // Wait for connect, which should fail ~immediately, because the server - // is not up. - gpr_log(GPR_INFO, "=== INITIAL CONNECTION ATTEMPT"); - EXPECT_FALSE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10))); - // Reset connection backoff. - // Note that the time at which the third attempt will be started is - // actually computed at this point, so we record the start time here. - gpr_log(GPR_INFO, "=== RESETTING BACKOFF"); - const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - experimental::ChannelResetConnectionBackoff(channel.get()); - // Trigger a second connection attempt. This should also fail - // ~immediately, but the retry should be scheduled for - // kInitialBackOffMs instead of applying the multiplier. - gpr_log(GPR_INFO, "=== POLLING FOR SECOND CONNECTION ATTEMPT"); - EXPECT_FALSE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10))); - // Bring up a server on the chosen port. - gpr_log(GPR_INFO, "=== STARTING BACKEND"); - StartServers(1, ports); - // Wait for connect. Should happen within kInitialBackOffMs. - // Give an extra 100ms to account for the time spent in the second and - // third connection attempts themselves (since what we really want to - // measure is the time between the two). As long as this is less than - // the 1.6x increase we would see if the backoff state was not reset - // properly, the test is still proving that the backoff was reset. - constexpr int kWaitMs = kInitialBackOffMs + 100; - gpr_log(GPR_INFO, "=== POLLING FOR THIRD CONNECTION ATTEMPT"); - EXPECT_TRUE(channel->WaitForConnected( - grpc_timeout_milliseconds_to_deadline(kWaitMs))); - const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); - const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); - gpr_log(GPR_DEBUG, "Waited %" PRId64 " milliseconds", waited_ms); - EXPECT_LT(waited_ms, kWaitMs); -} - -TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - - std::vector<int> ports; - - // Perform one RPC against the first server. - ports.emplace_back(servers_[0]->port_); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET [0] *******"); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(servers_[0]->service_.request_count(), 1); - - // An empty update will result in the channel going into TRANSIENT_FAILURE. - ports.clear(); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET none *******"); - grpc_connectivity_state channel_state; - do { - channel_state = channel->GetState(true /* try to connect */); - } while (channel_state == GRPC_CHANNEL_READY); - ASSERT_NE(channel_state, GRPC_CHANNEL_READY); - servers_[0]->service_.ResetCounters(); - - // Next update introduces servers_[1], making the channel recover. - ports.clear(); - ports.emplace_back(servers_[1]->port_); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET [1] *******"); - WaitForServer(stub, 1, DEBUG_LOCATION); - EXPECT_EQ(servers_[0]->service_.request_count(), 0); - - // And again for servers_[2] - ports.clear(); - ports.emplace_back(servers_[2]->port_); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET [2] *******"); - WaitForServer(stub, 2, DEBUG_LOCATION); - EXPECT_EQ(servers_[0]->service_.request_count(), 0); - EXPECT_EQ(servers_[1]->service_.request_count(), 0); - - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - - std::vector<int> ports; - - // Perform one RPC against the first server. - ports.emplace_back(servers_[0]->port_); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET [0] *******"); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(servers_[0]->service_.request_count(), 1); - servers_[0]->service_.ResetCounters(); - - // Send and superset update - ports.clear(); - ports.emplace_back(servers_[1]->port_); - ports.emplace_back(servers_[0]->port_); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** SET superset *******"); - CheckRpcSendOk(stub, DEBUG_LOCATION); - // We stick to the previously connected server. - WaitForServer(stub, 0, DEBUG_LOCATION); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstGlobalSubchannelPool) { - // Start one server. - const int kNumServers = 1; - StartServers(kNumServers); - std::vector<int> ports = GetServersPorts(); - // Create two channels that (by default) use the global subchannel pool. - auto response_generator1 = BuildResolverResponseGenerator(); - auto channel1 = BuildChannel("pick_first", response_generator1); - auto stub1 = BuildStub(channel1); - response_generator1.SetNextResolution(ports); - auto response_generator2 = BuildResolverResponseGenerator(); - auto channel2 = BuildChannel("pick_first", response_generator2); - auto stub2 = BuildStub(channel2); - response_generator2.SetNextResolution(ports); - WaitForServer(stub1, 0, DEBUG_LOCATION); - // Send one RPC on each channel. - CheckRpcSendOk(stub1, DEBUG_LOCATION); - CheckRpcSendOk(stub2, DEBUG_LOCATION); - // The server receives two requests. - EXPECT_EQ(2, servers_[0]->service_.request_count()); - // The two requests are from the same client port, because the two channels - // share subchannels via the global subchannel pool. - EXPECT_EQ(1UL, servers_[0]->service_.clients().size()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstLocalSubchannelPool) { - // Start one server. - const int kNumServers = 1; - StartServers(kNumServers); - std::vector<int> ports = GetServersPorts(); - // Create two channels that use local subchannel pool. - ChannelArguments args; - args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); - auto response_generator1 = BuildResolverResponseGenerator(); - auto channel1 = BuildChannel("pick_first", response_generator1, args); - auto stub1 = BuildStub(channel1); - response_generator1.SetNextResolution(ports); - auto response_generator2 = BuildResolverResponseGenerator(); - auto channel2 = BuildChannel("pick_first", response_generator2, args); - auto stub2 = BuildStub(channel2); - response_generator2.SetNextResolution(ports); - WaitForServer(stub1, 0, DEBUG_LOCATION); - // Send one RPC on each channel. - CheckRpcSendOk(stub1, DEBUG_LOCATION); - CheckRpcSendOk(stub2, DEBUG_LOCATION); - // The server receives two requests. - EXPECT_EQ(2, servers_[0]->service_.request_count()); - // The two requests are from two client ports, because the two channels didn't - // share subchannels with each other. - EXPECT_EQ(2UL, servers_[0]->service_.clients().size()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) { - const int kNumUpdates = 1000; - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - std::vector<int> ports = GetServersPorts(); - for (size_t i = 0; i < kNumUpdates; ++i) { - std::shuffle(ports.begin(), ports.end(), - std::mt19937(std::random_device()())); - response_generator.SetNextResolution(ports); - // We should re-enter core at the end of the loop to give the resolution - // setting closure a chance to run. - if ((i + 1) % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstReresolutionNoSelected) { - // Prepare the ports for up servers and down servers. - const int kNumServers = 3; - const int kNumAliveServers = 1; - StartServers(kNumAliveServers); - std::vector<int> alive_ports, dead_ports; - for (size_t i = 0; i < kNumServers; ++i) { - if (i < kNumAliveServers) { - alive_ports.emplace_back(servers_[i]->port_); - } else { - dead_ports.emplace_back(5107 + i); - // dead_ports.emplace_back(grpc_pick_unused_port_or_die()); - } - } - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - // The initial resolution only contains dead ports. There won't be any - // selected subchannel. Re-resolution will return the same result. - response_generator.SetNextResolution(dead_ports); - gpr_log(GPR_INFO, "****** INITIAL RESOLUTION SET *******"); - for (size_t i = 0; i < 10; ++i) CheckRpcSendFailure(stub); - // Set a re-resolution result that contains reachable ports, so that the - // pick_first LB policy can recover soon. - response_generator.SetNextResolutionUponError(alive_ports); - gpr_log(GPR_INFO, "****** RE-RESOLUTION SET *******"); - WaitForServer(stub, 0, DEBUG_LOCATION, true /* ignore_failure */); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(servers_[0]->service_.request_count(), 1); - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstReconnectWithoutNewResolverResult) { - std::vector<int> ports = {5110}; // {grpc_pick_unused_port_or_die()}; - StartServers(1, ports); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******"); - WaitForServer(stub, 0, DEBUG_LOCATION); - gpr_log(GPR_INFO, "****** STOPPING SERVER ******"); - servers_[0]->Shutdown(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - gpr_log(GPR_INFO, "****** RESTARTING SERVER ******"); - StartServers(1, ports); - WaitForServer(stub, 0, DEBUG_LOCATION); -} - -TEST_F(ClientLbEnd2endTest, - PickFirstReconnectWithoutNewResolverResultStartsFromTopOfList) { - std::vector<int> ports = {5111, // grpc_pick_unused_port_or_die(), - 5112}; // grpc_pick_unused_port_or_die()}; - CreateServers(2, ports); - StartServer(1); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("pick_first", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******"); - WaitForServer(stub, 1, DEBUG_LOCATION); - gpr_log(GPR_INFO, "****** STOPPING SERVER ******"); - servers_[1]->Shutdown(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - gpr_log(GPR_INFO, "****** STARTING BOTH SERVERS ******"); - StartServers(2, ports); - WaitForServer(stub, 0, DEBUG_LOCATION); -} - -TEST_F(ClientLbEnd2endTest, PickFirstCheckStateBeforeStartWatch) { - std::vector<int> ports = {5113}; // {grpc_pick_unused_port_or_die()}; - StartServers(1, ports); - auto response_generator = BuildResolverResponseGenerator(); - auto channel_1 = BuildChannel("pick_first", response_generator); - auto stub_1 = BuildStub(channel_1); - response_generator.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 1 *******"); - WaitForServer(stub_1, 0, DEBUG_LOCATION); - gpr_log(GPR_INFO, "****** CHANNEL 1 CONNECTED *******"); - servers_[0]->Shutdown(); - // Channel 1 will receive a re-resolution containing the same server. It will - // create a new subchannel and hold a ref to it. - StartServers(1, ports); - gpr_log(GPR_INFO, "****** SERVER RESTARTED *******"); - auto response_generator_2 = BuildResolverResponseGenerator(); - auto channel_2 = BuildChannel("pick_first", response_generator_2); - auto stub_2 = BuildStub(channel_2); - response_generator_2.SetNextResolution(ports); - gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 2 *******"); - WaitForServer(stub_2, 0, DEBUG_LOCATION, true); - gpr_log(GPR_INFO, "****** CHANNEL 2 CONNECTED *******"); - servers_[0]->Shutdown(); - // Wait until the disconnection has triggered the connectivity notification. - // Otherwise, the subchannel may be picked for next call but will fail soon. - EXPECT_TRUE(WaitForChannelNotReady(channel_2.get())); - // Channel 2 will also receive a re-resolution containing the same server. - // Both channels will ref the same subchannel that failed. - StartServers(1, ports); - gpr_log(GPR_INFO, "****** SERVER RESTARTED AGAIN *******"); - gpr_log(GPR_INFO, "****** CHANNEL 2 STARTING A CALL *******"); - // The first call after the server restart will succeed. - CheckRpcSendOk(stub_2, DEBUG_LOCATION); - gpr_log(GPR_INFO, "****** CHANNEL 2 FINISHED A CALL *******"); - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_1->GetLoadBalancingPolicyName()); - // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_2->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, PickFirstIdleOnDisconnect) { - // Start server, send RPC, and make sure channel is READY. - const int kNumServers = 1; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("", response_generator); // pick_first is the default. - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - // Stop server. Channel should go into state IDLE. - response_generator.SetFailureOnReresolution(); - servers_[0]->Shutdown(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); - servers_.clear(); -} - -TEST_F(ClientLbEnd2endTest, PickFirstPendingUpdateAndSelectedSubchannelFails) { - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("", response_generator); // pick_first is the default. - auto stub = BuildStub(channel); - // Create a number of servers, but only start 1 of them. - CreateServers(10); - StartServer(0); - // Initially resolve to first server and make sure it connects. - gpr_log(GPR_INFO, "Phase 1: Connect to first server."); - response_generator.SetNextResolution({servers_[0]->port_}); - CheckRpcSendOk(stub, DEBUG_LOCATION, true /* wait_for_ready */); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - // Send a resolution update with the remaining servers, none of which are - // running yet, so the update will stay pending. Note that it's important - // to have multiple servers here, or else the test will be flaky; with only - // one server, the pending subchannel list has already gone into - // TRANSIENT_FAILURE due to hitting the end of the list by the time we - // check the state. - gpr_log(GPR_INFO, - "Phase 2: Resolver update pointing to remaining " - "(not started) servers."); - response_generator.SetNextResolution(GetServersPorts(1 /* start_index */)); - // RPCs will continue to be sent to the first server. - CheckRpcSendOk(stub, DEBUG_LOCATION); - // Now stop the first server, so that the current subchannel list - // fails. This should cause us to immediately swap over to the - // pending list, even though it's not yet connected. The state should - // be set to CONNECTING, since that's what the pending subchannel list - // was doing when we swapped over. - gpr_log(GPR_INFO, "Phase 3: Stopping first server."); - servers_[0]->Shutdown(); - WaitForChannelNotReady(channel.get()); - // TODO(roth): This should always return CONNECTING, but it's flaky - // between that and TRANSIENT_FAILURE. I suspect that this problem - // will go away once we move the backoff code out of the subchannel - // and into the LB policies. - EXPECT_THAT(channel->GetState(false), - ::testing::AnyOf(GRPC_CHANNEL_CONNECTING, - GRPC_CHANNEL_TRANSIENT_FAILURE)); - // Now start the second server. - gpr_log(GPR_INFO, "Phase 4: Starting second server."); - StartServer(1); - // The channel should go to READY state and RPCs should go to the - // second server. - WaitForChannelReady(channel.get()); - WaitForServer(stub, 1, DEBUG_LOCATION, true /* ignore_failure */); -} - -TEST_F(ClientLbEnd2endTest, PickFirstStaysIdleUponEmptyUpdate) { - // Start server, send RPC, and make sure channel is READY. - const int kNumServers = 1; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("", response_generator); // pick_first is the default. - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - // Stop server. Channel should go into state IDLE. - servers_[0]->Shutdown(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); - // Now send resolver update that includes no addresses. Channel - // should stay in state IDLE. - response_generator.SetNextResolution({}); - EXPECT_FALSE(channel->WaitForStateChange( - GRPC_CHANNEL_IDLE, grpc_timeout_seconds_to_deadline(3))); - // Now bring the backend back up and send a non-empty resolver update, - // and then try to send an RPC. Channel should go back into state READY. - StartServer(0); - response_generator.SetNextResolution(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); -} - -TEST_F(ClientLbEnd2endTest, RoundRobin) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - // Wait until all backends are ready. - do { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } while (!SeenAllServers()); - ResetCounters(); - // "Sync" to the end of the list. Next sequence of picks will start at the - // first server (index 0). - WaitForServer(stub, servers_.size() - 1, DEBUG_LOCATION); - std::vector<int> connection_order; - for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - UpdateConnectionOrder(servers_, &connection_order); - } - // Backends should be iterated over in the order in which the addresses were - // given. - const auto expected = std::vector<int>{0, 1, 2}; - EXPECT_EQ(expected, connection_order); - // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinProcessPending) { - StartServers(1); // Single server - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution({servers_[0]->port_}); - WaitForServer(stub, 0, DEBUG_LOCATION); - // Create a new channel and its corresponding RR LB policy, which will pick - // the subchannels in READY state from the previous RPC against the same - // target (even if it happened over a different channel, because subchannels - // are globally reused). Progress should happen without any transition from - // this READY state. - auto second_response_generator = BuildResolverResponseGenerator(); - auto second_channel = BuildChannel("round_robin", second_response_generator); - auto second_stub = BuildStub(second_channel); - second_response_generator.SetNextResolution({servers_[0]->port_}); - CheckRpcSendOk(second_stub, DEBUG_LOCATION); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - std::vector<int> ports; - // Start with a single server. - gpr_log(GPR_INFO, "*** FIRST BACKEND ***"); - ports.emplace_back(servers_[0]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 0, DEBUG_LOCATION); - // Send RPCs. They should all go servers_[0] - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(10, servers_[0]->service_.request_count()); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - EXPECT_EQ(0, servers_[2]->service_.request_count()); - servers_[0]->service_.ResetCounters(); - // And now for the second server. - gpr_log(GPR_INFO, "*** SECOND BACKEND ***"); - ports.clear(); - ports.emplace_back(servers_[1]->port_); - response_generator.SetNextResolution(ports); - // Wait until update has been processed, as signaled by the second backend - // receiving a request. - EXPECT_EQ(0, servers_[1]->service_.request_count()); - WaitForServer(stub, 1, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(0, servers_[0]->service_.request_count()); - EXPECT_EQ(10, servers_[1]->service_.request_count()); - EXPECT_EQ(0, servers_[2]->service_.request_count()); - servers_[1]->service_.ResetCounters(); - // ... and for the last server. - gpr_log(GPR_INFO, "*** THIRD BACKEND ***"); - ports.clear(); - ports.emplace_back(servers_[2]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 2, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(0, servers_[0]->service_.request_count()); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - EXPECT_EQ(10, servers_[2]->service_.request_count()); - servers_[2]->service_.ResetCounters(); - // Back to all servers. - gpr_log(GPR_INFO, "*** ALL BACKENDS ***"); - ports.clear(); - ports.emplace_back(servers_[0]->port_); - ports.emplace_back(servers_[1]->port_); - ports.emplace_back(servers_[2]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 0, DEBUG_LOCATION); - WaitForServer(stub, 1, DEBUG_LOCATION); - WaitForServer(stub, 2, DEBUG_LOCATION); - // Send three RPCs, one per server. - for (size_t i = 0; i < 3; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(1, servers_[0]->service_.request_count()); - EXPECT_EQ(1, servers_[1]->service_.request_count()); - EXPECT_EQ(1, servers_[2]->service_.request_count()); - // An empty update will result in the channel going into TRANSIENT_FAILURE. - gpr_log(GPR_INFO, "*** NO BACKENDS ***"); - ports.clear(); - response_generator.SetNextResolution(ports); - grpc_connectivity_state channel_state; - do { - channel_state = channel->GetState(true /* try to connect */); - } while (channel_state == GRPC_CHANNEL_READY); - ASSERT_NE(channel_state, GRPC_CHANNEL_READY); - servers_[0]->service_.ResetCounters(); - // Next update introduces servers_[1], making the channel recover. - gpr_log(GPR_INFO, "*** BACK TO SECOND BACKEND ***"); - ports.clear(); - ports.emplace_back(servers_[1]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 1, DEBUG_LOCATION); - channel_state = channel->GetState(false /* try to connect */); - ASSERT_EQ(channel_state, GRPC_CHANNEL_READY); - // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) { - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - std::vector<int> ports; - // Start with a single server. - ports.emplace_back(servers_[0]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 0, DEBUG_LOCATION); - // Send RPCs. They should all go to servers_[0] - for (size_t i = 0; i < 10; ++i) SendRpc(stub); - EXPECT_EQ(10, servers_[0]->service_.request_count()); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - EXPECT_EQ(0, servers_[2]->service_.request_count()); - servers_[0]->service_.ResetCounters(); - // Shutdown one of the servers to be sent in the update. - servers_[1]->Shutdown(); - ports.emplace_back(servers_[1]->port_); - ports.emplace_back(servers_[2]->port_); - response_generator.SetNextResolution(ports); - WaitForServer(stub, 0, DEBUG_LOCATION); - WaitForServer(stub, 2, DEBUG_LOCATION); - // Send three RPCs, one per server. - for (size_t i = 0; i < kNumServers; ++i) SendRpc(stub); - // The server in shutdown shouldn't receive any. - EXPECT_EQ(0, servers_[1]->service_.request_count()); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - std::vector<int> ports = GetServersPorts(); - for (size_t i = 0; i < 1000; ++i) { - std::shuffle(ports.begin(), ports.end(), - std::mt19937(std::random_device()())); - response_generator.SetNextResolution(ports); - if (i % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinConcurrentUpdates) { - // TODO(dgq): replicate the way internal testing exercises the concurrent - // update provisions of RR. -} - -TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { - // Start servers and send one RPC per server. - const int kNumServers = 3; - std::vector<int> first_ports; - std::vector<int> second_ports; - first_ports.reserve(kNumServers); - for (int i = 0; i < kNumServers; ++i) { - // first_ports.push_back(grpc_pick_unused_port_or_die()); - first_ports.push_back(5114 + i); - } - second_ports.reserve(kNumServers); - for (int i = 0; i < kNumServers; ++i) { - // second_ports.push_back(grpc_pick_unused_port_or_die()); - second_ports.push_back(5117 + i); - } - StartServers(kNumServers, first_ports); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(first_ports); - // Send a number of RPCs, which succeed. - for (size_t i = 0; i < 100; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // Kill all servers - gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******"); - for (size_t i = 0; i < servers_.size(); ++i) { - servers_[i]->Shutdown(); - } - gpr_log(GPR_INFO, "****** SERVERS KILLED *******"); - gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******"); - // Client requests should fail. Send enough to tickle all subchannels. - for (size_t i = 0; i < servers_.size(); ++i) CheckRpcSendFailure(stub); - gpr_log(GPR_INFO, "****** DOOMED REQUESTS SENT *******"); - // Bring servers back up on a different set of ports. We need to do this to be - // sure that the eventual success is *not* due to subchannel reconnection - // attempts and that an actual re-resolution has happened as a result of the - // RR policy going into transient failure when all its subchannels become - // unavailable (in transient failure as well). - gpr_log(GPR_INFO, "****** RESTARTING SERVERS *******"); - StartServers(kNumServers, second_ports); - // Don't notify of the update. Wait for the LB policy's re-resolution to - // "pull" the new ports. - response_generator.SetNextResolutionUponError(second_ports); - gpr_log(GPR_INFO, "****** SERVERS RESTARTED *******"); - gpr_log(GPR_INFO, "****** SENDING REQUEST TO SUCCEED *******"); - // Client request should eventually (but still fairly soon) succeed. - const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - while (gpr_time_cmp(deadline, now) > 0) { - if (SendRpc(stub)) break; - now = gpr_now(GPR_CLOCK_MONOTONIC); - } - ASSERT_GT(gpr_time_cmp(deadline, now), 0); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinTransientFailure) { - // Start servers and create channel. Channel should go to READY state. - const int kNumServers = 3; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - // Now kill the servers. The channel should transition to TRANSIENT_FAILURE. - // TODO(roth): This test should ideally check that even when the - // subchannels are in state CONNECTING for an extended period of time, - // we will still report TRANSIENT_FAILURE. Unfortunately, we don't - // currently have a good way to get a subchannel to report CONNECTING - // for a long period of time, since the servers in this test framework - // are on the loopback interface, which will immediately return a - // "Connection refused" error, so the subchannels will only be in - // CONNECTING state very briefly. When we have time, see if we can - // find a way to fix this. - for (size_t i = 0; i < servers_.size(); ++i) { - servers_[i]->Shutdown(); - } - auto predicate = [](grpc_connectivity_state state) { - return state == GRPC_CHANNEL_TRANSIENT_FAILURE; - }; - EXPECT_TRUE(WaitForChannelState(channel.get(), predicate)); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinTransientFailureAtStartup) { - // Create channel and return servers that don't exist. Channel should - // quickly transition into TRANSIENT_FAILURE. - // TODO(roth): This test should ideally check that even when the - // subchannels are in state CONNECTING for an extended period of time, - // we will still report TRANSIENT_FAILURE. Unfortunately, we don't - // currently have a good way to get a subchannel to report CONNECTING - // for a long period of time, since the servers in this test framework - // are on the loopback interface, which will immediately return a - // "Connection refused" error, so the subchannels will only be in - // CONNECTING state very briefly. When we have time, see if we can - // find a way to fix this. - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution({ - grpc_pick_unused_port_or_die(), - grpc_pick_unused_port_or_die(), - grpc_pick_unused_port_or_die(), - }); - for (size_t i = 0; i < servers_.size(); ++i) { - servers_[i]->Shutdown(); - } - auto predicate = [](grpc_connectivity_state state) { - return state == GRPC_CHANNEL_TRANSIENT_FAILURE; - }; - EXPECT_TRUE(WaitForChannelState(channel.get(), predicate, true)); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { - const int kNumServers = 3; - StartServers(kNumServers); - const auto ports = GetServersPorts(); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(ports); - for (size_t i = 0; i < kNumServers; ++i) { - WaitForServer(stub, i, DEBUG_LOCATION); - } - for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i; - } - // One request should have gone to each server. - for (size_t i = 0; i < servers_.size(); ++i) { - EXPECT_EQ(1, servers_[i]->service_.request_count()); - } - const auto pre_death = servers_[0]->service_.request_count(); - // Kill the first server. - servers_[0]->Shutdown(); - // Client request still succeed. May need retrying if RR had returned a pick - // before noticing the change in the server's connectivity. - while (!SendRpc(stub)) { - } // Retry until success. - // Send a bunch of RPCs that should succeed. - for (int i = 0; i < 10 * kNumServers; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - const auto post_death = servers_[0]->service_.request_count(); - // No requests have gone to the deceased server. - EXPECT_EQ(pre_death, post_death); - // Bring the first server back up. - StartServer(0); - // Requests should start arriving at the first server either right away (if - // the server managed to start before the RR policy retried the subchannel) or - // after the subchannel retry delay otherwise (RR's subchannel retried before - // the server was fully back up). - WaitForServer(stub, 0, DEBUG_LOCATION); -} - -// If health checking is required by client but health checking service -// is not running on the server, the channel should be treated as healthy. -TEST_F(ClientLbEnd2endTest, - RoundRobinServersHealthCheckingUnimplementedTreatedAsHealthy) { - StartServers(1); // Single server - ChannelArguments args; - args.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution({servers_[0]->port_}); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - CheckRpcSendOk(stub, DEBUG_LOCATION); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthChecking) { - EnableDefaultHealthCheckService(true); - // Start servers. - const int kNumServers = 3; - StartServers(kNumServers); - ChannelArguments args; - args.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - // Channel should not become READY, because health checks should be failing. - gpr_log(GPR_INFO, - "*** initial state: unknown health check service name for " - "all servers"); - EXPECT_FALSE(WaitForChannelReady(channel.get(), 1)); - // Now set one of the servers to be healthy. - // The channel should become healthy and all requests should go to - // the healthy server. - gpr_log(GPR_INFO, "*** server 0 healthy"); - servers_[0]->SetServingStatus("health_check_service_name", true); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - for (int i = 0; i < 10; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - EXPECT_EQ(10, servers_[0]->service_.request_count()); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - EXPECT_EQ(0, servers_[2]->service_.request_count()); - // Now set a second server to be healthy. - gpr_log(GPR_INFO, "*** server 2 healthy"); - servers_[2]->SetServingStatus("health_check_service_name", true); - WaitForServer(stub, 2, DEBUG_LOCATION); - for (int i = 0; i < 10; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - EXPECT_EQ(5, servers_[0]->service_.request_count()); - EXPECT_EQ(0, servers_[1]->service_.request_count()); - EXPECT_EQ(5, servers_[2]->service_.request_count()); - // Now set the remaining server to be healthy. - gpr_log(GPR_INFO, "*** server 1 healthy"); - servers_[1]->SetServingStatus("health_check_service_name", true); - WaitForServer(stub, 1, DEBUG_LOCATION); - for (int i = 0; i < 9; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - EXPECT_EQ(3, servers_[0]->service_.request_count()); - EXPECT_EQ(3, servers_[1]->service_.request_count()); - EXPECT_EQ(3, servers_[2]->service_.request_count()); - // Now set one server to be unhealthy again. Then wait until the - // unhealthiness has hit the client. We know that the client will see - // this when we send kNumServers requests and one of the remaining servers - // sees two of the requests. - gpr_log(GPR_INFO, "*** server 0 unhealthy"); - servers_[0]->SetServingStatus("health_check_service_name", false); - do { - ResetCounters(); - for (int i = 0; i < kNumServers; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - } while (servers_[1]->service_.request_count() != 2 && - servers_[2]->service_.request_count() != 2); - // Now set the remaining two servers to be unhealthy. Make sure the - // channel leaves READY state and that RPCs fail. - gpr_log(GPR_INFO, "*** all servers unhealthy"); - servers_[1]->SetServingStatus("health_check_service_name", false); - servers_[2]->SetServingStatus("health_check_service_name", false); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - CheckRpcSendFailure(stub); - // Clean up. - EnableDefaultHealthCheckService(false); -} - -TEST_F(ClientLbEnd2endTest, - RoundRobinWithHealthCheckingHandlesSubchannelFailure) { - EnableDefaultHealthCheckService(true); - // Start servers. - const int kNumServers = 3; - StartServers(kNumServers); - servers_[0]->SetServingStatus("health_check_service_name", true); - servers_[1]->SetServingStatus("health_check_service_name", true); - servers_[2]->SetServingStatus("health_check_service_name", true); - ChannelArguments args; - args.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - WaitForServer(stub, 0, DEBUG_LOCATION); - // Stop server 0 and send a new resolver result to ensure that RR - // checks each subchannel's state. - servers_[0]->Shutdown(); - response_generator.SetNextResolution(GetServersPorts()); - // Send a bunch more RPCs. - for (size_t i = 0; i < 100; i++) { - SendRpc(stub); - } -} - -TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingInhibitPerChannel) { - EnableDefaultHealthCheckService(true); - // Start server. - const int kNumServers = 1; - StartServers(kNumServers); - // Create a channel with health-checking enabled. - ChannelArguments args; - args.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"); - auto response_generator1 = BuildResolverResponseGenerator(); - auto channel1 = BuildChannel("round_robin", response_generator1, args); - auto stub1 = BuildStub(channel1); - std::vector<int> ports = GetServersPorts(); - response_generator1.SetNextResolution(ports); - // Create a channel with health checking enabled but inhibited. - args.SetInt(GRPC_ARG_INHIBIT_HEALTH_CHECKING, 1); - auto response_generator2 = BuildResolverResponseGenerator(); - auto channel2 = BuildChannel("round_robin", response_generator2, args); - auto stub2 = BuildStub(channel2); - response_generator2.SetNextResolution(ports); - // First channel should not become READY, because health checks should be - // failing. - EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); - CheckRpcSendFailure(stub1); - // Second channel should be READY. - EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); - CheckRpcSendOk(stub2, DEBUG_LOCATION); - // Enable health checks on the backend and wait for channel 1 to succeed. - servers_[0]->SetServingStatus("health_check_service_name", true); - CheckRpcSendOk(stub1, DEBUG_LOCATION, true /* wait_for_ready */); - // Check that we created only one subchannel to the backend. - EXPECT_EQ(1UL, servers_[0]->service_.clients().size()); - // Clean up. - EnableDefaultHealthCheckService(false); -} - -TEST_F(ClientLbEnd2endTest, RoundRobinWithHealthCheckingServiceNamePerChannel) { - EnableDefaultHealthCheckService(true); - // Start server. - const int kNumServers = 1; - StartServers(kNumServers); - // Create a channel with health-checking enabled. - ChannelArguments args; - args.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"); - auto response_generator1 = BuildResolverResponseGenerator(); - auto channel1 = BuildChannel("round_robin", response_generator1, args); - auto stub1 = BuildStub(channel1); - std::vector<int> ports = GetServersPorts(); - response_generator1.SetNextResolution(ports); - // Create a channel with health-checking enabled with a different - // service name. - ChannelArguments args2; - args2.SetServiceConfigJSON( - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name2\"}}"); - auto response_generator2 = BuildResolverResponseGenerator(); - auto channel2 = BuildChannel("round_robin", response_generator2, args2); - auto stub2 = BuildStub(channel2); - response_generator2.SetNextResolution(ports); - // Allow health checks from channel 2 to succeed. - servers_[0]->SetServingStatus("health_check_service_name2", true); - // First channel should not become READY, because health checks should be - // failing. - EXPECT_FALSE(WaitForChannelReady(channel1.get(), 1)); - CheckRpcSendFailure(stub1); - // Second channel should be READY. - EXPECT_TRUE(WaitForChannelReady(channel2.get(), 1)); - CheckRpcSendOk(stub2, DEBUG_LOCATION); - // Enable health checks for channel 1 and wait for it to succeed. - servers_[0]->SetServingStatus("health_check_service_name", true); - CheckRpcSendOk(stub1, DEBUG_LOCATION, true /* wait_for_ready */); - // Check that we created only one subchannel to the backend. - EXPECT_EQ(1UL, servers_[0]->service_.clients().size()); - // Clean up. - EnableDefaultHealthCheckService(false); -} - -TEST_F(ClientLbEnd2endTest, - RoundRobinWithHealthCheckingServiceNameChangesAfterSubchannelsCreated) { - EnableDefaultHealthCheckService(true); - // Start server. - const int kNumServers = 1; - StartServers(kNumServers); - // Create a channel with health-checking enabled. - const char* kServiceConfigJson = - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name\"}}"; - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("round_robin", response_generator); - auto stub = BuildStub(channel); - std::vector<int> ports = GetServersPorts(); - response_generator.SetNextResolution(ports, kServiceConfigJson); - servers_[0]->SetServingStatus("health_check_service_name", true); - EXPECT_TRUE(WaitForChannelReady(channel.get(), 1 /* timeout_seconds */)); - // Send an update on the channel to change it to use a health checking - // service name that is not being reported as healthy. - const char* kServiceConfigJson2 = - "{\"healthCheckConfig\": " - "{\"serviceName\": \"health_check_service_name2\"}}"; - response_generator.SetNextResolution(ports, kServiceConfigJson2); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - // Clean up. - EnableDefaultHealthCheckService(false); -} - -TEST_F(ClientLbEnd2endTest, ChannelIdleness) { - // Start server. - const int kNumServers = 1; - StartServers(kNumServers); - // Set max idle time and build the channel. - ChannelArguments args; - args.SetInt(GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS, 1000); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("", response_generator, args); - auto stub = BuildStub(channel); - // The initial channel state should be IDLE. - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); - // After sending RPC, channel state should be READY. - gpr_log(GPR_INFO, "*** SENDING RPC, CHANNEL SHOULD CONNECT ***"); - response_generator.SetNextResolution(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - // After a period time not using the channel, the channel state should switch - // to IDLE. - gpr_log(GPR_INFO, "*** WAITING FOR CHANNEL TO GO IDLE ***"); - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1200)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); - // Sending a new RPC should awake the IDLE channel. - gpr_log(GPR_INFO, "*** SENDING ANOTHER RPC, CHANNEL SHOULD RECONNECT ***"); - response_generator.SetNextResolution(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); -} - -class ClientLbPickArgsTest : public ClientLbEnd2endTest { - protected: - void SetUp() override { - ClientLbEnd2endTest::SetUp(); - current_test_instance_ = this; - } - - static void SetUpTestCase() { - grpc_init(); - grpc_core::RegisterTestPickArgsLoadBalancingPolicy(SavePickArgs); - } - - static void TearDownTestCase() { grpc_shutdown(); } - - std::vector<grpc_core::PickArgsSeen> args_seen_list() { - grpc::internal::MutexLock lock(&mu_); - return args_seen_list_; - } - - static TString ArgsSeenListString( - const std::vector<grpc_core::PickArgsSeen>& args_seen_list) { - std::vector<TString> entries; - for (const auto& args_seen : args_seen_list) { - std::vector<TString> metadata; - for (const auto& p : args_seen.metadata) { - metadata.push_back(y_absl::StrCat(p.first, "=", p.second)); - } - entries.push_back(y_absl::StrFormat("{path=\"%s\", metadata=[%s]}", - args_seen.path, - y_absl::StrJoin(metadata, ", "))); - } - return y_absl::StrCat("[", y_absl::StrJoin(entries, ", "), "]"); - } - - private: - static void SavePickArgs(const grpc_core::PickArgsSeen& args_seen) { - ClientLbPickArgsTest* self = current_test_instance_; - grpc::internal::MutexLock lock(&self->mu_); - self->args_seen_list_.emplace_back(args_seen); - } - - static ClientLbPickArgsTest* current_test_instance_; - grpc::internal::Mutex mu_; - std::vector<grpc_core::PickArgsSeen> args_seen_list_; -}; - -ClientLbPickArgsTest* ClientLbPickArgsTest::current_test_instance_ = nullptr; - -TEST_F(ClientLbPickArgsTest, Basic) { - const int kNumServers = 1; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("test_pick_args_lb", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - // Proactively connect the channel, so that the LB policy will always - // be connected before it sees the pick. Otherwise, the test would be - // flaky because sometimes the pick would be seen twice (once in - // CONNECTING and again in READY) and other times only once (in READY). - ASSERT_TRUE(channel->WaitForConnected(gpr_inf_future(GPR_CLOCK_MONOTONIC))); - // Check LB policy name for the channel. - EXPECT_EQ("test_pick_args_lb", channel->GetLoadBalancingPolicyName()); - // Now send an RPC and check that the picker sees the expected data. - CheckRpcSendOk(stub, DEBUG_LOCATION, /*wait_for_ready=*/true); - auto pick_args_seen_list = args_seen_list(); - EXPECT_THAT(pick_args_seen_list, - ::testing::ElementsAre(::testing::AllOf( - ::testing::Field(&grpc_core::PickArgsSeen::path, - "/grpc.testing.EchoTestService/Echo"), - ::testing::Field(&grpc_core::PickArgsSeen::metadata, - ::testing::UnorderedElementsAre( - ::testing::Pair("foo", "1"), - ::testing::Pair("bar", "2"), - ::testing::Pair("baz", "3")))))) - << ArgsSeenListString(pick_args_seen_list); -} - -class ClientLbInterceptTrailingMetadataTest : public ClientLbEnd2endTest { - protected: - void SetUp() override { - ClientLbEnd2endTest::SetUp(); - current_test_instance_ = this; - } - - static void SetUpTestCase() { - grpc_init(); - grpc_core::RegisterInterceptRecvTrailingMetadataLoadBalancingPolicy( - ReportTrailerIntercepted); - } - - static void TearDownTestCase() { grpc_shutdown(); } - - int trailers_intercepted() { - grpc::internal::MutexLock lock(&mu_); - return trailers_intercepted_; - } - - const grpc_core::MetadataVector& trailing_metadata() { - grpc::internal::MutexLock lock(&mu_); - return trailing_metadata_; - } - - const xds::data::orca::v3::OrcaLoadReport* backend_load_report() { - grpc::internal::MutexLock lock(&mu_); - return load_report_.get(); - } - - private: - static void ReportTrailerIntercepted( - const grpc_core::TrailingMetadataArgsSeen& args_seen) { - const auto* backend_metric_data = args_seen.backend_metric_data; - ClientLbInterceptTrailingMetadataTest* self = current_test_instance_; - grpc::internal::MutexLock lock(&self->mu_); - self->trailers_intercepted_++; - self->trailing_metadata_ = args_seen.metadata; - if (backend_metric_data != nullptr) { - self->load_report_ = - y_absl::make_unique<xds::data::orca::v3::OrcaLoadReport>(); - self->load_report_->set_cpu_utilization( - backend_metric_data->cpu_utilization); - self->load_report_->set_mem_utilization( - backend_metric_data->mem_utilization); - self->load_report_->set_rps(backend_metric_data->requests_per_second); - for (const auto& p : backend_metric_data->request_cost) { - TString name = TString(p.first); - (*self->load_report_->mutable_request_cost())[name] = p.second; - } - for (const auto& p : backend_metric_data->utilization) { - TString name = TString(p.first); - (*self->load_report_->mutable_utilization())[name] = p.second; - } - } - } - - static ClientLbInterceptTrailingMetadataTest* current_test_instance_; - grpc::internal::Mutex mu_; - int trailers_intercepted_ = 0; - grpc_core::MetadataVector trailing_metadata_; - std::unique_ptr<xds::data::orca::v3::OrcaLoadReport> load_report_; -}; - -ClientLbInterceptTrailingMetadataTest* - ClientLbInterceptTrailingMetadataTest::current_test_instance_ = nullptr; - -TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesDisabled) { - const int kNumServers = 1; - const int kNumRpcs = 10; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("intercept_trailing_metadata_lb", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - for (size_t i = 0; i < kNumRpcs; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // Check LB policy name for the channel. - EXPECT_EQ("intercept_trailing_metadata_lb", - channel->GetLoadBalancingPolicyName()); - EXPECT_EQ(kNumRpcs, trailers_intercepted()); - EXPECT_THAT(trailing_metadata(), - ::testing::UnorderedElementsAre( - // TODO(roth): Should grpc-status be visible here? - ::testing::Pair("grpc-status", "0"), - ::testing::Pair("user-agent", ::testing::_), - ::testing::Pair("foo", "1"), ::testing::Pair("bar", "2"), - ::testing::Pair("baz", "3"))); - EXPECT_EQ(nullptr, backend_load_report()); -} - -TEST_F(ClientLbInterceptTrailingMetadataTest, InterceptsRetriesEnabled) { - const int kNumServers = 1; - const int kNumRpcs = 10; - StartServers(kNumServers); - ChannelArguments args; - args.SetServiceConfigJSON( - "{\n" - " \"methodConfig\": [ {\n" - " \"name\": [\n" - " { \"service\": \"grpc.testing.EchoTestService\" }\n" - " ],\n" - " \"retryPolicy\": {\n" - " \"maxAttempts\": 3,\n" - " \"initialBackoff\": \"1s\",\n" - " \"maxBackoff\": \"120s\",\n" - " \"backoffMultiplier\": 1.6,\n" - " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" - " }\n" - " } ]\n" - "}"); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("intercept_trailing_metadata_lb", response_generator, args); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - for (size_t i = 0; i < kNumRpcs; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - // Check LB policy name for the channel. - EXPECT_EQ("intercept_trailing_metadata_lb", - channel->GetLoadBalancingPolicyName()); - EXPECT_EQ(kNumRpcs, trailers_intercepted()); - EXPECT_THAT(trailing_metadata(), - ::testing::UnorderedElementsAre( - // TODO(roth): Should grpc-status be visible here? - ::testing::Pair("grpc-status", "0"), - ::testing::Pair("user-agent", ::testing::_), - ::testing::Pair("foo", "1"), ::testing::Pair("bar", "2"), - ::testing::Pair("baz", "3"))); - EXPECT_EQ(nullptr, backend_load_report()); -} - -TEST_F(ClientLbInterceptTrailingMetadataTest, BackendMetricData) { - const int kNumServers = 1; - const int kNumRpcs = 10; - StartServers(kNumServers); - xds::data::orca::v3::OrcaLoadReport load_report; - load_report.set_cpu_utilization(0.5); - load_report.set_mem_utilization(0.75); - load_report.set_rps(25); - auto* request_cost = load_report.mutable_request_cost(); - (*request_cost)["foo"] = 0.8; - (*request_cost)["bar"] = 1.4; - auto* utilization = load_report.mutable_utilization(); - (*utilization)["baz"] = 1.1; - (*utilization)["quux"] = 0.9; - for (const auto& server : servers_) { - server->service_.set_load_report(&load_report); - } - auto response_generator = BuildResolverResponseGenerator(); - auto channel = - BuildChannel("intercept_trailing_metadata_lb", response_generator); - auto stub = BuildStub(channel); - response_generator.SetNextResolution(GetServersPorts()); - for (size_t i = 0; i < kNumRpcs; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - auto* actual = backend_load_report(); - ASSERT_NE(actual, nullptr); - // TODO(roth): Change this to use EqualsProto() once that becomes - // available in OSS. - EXPECT_EQ(actual->cpu_utilization(), load_report.cpu_utilization()); - EXPECT_EQ(actual->mem_utilization(), load_report.mem_utilization()); - EXPECT_EQ(actual->rps(), load_report.rps()); - EXPECT_EQ(actual->request_cost().size(), load_report.request_cost().size()); - for (const auto& p : actual->request_cost()) { - auto it = load_report.request_cost().find(p.first); - ASSERT_NE(it, load_report.request_cost().end()); - EXPECT_EQ(it->second, p.second); - } - EXPECT_EQ(actual->utilization().size(), load_report.utilization().size()); - for (const auto& p : actual->utilization()) { - auto it = load_report.utilization().find(p.first); - ASSERT_NE(it, load_report.utilization().end()); - EXPECT_EQ(it->second, p.second); - } - } - // Check LB policy name for the channel. - EXPECT_EQ("intercept_trailing_metadata_lb", - channel->GetLoadBalancingPolicyName()); - EXPECT_EQ(kNumRpcs, trailers_intercepted()); -} - -class ClientLbAddressTest : public ClientLbEnd2endTest { - protected: - static const char* kAttributeKey; - - class Attribute : public grpc_core::ServerAddress::AttributeInterface { - public: - explicit Attribute(const TString& str) : str_(str) {} - - std::unique_ptr<AttributeInterface> Copy() const override { - return y_absl::make_unique<Attribute>(str_); - } - - int Cmp(const AttributeInterface* other) const override { - return str_.compare(static_cast<const Attribute*>(other)->str_); - } - - TString ToString() const override { return str_; } - - private: - TString str_; - }; - - void SetUp() override { - ClientLbEnd2endTest::SetUp(); - current_test_instance_ = this; - } - - static void SetUpTestCase() { - grpc_init(); - grpc_core::RegisterAddressTestLoadBalancingPolicy(SaveAddress); - } - - static void TearDownTestCase() { grpc_shutdown(); } - - const std::vector<TString>& addresses_seen() { - grpc::internal::MutexLock lock(&mu_); - return addresses_seen_; - } - - private: - static void SaveAddress(const grpc_core::ServerAddress& address) { - ClientLbAddressTest* self = current_test_instance_; - grpc::internal::MutexLock lock(&self->mu_); - self->addresses_seen_.emplace_back(address.ToString()); - } - - static ClientLbAddressTest* current_test_instance_; - grpc::internal::Mutex mu_; - std::vector<TString> addresses_seen_; -}; - -const char* ClientLbAddressTest::kAttributeKey = "attribute_key"; - -ClientLbAddressTest* ClientLbAddressTest::current_test_instance_ = nullptr; - -TEST_F(ClientLbAddressTest, Basic) { - const int kNumServers = 1; - StartServers(kNumServers); - auto response_generator = BuildResolverResponseGenerator(); - auto channel = BuildChannel("address_test_lb", response_generator); - auto stub = BuildStub(channel); - // Addresses returned by the resolver will have attached attributes. - response_generator.SetNextResolution(GetServersPorts(), nullptr, - kAttributeKey, - y_absl::make_unique<Attribute>("foo")); - CheckRpcSendOk(stub, DEBUG_LOCATION); - // Check LB policy name for the channel. - EXPECT_EQ("address_test_lb", channel->GetLoadBalancingPolicyName()); - // Make sure that the attributes wind up on the subchannels. - std::vector<TString> expected; - for (const int port : GetServersPorts()) { - expected.emplace_back( - y_absl::StrCat(ipv6_only_ ? "[::1]:" : "127.0.0.1:", port, - " args={} attributes={", kAttributeKey, "=foo}")); - } - EXPECT_EQ(addresses_seen(), expected); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - const auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/context_allocator_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/context_allocator_end2end_test.cc deleted file mode 100644 index 0d9fa72f48..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/context_allocator_end2end_test.cc +++ /dev/null @@ -1,330 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <atomic> -#include <condition_variable> -#include <functional> -#include <memory> -#include <mutex> -#include <sstream> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/impl/codegen/log.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/client_callback.h> -#include <grpcpp/support/message_allocator.h> - -#include "src/core/lib/iomgr/iomgr.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_credentials_provider.h" - -namespace grpc { -namespace testing { -namespace { - -enum class Protocol { INPROC, TCP }; - -class TestScenario { - public: - TestScenario(Protocol protocol, const TString& creds_type) - : protocol(protocol), credentials_type(creds_type) {} - void Log() const; - Protocol protocol; - const TString credentials_type; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{protocol=" - << (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP") - << "," << scenario.credentials_type << "}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_INFO, "%s", out.str().c_str()); -} - -class ContextAllocatorEnd2endTestBase - : public ::testing::TestWithParam<TestScenario> { - protected: - static void SetUpTestCase() { grpc_init(); } - static void TearDownTestCase() { grpc_shutdown(); } - ContextAllocatorEnd2endTestBase() {} - - ~ContextAllocatorEnd2endTestBase() override = default; - - void SetUp() override { GetParam().Log(); } - - void CreateServer(std::unique_ptr<grpc::ContextAllocator> context_allocator) { - ServerBuilder builder; - - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - if (GetParam().protocol == Protocol::TCP) { - picked_port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << picked_port_; - builder.AddListeningPort(server_address_.str(), server_creds); - } - builder.SetContextAllocator(std::move(context_allocator)); - builder.RegisterService(&callback_service_); - - server_ = builder.BuildAndStart(); - } - - void DestroyServer() { - if (server_) { - server_->Shutdown(); - server_.reset(); - } - } - - void ResetStub() { - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - switch (GetParam().protocol) { - case Protocol::TCP: - channel_ = ::grpc::CreateCustomChannel(server_address_.str(), - channel_creds, args); - break; - case Protocol::INPROC: - channel_ = server_->InProcessChannel(args); - break; - default: - assert(false); - } - stub_ = EchoTestService::NewStub(channel_); - } - - void TearDown() override { - DestroyServer(); - if (picked_port_ > 0) { - grpc_recycle_unused_port(picked_port_); - } - } - - void SendRpcs(int num_rpcs) { - TString test_string(""); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - - test_string += TString(1024, 'x'); - request.set_message(test_string); - TString val; - cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->Echo( - &cli_ctx, &request, &response, - [&request, &response, &done, &mu, &cv, val](Status s) { - GPR_ASSERT(s.ok()); - - EXPECT_EQ(request.message(), response.message()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } - } - } - - int picked_port_{0}; - std::shared_ptr<Channel> channel_; - std::unique_ptr<EchoTestService::Stub> stub_; - CallbackTestServiceImpl callback_service_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; -}; - -class DefaultContextAllocatorTest : public ContextAllocatorEnd2endTestBase {}; - -TEST_P(DefaultContextAllocatorTest, SimpleRpc) { - const int kRpcCount = 10; - CreateServer(nullptr); - ResetStub(); - SendRpcs(kRpcCount); -} - -class NullContextAllocatorTest : public ContextAllocatorEnd2endTestBase { - public: - class NullAllocator : public grpc::ContextAllocator { - public: - NullAllocator(std::atomic<int>* allocation_count, - std::atomic<int>* deallocation_count) - : allocation_count_(allocation_count), - deallocation_count_(deallocation_count) {} - grpc::CallbackServerContext* NewCallbackServerContext() override { - allocation_count_->fetch_add(1, std::memory_order_relaxed); - return nullptr; - } - - GenericCallbackServerContext* NewGenericCallbackServerContext() override { - allocation_count_->fetch_add(1, std::memory_order_relaxed); - return nullptr; - } - - void Release( - grpc::CallbackServerContext* /*callback_server_context*/) override { - deallocation_count_->fetch_add(1, std::memory_order_relaxed); - } - - void Release( - GenericCallbackServerContext* /*generic_callback_server_context*/) - override { - deallocation_count_->fetch_add(1, std::memory_order_relaxed); - } - - std::atomic<int>* allocation_count_; - std::atomic<int>* deallocation_count_; - }; -}; - -TEST_P(NullContextAllocatorTest, UnaryRpc) { - const int kRpcCount = 10; - std::atomic<int> allocation_count{0}; - std::atomic<int> deallocation_count{0}; - std::unique_ptr<NullAllocator> allocator( - new NullAllocator(&allocation_count, &deallocation_count)); - CreateServer(std::move(allocator)); - ResetStub(); - SendRpcs(kRpcCount); - // messages_deallocaton_count is updated in Release after server side - // OnDone. - DestroyServer(); - EXPECT_EQ(kRpcCount, allocation_count); - EXPECT_EQ(kRpcCount, deallocation_count); -} - -class SimpleContextAllocatorTest : public ContextAllocatorEnd2endTestBase { - public: - class SimpleAllocator : public grpc::ContextAllocator { - public: - SimpleAllocator(std::atomic<int>* allocation_count, - std::atomic<int>* deallocation_count) - : allocation_count_(allocation_count), - deallocation_count_(deallocation_count) {} - grpc::CallbackServerContext* NewCallbackServerContext() override { - allocation_count_->fetch_add(1, std::memory_order_relaxed); - return new grpc::CallbackServerContext(); - } - GenericCallbackServerContext* NewGenericCallbackServerContext() override { - allocation_count_->fetch_add(1, std::memory_order_relaxed); - return new GenericCallbackServerContext(); - } - - void Release( - grpc::CallbackServerContext* callback_server_context) override { - deallocation_count_->fetch_add(1, std::memory_order_relaxed); - delete callback_server_context; - } - - void Release(GenericCallbackServerContext* generic_callback_server_context) - override { - deallocation_count_->fetch_add(1, std::memory_order_relaxed); - delete generic_callback_server_context; - } - - std::atomic<int>* allocation_count_; - std::atomic<int>* deallocation_count_; - }; -}; - -TEST_P(SimpleContextAllocatorTest, UnaryRpc) { - const int kRpcCount = 10; - std::atomic<int> allocation_count{0}; - std::atomic<int> deallocation_count{0}; - std::unique_ptr<SimpleAllocator> allocator( - new SimpleAllocator(&allocation_count, &deallocation_count)); - CreateServer(std::move(allocator)); - ResetStub(); - SendRpcs(kRpcCount); - // messages_deallocaton_count is updated in Release after server side - // OnDone. - DestroyServer(); - EXPECT_EQ(kRpcCount, allocation_count); - EXPECT_EQ(kRpcCount, deallocation_count); -} - -std::vector<TestScenario> CreateTestScenarios(bool test_insecure) { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types{ - GetCredentialsProvider()->GetSecureCredentialsTypeList()}; - auto insec_ok = [] { - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - return GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr; - }; - if (test_insecure && insec_ok()) { - credentials_types.push_back(kInsecureCredentialsType); - } - GPR_ASSERT(!credentials_types.empty()); - - Protocol parr[]{Protocol::INPROC, Protocol::TCP}; - for (Protocol p : parr) { - for (const auto& cred : credentials_types) { - if (p == Protocol::INPROC && - (cred != kInsecureCredentialsType || !insec_ok())) { - continue; - } - scenarios.emplace_back(p, cred); - } - } - return scenarios; -} - -// TODO(ddyihai): adding client streaming/server streaming/bidi streaming -// test. - -INSTANTIATE_TEST_SUITE_P(DefaultContextAllocatorTest, - DefaultContextAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); -INSTANTIATE_TEST_SUITE_P(NullContextAllocatorTest, NullContextAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); -INSTANTIATE_TEST_SUITE_P(SimpleContextAllocatorTest, SimpleContextAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/counted_service.h b/contrib/libs/grpc/test/cpp/end2end/counted_service.h deleted file mode 100644 index 8143521407..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/counted_service.h +++ /dev/null @@ -1,64 +0,0 @@ -// -// Copyright 2017 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef GRPC_TEST_CPP_END2END_COUNTED_SERVICE_H -#define GRPC_TEST_CPP_END2END_COUNTED_SERVICE_H - -#include "src/core/lib/gprpp/sync.h" - -namespace grpc { -namespace testing { - -// A wrapper around an RPC service implementation that provides request and -// response counting. -template <typename ServiceType> -class CountedService : public ServiceType { - public: - size_t request_count() { - grpc_core::MutexLock lock(&mu_); - return request_count_; - } - - size_t response_count() { - grpc_core::MutexLock lock(&mu_); - return response_count_; - } - - void IncreaseResponseCount() { - grpc_core::MutexLock lock(&mu_); - ++response_count_; - } - void IncreaseRequestCount() { - grpc_core::MutexLock lock(&mu_); - ++request_count_; - } - - void ResetCounters() { - grpc_core::MutexLock lock(&mu_); - request_count_ = 0; - response_count_ = 0; - } - - private: - grpc_core::Mutex mu_; - size_t request_count_ Y_ABSL_GUARDED_BY(mu_) = 0; - size_t response_count_ Y_ABSL_GUARDED_BY(mu_) = 0; -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_END2END_COUNTED_SERVICE_H diff --git a/contrib/libs/grpc/test/cpp/end2end/delegating_channel_test.cc b/contrib/libs/grpc/test/cpp/end2end/delegating_channel_test.cc deleted file mode 100644 index bdc0df0fb1..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/delegating_channel_test.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <memory> -#include <vector> - -#include <gtest/gtest.h> - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/generic/generic_stub.h> -#include <grpcpp/impl/codegen/delegating_channel.h> -#include <grpcpp/impl/codegen/proto_utils.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/client_interceptor.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" -#include "test/cpp/util/string_ref_helper.h" - -namespace grpc { -namespace testing { -namespace { - -class TestChannel : public experimental::DelegatingChannel { - public: - explicit TestChannel( - const std::shared_ptr<ChannelInterface>& delegate_channel) - : experimental::DelegatingChannel(delegate_channel) {} - // Always returns GRPC_CHANNEL_READY - grpc_connectivity_state GetState(bool /*try_to_connect*/) override { - return GRPC_CHANNEL_READY; - } -}; - -class DelegatingChannelTest : public ::testing::Test { - protected: - DelegatingChannelTest() { - int port = grpc_pick_unused_port_or_die(); - ServerBuilder builder; - server_address_ = "localhost:" + ToString(port); - builder.AddListeningPort(server_address_, InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - ~DelegatingChannelTest() override { server_->Shutdown(); } - - TString server_address_; - TestServiceImpl service_; - std::unique_ptr<Server> server_; -}; - -TEST_F(DelegatingChannelTest, SimpleTest) { - auto channel = CreateChannel(server_address_, InsecureChannelCredentials()); - std::shared_ptr<TestChannel> test_channel = - std::make_shared<TestChannel>(channel); - // gRPC channel should be in idle state at this point but our test channel - // will return ready. - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_IDLE); - EXPECT_EQ(test_channel->GetState(false), GRPC_CHANNEL_READY); - auto stub = grpc::testing::EchoTestService::NewStub(test_channel); - ClientContext ctx; - EchoRequest req; - req.set_message("Hello"); - EchoResponse resp; - Status s = stub->Echo(&ctx, req, &resp); - EXPECT_EQ(s.ok(), true); - EXPECT_EQ(resp.message(), "Hello"); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/end2end_test.cc deleted file mode 100644 index 3649f3bbc0..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/end2end_test.cc +++ /dev/null @@ -1,2298 +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. - * - */ - -#include <mutex> -#include <thread> - -#include "y_absl/memory/memory.h" -#include "y_absl/strings/match.h" -#include "y_absl/strings/str_format.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/resource_quota.h> -#include <grpcpp/security/auth_metadata_processor.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/string_ref.h> -#include <grpcpp/test/channel_test_peer.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/security/credentials/credentials.h" -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/interceptors_util.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/string_ref_helper.h" -#include "test/cpp/util/test_credentials_provider.h" - -#ifdef GRPC_POSIX_SOCKET_EV -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET_EV - -#include <gtest/gtest.h> - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; -using grpc::testing::kTlsCredentialsType; -using std::chrono::system_clock; - -namespace grpc { -namespace testing { -namespace { - -bool CheckIsLocalhost(const TString& addr) { - const TString kIpv6("ipv6:[::1]:"); - const TString kIpv4MappedIpv6("ipv6:[::ffff:127.0.0.1]:"); - const TString kIpv4("ipv4:127.0.0.1:"); - return addr.substr(0, kIpv4.size()) == kIpv4 || - addr.substr(0, kIpv4MappedIpv6.size()) == kIpv4MappedIpv6 || - addr.substr(0, kIpv6.size()) == kIpv6; -} - -const int kClientChannelBackupPollIntervalMs = 200; - -const char kTestCredsPluginErrorMsg[] = "Could not find plugin metadata."; - -const char kFakeToken[] = "fake_token"; -const char kFakeSelector[] = "fake_selector"; -const char kExpectedFakeCredsDebugString[] = - "SecureCallCredentials{GoogleIAMCredentials{Token:present," - "AuthoritySelector:fake_selector}}"; - -const char kWrongToken[] = "wrong_token"; -const char kWrongSelector[] = "wrong_selector"; -const char kExpectedWrongCredsDebugString[] = - "SecureCallCredentials{GoogleIAMCredentials{Token:present," - "AuthoritySelector:wrong_selector}}"; - -const char kFakeToken1[] = "fake_token1"; -const char kFakeSelector1[] = "fake_selector1"; -const char kExpectedFakeCreds1DebugString[] = - "SecureCallCredentials{GoogleIAMCredentials{Token:present," - "AuthoritySelector:fake_selector1}}"; - -const char kFakeToken2[] = "fake_token2"; -const char kFakeSelector2[] = "fake_selector2"; -const char kExpectedFakeCreds2DebugString[] = - "SecureCallCredentials{GoogleIAMCredentials{Token:present," - "AuthoritySelector:fake_selector2}}"; - -const char kExpectedAuthMetadataPluginKeyFailureCredsDebugString[] = - "SecureCallCredentials{TestMetadataCredentials{key:TestPluginMetadata," - "value:Does not matter, will fail the key is invalid.}}"; -const char kExpectedAuthMetadataPluginValueFailureCredsDebugString[] = - "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," - "value:With illegal \n value.}}"; -const char kExpectedAuthMetadataPluginWithDeadlineCredsDebugString[] = - "SecureCallCredentials{TestMetadataCredentials{key:meta_key,value:Does not " - "matter}}"; -const char kExpectedNonBlockingAuthMetadataPluginFailureCredsDebugString[] = - "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," - "value:Does not matter, will fail anyway (see 3rd param)}}"; -const char - kExpectedNonBlockingAuthMetadataPluginAndProcessorSuccessCredsDebugString - [] = "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-" - "metadata,value:Dr Jekyll}}"; -const char - kExpectedNonBlockingAuthMetadataPluginAndProcessorFailureCredsDebugString - [] = "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-" - "metadata,value:Mr Hyde}}"; -const char kExpectedBlockingAuthMetadataPluginFailureCredsDebugString[] = - "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," - "value:Does not matter, will fail anyway (see 3rd param)}}"; -const char kExpectedCompositeCallCredsDebugString[] = - "SecureCallCredentials{CompositeCallCredentials{TestMetadataCredentials{" - "key:call-creds-key1,value:call-creds-val1},TestMetadataCredentials{key:" - "call-creds-key2,value:call-creds-val2}}}"; - -class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { - public: - static const char kGoodMetadataKey[]; - static const char kBadMetadataKey[]; - - TestMetadataCredentialsPlugin(const grpc::string_ref& metadata_key, - const grpc::string_ref& metadata_value, - bool is_blocking, bool is_successful, - int delay_ms) - : metadata_key_(metadata_key.data(), metadata_key.length()), - metadata_value_(metadata_value.data(), metadata_value.length()), - is_blocking_(is_blocking), - is_successful_(is_successful), - delay_ms_(delay_ms) {} - - bool IsBlocking() const override { return is_blocking_; } - - Status GetMetadata( - grpc::string_ref service_url, grpc::string_ref method_name, - const grpc::AuthContext& channel_auth_context, - std::multimap<TString, TString>* metadata) override { - if (delay_ms_ != 0) { - gpr_sleep_until( - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(delay_ms_, GPR_TIMESPAN))); - } - EXPECT_GT(service_url.length(), 0UL); - EXPECT_GT(method_name.length(), 0UL); - EXPECT_TRUE(channel_auth_context.IsPeerAuthenticated()); - EXPECT_TRUE(metadata != nullptr); - if (is_successful_) { - metadata->insert(std::make_pair(metadata_key_, metadata_value_)); - return Status::OK; - } else { - return Status(StatusCode::NOT_FOUND, kTestCredsPluginErrorMsg); - } - } - - TString DebugString() override { - return y_absl::StrFormat("TestMetadataCredentials{key:%s,value:%s}", - metadata_key_.c_str(), metadata_value_.c_str()); - } - - private: - TString metadata_key_; - TString metadata_value_; - bool is_blocking_; - bool is_successful_; - int delay_ms_; -}; - -const char TestMetadataCredentialsPlugin::kBadMetadataKey[] = - "TestPluginMetadata"; -const char TestMetadataCredentialsPlugin::kGoodMetadataKey[] = - "test-plugin-metadata"; - -class TestAuthMetadataProcessor : public AuthMetadataProcessor { - public: - static const char kGoodGuy[]; - - explicit TestAuthMetadataProcessor(bool is_blocking) - : is_blocking_(is_blocking) {} - - std::shared_ptr<CallCredentials> GetCompatibleClientCreds() { - return grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kGoodMetadataKey, kGoodGuy, - is_blocking_, true, 0))); - } - - std::shared_ptr<CallCredentials> GetIncompatibleClientCreds() { - return grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kGoodMetadataKey, "Mr Hyde", - is_blocking_, true, 0))); - } - - // Interface implementation - bool IsBlocking() const override { return is_blocking_; } - - Status Process(const InputMetadata& auth_metadata, AuthContext* context, - OutputMetadata* consumed_auth_metadata, - OutputMetadata* response_metadata) override { - EXPECT_TRUE(consumed_auth_metadata != nullptr); - EXPECT_TRUE(context != nullptr); - EXPECT_TRUE(response_metadata != nullptr); - auto auth_md = - auth_metadata.find(TestMetadataCredentialsPlugin::kGoodMetadataKey); - EXPECT_NE(auth_md, auth_metadata.end()); - string_ref auth_md_value = auth_md->second; - if (auth_md_value == kGoodGuy) { - context->AddProperty(kIdentityPropName, kGoodGuy); - context->SetPeerIdentityPropertyName(kIdentityPropName); - consumed_auth_metadata->insert(std::make_pair( - string(auth_md->first.data(), auth_md->first.length()), - string(auth_md->second.data(), auth_md->second.length()))); - return Status::OK; - } else { - return Status(StatusCode::UNAUTHENTICATED, - string("Invalid principal: ") + - string(auth_md_value.data(), auth_md_value.length())); - } - } - - private: - static const char kIdentityPropName[]; - bool is_blocking_; -}; - -const char TestAuthMetadataProcessor::kGoodGuy[] = "Dr Jekyll"; -const char TestAuthMetadataProcessor::kIdentityPropName[] = "novel identity"; - -class Proxy : public ::grpc::testing::EchoTestService::Service { - public: - explicit Proxy(const std::shared_ptr<Channel>& channel) - : stub_(grpc::testing::EchoTestService::NewStub(channel)) {} - - Status Echo(ServerContext* server_context, const EchoRequest* request, - EchoResponse* response) override { - std::unique_ptr<ClientContext> client_context = - ClientContext::FromServerContext(*server_context); - return stub_->Echo(client_context.get(), *request, response); - } - - private: - std::unique_ptr<::grpc::testing::EchoTestService::Stub> stub_; -}; - -class TestServiceImplDupPkg - : public ::grpc::testing::duplicate::EchoTestService::Service { - public: - Status Echo(ServerContext* /*context*/, const EchoRequest* /*request*/, - EchoResponse* response) override { - response->set_message("no package"); - return Status::OK; - } -}; - -class TestScenario { - public: - TestScenario(bool interceptors, bool proxy, bool inproc_stub, - const TString& creds_type, bool use_callback_server) - : use_interceptors(interceptors), - use_proxy(proxy), - inproc(inproc_stub), - credentials_type(creds_type), - callback_server(use_callback_server) {} - void Log() const; - bool use_interceptors; - bool use_proxy; - bool inproc; - const TString credentials_type; - bool callback_server; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{use_interceptors=" - << (scenario.use_interceptors ? "true" : "false") - << ", use_proxy=" << (scenario.use_proxy ? "true" : "false") - << ", inproc=" << (scenario.inproc ? "true" : "false") - << ", server_type=" - << (scenario.callback_server ? "callback" : "sync") - << ", credentials='" << scenario.credentials_type << "'}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_DEBUG, "%s", out.str().c_str()); -} - -class End2endTest : public ::testing::TestWithParam<TestScenario> { - protected: - static void SetUpTestCase() { grpc_init(); } - static void TearDownTestCase() { grpc_shutdown(); } - End2endTest() - : is_server_started_(false), - kMaxMessageSize_(8192), - special_service_("special"), - first_picked_port_(0) { - GetParam().Log(); - } - - void TearDown() override { - if (is_server_started_) { - server_->Shutdown(); - if (proxy_server_) proxy_server_->Shutdown(); - } - if (first_picked_port_ > 0) { - grpc_recycle_unused_port(first_picked_port_); - } - } - - void StartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) { - int port = grpc_pick_unused_port_or_die(); - first_picked_port_ = port; - server_address_ << "localhost:" << port; - // Setup server - BuildAndStartServer(processor); - } - - void RestartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) { - if (is_server_started_) { - server_->Shutdown(); - BuildAndStartServer(processor); - } - } - - void BuildAndStartServer( - const std::shared_ptr<AuthMetadataProcessor>& processor) { - ServerBuilder builder; - ConfigureServerBuilder(&builder); - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - if (GetParam().credentials_type != kInsecureCredentialsType) { - server_creds->SetAuthMetadataProcessor(processor); - } - if (GetParam().use_interceptors) { - std::vector< - std::unique_ptr<experimental::ServerInterceptorFactoryInterface>> - creators; - // Add 20 phony server interceptors - creators.reserve(20); - for (auto i = 0; i < 20; i++) { - creators.push_back(y_absl::make_unique<PhonyInterceptorFactory>()); - } - builder.experimental().SetInterceptorCreators(std::move(creators)); - } - builder.AddListeningPort(server_address_.str(), server_creds); - if (!GetParam().callback_server) { - builder.RegisterService(&service_); - } else { - builder.RegisterService(&callback_service_); - } - builder.RegisterService("foo.test.youtube.com", &special_service_); - builder.RegisterService(&dup_pkg_service_); - - builder.SetSyncServerOption(ServerBuilder::SyncServerOption::NUM_CQS, 4); - builder.SetSyncServerOption( - ServerBuilder::SyncServerOption::CQ_TIMEOUT_MSEC, 10); - - server_ = builder.BuildAndStart(); - is_server_started_ = true; - } - - virtual void ConfigureServerBuilder(ServerBuilder* builder) { - builder->SetMaxMessageSize( - kMaxMessageSize_); // For testing max message size. - } - - void ResetChannel( - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators = {}) { - if (!is_server_started_) { - StartServer(std::shared_ptr<AuthMetadataProcessor>()); - } - EXPECT_TRUE(is_server_started_); - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - if (!user_agent_prefix_.empty()) { - args.SetUserAgentPrefix(user_agent_prefix_); - } - args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); - - if (!GetParam().inproc) { - if (!GetParam().use_interceptors) { - channel_ = ::grpc::CreateCustomChannel(server_address_.str(), - channel_creds, args); - } else { - channel_ = CreateCustomChannelWithInterceptors( - server_address_.str(), channel_creds, args, - interceptor_creators.empty() ? CreatePhonyClientInterceptors() - : std::move(interceptor_creators)); - } - } else { - if (!GetParam().use_interceptors) { - channel_ = server_->InProcessChannel(args); - } else { - channel_ = server_->experimental().InProcessChannelWithInterceptors( - args, interceptor_creators.empty() - ? CreatePhonyClientInterceptors() - : std::move(interceptor_creators)); - } - } - } - - void ResetStub( - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators = {}) { - ResetChannel(std::move(interceptor_creators)); - if (GetParam().use_proxy) { - proxy_service_ = y_absl::make_unique<Proxy>(channel_); - int port = grpc_pick_unused_port_or_die(); - std::ostringstream proxyaddr; - proxyaddr << "localhost:" << port; - ServerBuilder builder; - builder.AddListeningPort(proxyaddr.str(), InsecureServerCredentials()); - builder.RegisterService(proxy_service_.get()); - - builder.SetSyncServerOption(ServerBuilder::SyncServerOption::NUM_CQS, 4); - builder.SetSyncServerOption( - ServerBuilder::SyncServerOption::CQ_TIMEOUT_MSEC, 10); - - proxy_server_ = builder.BuildAndStart(); - - channel_ = - grpc::CreateChannel(proxyaddr.str(), InsecureChannelCredentials()); - } - - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - PhonyInterceptor::Reset(); - } - - bool is_server_started_; - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::unique_ptr<Server> proxy_server_; - std::unique_ptr<Proxy> proxy_service_; - std::ostringstream server_address_; - const int kMaxMessageSize_; - TestServiceImpl service_; - CallbackTestServiceImpl callback_service_; - TestServiceImpl special_service_; - TestServiceImplDupPkg dup_pkg_service_; - TString user_agent_prefix_; - int first_picked_port_; -}; - -void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs, - bool with_binary_metadata) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello hello hello hello"); - - for (int i = 0; i < num_rpcs; ++i) { - ClientContext context; - if (with_binary_metadata) { - char bytes[8] = {'\0', '\1', '\2', '\3', - '\4', '\5', '\6', static_cast<char>(i)}; - context.AddMetadata("custom-bin", TString(bytes, 8)); - } - context.set_compression_algorithm(GRPC_COMPRESS_GZIP); - Status s = stub->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - } -} - -// This class is for testing scenarios where RPCs are cancelled on the server -// by calling ServerContext::TryCancel() -class End2endServerTryCancelTest : public End2endTest { - protected: - // Helper for testing client-streaming RPCs which are cancelled on the server. - // Depending on the value of server_try_cancel parameter, this will test one - // of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before reading - // any messages from the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while reading - // messages from the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after reading all - // the messages from the client - // - // NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL. - void TestRequestStreamServerCancel( - ServerTryCancelRequestPhase server_try_cancel, int num_msgs_to_send) { - RestartServer(std::shared_ptr<AuthMetadataProcessor>()); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - // Send server_try_cancel value in the client metadata - context.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - - auto stream = stub_->RequestStream(&context, &response); - - int num_msgs_sent = 0; - while (num_msgs_sent < num_msgs_to_send) { - request.set_message("hello"); - if (!stream->Write(request)) { - break; - } - num_msgs_sent++; - } - gpr_log(GPR_INFO, "Sent %d messages", num_msgs_sent); - - stream->WritesDone(); - Status s = stream->Finish(); - - // At this point, we know for sure that RPC was cancelled by the server - // since we passed server_try_cancel value in the metadata. Depending on the - // value of server_try_cancel, the RPC might have been cancelled by the - // server at different stages. The following validates our expectations of - // number of messages sent in various cancellation scenarios: - - switch (server_try_cancel) { - case CANCEL_BEFORE_PROCESSING: - case CANCEL_DURING_PROCESSING: - // If the RPC is cancelled by server before / during messages from the - // client, it means that the client most likely did not get a chance to - // send all the messages it wanted to send. i.e num_msgs_sent <= - // num_msgs_to_send - EXPECT_LE(num_msgs_sent, num_msgs_to_send); - break; - - case CANCEL_AFTER_PROCESSING: - // If the RPC was cancelled after all messages were read by the server, - // the client did get a chance to send all its messages - EXPECT_EQ(num_msgs_sent, num_msgs_to_send); - break; - - default: - gpr_log(GPR_ERROR, "Invalid server_try_cancel value: %d", - server_try_cancel); - EXPECT_TRUE(server_try_cancel > DO_NOT_CANCEL && - server_try_cancel <= CANCEL_AFTER_PROCESSING); - break; - } - - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } - } - - // Helper for testing server-streaming RPCs which are cancelled on the server. - // Depending on the value of server_try_cancel parameter, this will test one - // of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before writing - // any messages to the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while writing - // messages to the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after writing all - // the messages to the client - // - // NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL. - void TestResponseStreamServerCancel( - ServerTryCancelRequestPhase server_try_cancel) { - RestartServer(std::shared_ptr<AuthMetadataProcessor>()); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - // Send server_try_cancel in the client metadata - context.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - - request.set_message("hello"); - auto stream = stub_->ResponseStream(&context, request); - - int num_msgs_read = 0; - while (num_msgs_read < kServerDefaultResponseStreamsToSend) { - if (!stream->Read(&response)) { - break; - } - EXPECT_EQ(response.message(), - request.message() + ToString(num_msgs_read)); - num_msgs_read++; - } - gpr_log(GPR_INFO, "Read %d messages", num_msgs_read); - - Status s = stream->Finish(); - - // Depending on the value of server_try_cancel, the RPC might have been - // cancelled by the server at different stages. The following validates our - // expectations of number of messages read in various cancellation - // scenarios: - switch (server_try_cancel) { - case CANCEL_BEFORE_PROCESSING: - // Server cancelled before sending any messages. Which means the client - // wouldn't have read any - EXPECT_EQ(num_msgs_read, 0); - break; - - case CANCEL_DURING_PROCESSING: - // Server cancelled while writing messages. Client must have read less - // than or equal to the expected number of messages - EXPECT_LE(num_msgs_read, kServerDefaultResponseStreamsToSend); - break; - - case CANCEL_AFTER_PROCESSING: - // Even though the Server cancelled after writing all messages, the RPC - // may be cancelled before the Client got a chance to read all the - // messages. - EXPECT_LE(num_msgs_read, kServerDefaultResponseStreamsToSend); - break; - - default: { - gpr_log(GPR_ERROR, "Invalid server_try_cancel value: %d", - server_try_cancel); - EXPECT_TRUE(server_try_cancel > DO_NOT_CANCEL && - server_try_cancel <= CANCEL_AFTER_PROCESSING); - break; - } - } - - EXPECT_FALSE(s.ok()); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } - } - - // Helper for testing bidirectional-streaming RPCs which are cancelled on the - // server. Depending on the value of server_try_cancel parameter, this will - // test one of the following three scenarios: - // CANCEL_BEFORE_PROCESSING: Rpc is cancelled by the server before reading/ - // writing any messages from/to the client - // - // CANCEL_DURING_PROCESSING: Rpc is cancelled by the server while reading/ - // writing messages from/to the client - // - // CANCEL_AFTER PROCESSING: Rpc is cancelled by server after reading/writing - // all the messages from/to the client - // - // NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL. - void TestBidiStreamServerCancel(ServerTryCancelRequestPhase server_try_cancel, - int num_messages) { - RestartServer(std::shared_ptr<AuthMetadataProcessor>()); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - // Send server_try_cancel in the client metadata - context.AddMetadata(kServerTryCancelRequest, - ToString(server_try_cancel)); - - auto stream = stub_->BidiStream(&context); - - int num_msgs_read = 0; - int num_msgs_sent = 0; - while (num_msgs_sent < num_messages) { - request.set_message("hello " + ToString(num_msgs_sent)); - if (!stream->Write(request)) { - break; - } - num_msgs_sent++; - - if (!stream->Read(&response)) { - break; - } - num_msgs_read++; - - EXPECT_EQ(response.message(), request.message()); - } - gpr_log(GPR_INFO, "Sent %d messages", num_msgs_sent); - gpr_log(GPR_INFO, "Read %d messages", num_msgs_read); - - stream->WritesDone(); - Status s = stream->Finish(); - - // Depending on the value of server_try_cancel, the RPC might have been - // cancelled by the server at different stages. The following validates our - // expectations of number of messages read in various cancellation - // scenarios: - switch (server_try_cancel) { - case CANCEL_BEFORE_PROCESSING: - EXPECT_EQ(num_msgs_read, 0); - break; - - case CANCEL_DURING_PROCESSING: - EXPECT_LE(num_msgs_sent, num_messages); - EXPECT_LE(num_msgs_read, num_msgs_sent); - break; - - case CANCEL_AFTER_PROCESSING: - EXPECT_EQ(num_msgs_sent, num_messages); - - // The Server cancelled after reading the last message and after writing - // the message to the client. However, the RPC cancellation might have - // taken effect before the client actually read the response. - EXPECT_LE(num_msgs_read, num_msgs_sent); - break; - - default: - gpr_log(GPR_ERROR, "Invalid server_try_cancel value: %d", - server_try_cancel); - EXPECT_TRUE(server_try_cancel > DO_NOT_CANCEL && - server_try_cancel <= CANCEL_AFTER_PROCESSING); - break; - } - - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - // Make sure that the server interceptors were notified - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } - } -}; - -TEST_P(End2endServerTryCancelTest, RequestEchoServerCancel) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.AddMetadata(kServerTryCancelRequest, - ToString(CANCEL_BEFORE_PROCESSING)); - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); -} - -// Server to cancel before doing reading the request -TEST_P(End2endServerTryCancelTest, RequestStreamServerCancelBeforeReads) { - TestRequestStreamServerCancel(CANCEL_BEFORE_PROCESSING, 1); -} - -// Server to cancel while reading a request from the stream in parallel -TEST_P(End2endServerTryCancelTest, RequestStreamServerCancelDuringRead) { - TestRequestStreamServerCancel(CANCEL_DURING_PROCESSING, 10); -} - -// Server to cancel after reading all the requests but before returning to the -// client -TEST_P(End2endServerTryCancelTest, RequestStreamServerCancelAfterReads) { - TestRequestStreamServerCancel(CANCEL_AFTER_PROCESSING, 4); -} - -// Server to cancel before sending any response messages -TEST_P(End2endServerTryCancelTest, ResponseStreamServerCancelBefore) { - TestResponseStreamServerCancel(CANCEL_BEFORE_PROCESSING); -} - -// Server to cancel while writing a response to the stream in parallel -TEST_P(End2endServerTryCancelTest, ResponseStreamServerCancelDuring) { - TestResponseStreamServerCancel(CANCEL_DURING_PROCESSING); -} - -// Server to cancel after writing all the respones to the stream but before -// returning to the client -TEST_P(End2endServerTryCancelTest, ResponseStreamServerCancelAfter) { - TestResponseStreamServerCancel(CANCEL_AFTER_PROCESSING); -} - -// Server to cancel before reading/writing any requests/responses on the stream -TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelBefore) { - TestBidiStreamServerCancel(CANCEL_BEFORE_PROCESSING, 2); -} - -// Server to cancel while reading/writing requests/responses on the stream in -// parallel -TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelDuring) { - TestBidiStreamServerCancel(CANCEL_DURING_PROCESSING, 10); -} - -// Server to cancel after reading/writing all requests/responses on the stream -// but before returning to the client -TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelAfter) { - TestBidiStreamServerCancel(CANCEL_AFTER_PROCESSING, 5); -} - -TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) { - // User-Agent is an HTTP header for HTTP transports only - if (GetParam().inproc) { - return; - } - user_agent_prefix_ = "custom_prefix"; - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello hello hello hello"); - request.mutable_param()->set_echo_metadata(true); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - const auto& trailing_metadata = context.GetServerTrailingMetadata(); - auto iter = trailing_metadata.find("user-agent"); - EXPECT_TRUE(iter != trailing_metadata.end()); - TString expected_prefix = user_agent_prefix_ + " grpc-c++/"; - EXPECT_TRUE(iter->second.starts_with(expected_prefix)) << iter->second; -} - -TEST_P(End2endTest, MultipleRpcsWithVariedBinaryMetadataValue) { - ResetStub(); - std::vector<std::thread> threads; - threads.reserve(10); - for (int i = 0; i < 10; ++i) { - threads.emplace_back(SendRpc, stub_.get(), 10, true); - } - for (int i = 0; i < 10; ++i) { - threads[i].join(); - } -} - -TEST_P(End2endTest, MultipleRpcs) { - ResetStub(); - std::vector<std::thread> threads; - threads.reserve(10); - for (int i = 0; i < 10; ++i) { - threads.emplace_back(SendRpc, stub_.get(), 10, false); - } - for (int i = 0; i < 10; ++i) { - threads[i].join(); - } -} - -TEST_P(End2endTest, ManyStubs) { - ResetStub(); - ChannelTestPeer peer(channel_.get()); - int registered_calls_pre = peer.registered_calls(); - int registration_attempts_pre = peer.registration_attempts(); - for (int i = 0; i < 1000; ++i) { - grpc::testing::EchoTestService::NewStub(channel_); - } - EXPECT_EQ(peer.registered_calls(), registered_calls_pre); - EXPECT_GT(peer.registration_attempts(), registration_attempts_pre); -} - -TEST_P(End2endTest, EmptyBinaryMetadata) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello hello hello hello"); - ClientContext context; - context.AddMetadata("custom-bin", ""); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, ReconnectChannel) { - if (GetParam().inproc) { - return; - } - int poller_slowdown_factor = 1; - // It needs 2 pollset_works to reconnect the channel with polling engine - // "poll" -#ifdef GRPC_POSIX_SOCKET_EV - grpc_core::UniquePtr<char> poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { - poller_slowdown_factor = 2; - } -#endif // GRPC_POSIX_SOCKET_EV - ResetStub(); - SendRpc(stub_.get(), 1, false); - RestartServer(std::shared_ptr<AuthMetadataProcessor>()); - // It needs more than GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS time to - // reconnect the channel. Make it a factor of 5x - gpr_sleep_until( - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(kClientChannelBackupPollIntervalMs * 5 * - poller_slowdown_factor * - grpc_test_slowdown_factor(), - GPR_TIMESPAN))); - SendRpc(stub_.get(), 1, false); -} - -TEST_P(End2endTest, RequestStreamOneRequest) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - EXPECT_TRUE(stream->Write(request)); - stream->WritesDone(); - Status s = stream->Finish(); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(context.debug_error_string().empty()); -} - -TEST_P(End2endTest, RequestStreamOneRequestWithCoalescingApi) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.set_initial_metadata_corked(true); - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - stream->WriteLast(request, WriteOptions()); - Status s = stream->Finish(); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, RequestStreamTwoRequests) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Write(request)); - stream->WritesDone(); - Status s = stream->Finish(); - EXPECT_EQ(response.message(), "hellohello"); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, RequestStreamTwoRequestsWithWriteThrough) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - EXPECT_TRUE(stream->Write(request, WriteOptions().set_write_through())); - EXPECT_TRUE(stream->Write(request, WriteOptions().set_write_through())); - stream->WritesDone(); - Status s = stream->Finish(); - EXPECT_EQ(response.message(), "hellohello"); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, RequestStreamTwoRequestsWithCoalescingApi) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.set_initial_metadata_corked(true); - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - EXPECT_TRUE(stream->Write(request)); - stream->WriteLast(request, WriteOptions()); - Status s = stream->Finish(); - EXPECT_EQ(response.message(), "hellohello"); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, ResponseStream) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - - auto stream = stub_->ResponseStream(&context, request); - for (int i = 0; i < kServerDefaultResponseStreamsToSend; ++i) { - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + ToString(i)); - } - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, ResponseStreamWithCoalescingApi) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - context.AddMetadata(kServerUseCoalescingApi, "1"); - - auto stream = stub_->ResponseStream(&context, request); - for (int i = 0; i < kServerDefaultResponseStreamsToSend; ++i) { - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + ToString(i)); - } - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -// This was added to prevent regression from issue: -// https://github.com/grpc/grpc/issues/11546 -TEST_P(End2endTest, ResponseStreamWithEverythingCoalesced) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - context.AddMetadata(kServerUseCoalescingApi, "1"); - // We will only send one message, forcing everything (init metadata, message, - // trailing) to be coalesced together. - context.AddMetadata(kServerResponseStreamsToSend, "1"); - - auto stream = stub_->ResponseStream(&context, request); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "0"); - - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, BidiStream) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - TString msg("hello"); - - auto stream = stub_->BidiStream(&context); - - for (int i = 0; i < kServerDefaultResponseStreamsToSend; ++i) { - request.set_message(msg + ToString(i)); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - } - - stream->WritesDone(); - EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, BidiStreamWithCoalescingApi) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.AddMetadata(kServerFinishAfterNReads, "3"); - context.set_initial_metadata_corked(true); - TString msg("hello"); - - auto stream = stub_->BidiStream(&context); - - request.set_message(msg + "0"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "1"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "2"); - stream->WriteLast(request, WriteOptions()); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -// This was added to prevent regression from issue: -// https://github.com/grpc/grpc/issues/11546 -TEST_P(End2endTest, BidiStreamWithEverythingCoalesced) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.AddMetadata(kServerFinishAfterNReads, "1"); - context.set_initial_metadata_corked(true); - TString msg("hello"); - - auto stream = stub_->BidiStream(&context); - - request.set_message(msg + "0"); - stream->WriteLast(request, WriteOptions()); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -// Talk to the two services with the same name but different package names. -// The two stubs are created on the same channel. -TEST_P(End2endTest, DiffPackageServices) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - - std::unique_ptr<grpc::testing::duplicate::EchoTestService::Stub> dup_pkg_stub( - grpc::testing::duplicate::EchoTestService::NewStub(channel_)); - ClientContext context2; - s = dup_pkg_stub->Echo(&context2, request, &response); - EXPECT_EQ("no package", response.message()); - EXPECT_TRUE(s.ok()); -} - -template <class ServiceType> -void CancelRpc(ClientContext* context, int delay_us, ServiceType* service) { - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(delay_us, GPR_TIMESPAN))); - while (!service->signal_client()) { - } - context->TryCancel(); -} - -TEST_P(End2endTest, CancelRpcBeforeStart) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - context.TryCancel(); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ("", response.message()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(End2endTest, CancelRpcAfterStart) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - request.mutable_param()->set_server_notify_client_when_started(true); - request.mutable_param()->set_skip_cancelled_check(true); - Status s; - std::thread echo_thread([this, &s, &context, &request, &response] { - s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); - }); - if (!GetParam().callback_server) { - service_.ClientWaitUntilRpcStarted(); - } else { - callback_service_.ClientWaitUntilRpcStarted(); - } - - context.TryCancel(); - - if (!GetParam().callback_server) { - service_.SignalServerToContinue(); - } else { - callback_service_.SignalServerToContinue(); - } - - echo_thread.join(); - EXPECT_EQ("", response.message()); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Client cancels request stream after sending two messages -TEST_P(End2endTest, ClientCancelsRequestStream) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - - auto stream = stub_->RequestStream(&context, &response); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Write(request)); - - context.TryCancel(); - - Status s = stream->Finish(); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - - EXPECT_EQ(response.message(), ""); - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Client cancels server stream after sending some messages -TEST_P(End2endTest, ClientCancelsResponseStream) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("hello"); - - auto stream = stub_->ResponseStream(&context, request); - - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "0"); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "1"); - - context.TryCancel(); - - // The cancellation races with responses, so there might be zero or - // one responses pending, read till failure - - if (stream->Read(&response)) { - EXPECT_EQ(response.message(), request.message() + "2"); - // Since we have cancelled, we expect the next attempt to read to fail - EXPECT_FALSE(stream->Read(&response)); - } - - Status s = stream->Finish(); - // The final status could be either of CANCELLED or OK depending on - // who won the race. - EXPECT_GE(grpc::StatusCode::CANCELLED, s.error_code()); - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -// Client cancels bidi stream after sending some messages -TEST_P(End2endTest, ClientCancelsBidi) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - TString msg("hello"); - - // Send server_try_cancel value in the client metadata - context.AddMetadata(kClientTryCancelRequest, ToString(1)); - - auto stream = stub_->BidiStream(&context); - - request.set_message(msg + "0"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "1"); - EXPECT_TRUE(stream->Write(request)); - - context.TryCancel(); - - // The cancellation races with responses, so there might be zero or - // one responses pending, read till failure - - if (stream->Read(&response)) { - EXPECT_EQ(response.message(), request.message()); - // Since we have cancelled, we expect the next attempt to read to fail - EXPECT_FALSE(stream->Read(&response)); - } - - Status s = stream->Finish(); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); - if (GetParam().use_interceptors) { - EXPECT_EQ(20, PhonyInterceptor::GetNumTimesCancel()); - } -} - -TEST_P(End2endTest, RpcMaxMessageSize) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message(string(kMaxMessageSize_ * 2, 'a')); - request.mutable_param()->set_server_die(true); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); -} - -void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream, - gpr_event* ev) { - EchoResponse resp; - gpr_event_set(ev, reinterpret_cast<void*>(1)); - while (stream->Read(&resp)) { - gpr_log(GPR_INFO, "Read message"); - } -} - -// Run a Read and a WritesDone simultaneously. -TEST_P(End2endTest, SimultaneousReadWritesDone) { - ResetStub(); - ClientContext context; - gpr_event ev; - gpr_event_init(&ev); - auto stream = stub_->BidiStream(&context); - std::thread reader_thread(ReaderThreadFunc, stream.get(), &ev); - gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME)); - stream->WritesDone(); - reader_thread.join(); - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); -} - -TEST_P(End2endTest, ChannelState) { - if (GetParam().inproc) { - return; - } - - ResetStub(); - // Start IDLE - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(false)); - - // Did not ask to connect, no state change. - CompletionQueue cq; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::milliseconds(10); - channel_->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, &cq, nullptr); - void* tag; - bool ok = true; - cq.Next(&tag, &ok); - EXPECT_FALSE(ok); - - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(true)); - EXPECT_TRUE(channel_->WaitForStateChange(GRPC_CHANNEL_IDLE, - gpr_inf_future(GPR_CLOCK_REALTIME))); - auto state = channel_->GetState(false); - EXPECT_TRUE(state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_READY); -} - -// Takes 10s. -TEST_P(End2endTest, ChannelStateTimeout) { - if ((GetParam().credentials_type != kInsecureCredentialsType) || - GetParam().inproc) { - return; - } - int port = grpc_pick_unused_port_or_die(); - std::ostringstream server_address; - server_address << "localhost:" << port; - // Channel to non-existing server - auto channel = - grpc::CreateChannel(server_address.str(), InsecureChannelCredentials()); - // Start IDLE - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(true)); - - auto state = GRPC_CHANNEL_IDLE; - for (int i = 0; i < 10; i++) { - channel->WaitForStateChange( - state, std::chrono::system_clock::now() + std::chrono::seconds(1)); - state = channel->GetState(false); - } -} - -TEST_P(End2endTest, ChannelStateOnLameChannel) { - if ((GetParam().credentials_type != kInsecureCredentialsType) || - GetParam().inproc) { - return; - } - // Channel using invalid target URI. This creates a lame channel. - auto channel = grpc::CreateChannel("dns:///", InsecureChannelCredentials()); - // Channel should immediately report TRANSIENT_FAILURE. - EXPECT_EQ(GRPC_CHANNEL_TRANSIENT_FAILURE, channel->GetState(true)); - // And state will never change. - auto state = GRPC_CHANNEL_TRANSIENT_FAILURE; - for (int i = 0; i < 10; ++i) { - channel->WaitForStateChange( - state, std::chrono::system_clock::now() + std::chrono::seconds(1)); - state = channel->GetState(false); - } -} - -// Talking to a non-existing service. -TEST_P(End2endTest, NonExistingService) { - ResetChannel(); - std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub; - stub = grpc::testing::UnimplementedEchoService::NewStub(channel_); - - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - Status s = stub->Unimplemented(&context, request, &response); - EXPECT_EQ(StatusCode::UNIMPLEMENTED, s.error_code()); - EXPECT_EQ("", s.error_message()); -} - -// Ask the server to send back a serialized proto in trailer. -// This is an example of setting error details. -TEST_P(End2endTest, BinaryTrailerTest) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - request.mutable_param()->set_echo_metadata(true); - DebugInfo* info = request.mutable_param()->mutable_debug_info(); - info->add_stack_entries("stack_entry_1"); - info->add_stack_entries("stack_entry_2"); - info->add_stack_entries("stack_entry_3"); - info->set_detail("detailed debug info"); - TString expected_string = info->SerializeAsString(); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - auto trailers = context.GetServerTrailingMetadata(); - EXPECT_EQ(1u, trailers.count(kDebugInfoTrailerKey)); - auto iter = trailers.find(kDebugInfoTrailerKey); - EXPECT_EQ(expected_string, iter->second); - // Parse the returned trailer into a DebugInfo proto. - DebugInfo returned_info; - EXPECT_TRUE(returned_info.ParseFromString(ToString(iter->second))); -} - -TEST_P(End2endTest, ExpectErrorTest) { - ResetStub(); - - std::vector<ErrorStatus> expected_status; - expected_status.emplace_back(); - expected_status.back().set_code(13); // INTERNAL - // No Error message or details - - expected_status.emplace_back(); - expected_status.back().set_code(13); // INTERNAL - expected_status.back().set_error_message("text error message"); - expected_status.back().set_binary_error_details("text error details"); - - expected_status.emplace_back(); - expected_status.back().set_code(13); // INTERNAL - expected_status.back().set_error_message("text error message"); - expected_status.back().set_binary_error_details( - "\x0\x1\x2\x3\x4\x5\x6\x8\x9\xA\xB"); - - for (auto iter = expected_status.begin(); iter != expected_status.end(); - ++iter) { - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("Hello"); - auto* error = request.mutable_param()->mutable_expected_error(); - error->set_code(iter->code()); - error->set_error_message(iter->error_message()); - error->set_binary_error_details(iter->binary_error_details()); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(iter->code(), s.error_code()); - EXPECT_EQ(iter->error_message(), s.error_message()); - EXPECT_EQ(iter->binary_error_details(), s.error_details()); - EXPECT_TRUE(y_absl::StrContains(context.debug_error_string(), "created")); -#ifndef NDEBUG - // GRPC_ERROR_INT_FILE_LINE is for debug only - EXPECT_TRUE(y_absl::StrContains(context.debug_error_string(), "file")); - EXPECT_TRUE(y_absl::StrContains(context.debug_error_string(), "line")); -#endif - EXPECT_TRUE(y_absl::StrContains(context.debug_error_string(), "status")); - EXPECT_TRUE(y_absl::StrContains(context.debug_error_string(), "13")); - } -} - -////////////////////////////////////////////////////////////////////////// -// Test with and without a proxy. -class ProxyEnd2endTest : public End2endTest { - protected: -}; - -TEST_P(ProxyEnd2endTest, SimpleRpc) { - ResetStub(); - SendRpc(stub_.get(), 1, false); -} - -TEST_P(ProxyEnd2endTest, SimpleRpcWithEmptyMessages) { - ResetStub(); - EchoRequest request; - EchoResponse response; - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_TRUE(s.ok()); -} - -TEST_P(ProxyEnd2endTest, MultipleRpcs) { - ResetStub(); - std::vector<std::thread> threads; - threads.reserve(10); - for (int i = 0; i < 10; ++i) { - threads.emplace_back(SendRpc, stub_.get(), 10, false); - } - for (int i = 0; i < 10; ++i) { - threads[i].join(); - } -} - -// Set a 10us deadline and make sure proper error is returned. -TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - request.mutable_param()->set_skip_cancelled_check(true); - // Let server sleep for 40 ms first to guarantee expiry. - // 40 ms might seem a bit extreme but the timer manager would have been just - // initialized (when ResetStub() was called) and there are some warmup costs - // i.e the timer thread many not have even started. There might also be other - // delays in the timer manager thread (in acquiring locks, timer data - // structure manipulations, starting backup timer threads) that add to the - // delays. 40ms is still not enough in some cases but this significantly - // reduces the test flakes - request.mutable_param()->set_server_sleep_us(40 * 1000); - - ClientContext context; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::milliseconds(1); - context.set_deadline(deadline); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.error_code()); -} - -// Set a long but finite deadline. -TEST_P(ProxyEnd2endTest, RpcLongDeadline) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::hours(1); - context.set_deadline(deadline); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); -} - -// Ask server to echo back the deadline it sees. -TEST_P(ProxyEnd2endTest, EchoDeadline) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - request.mutable_param()->set_echo_deadline(true); - - ClientContext context; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::seconds(100); - context.set_deadline(deadline); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - gpr_timespec sent_deadline; - Timepoint2Timespec(deadline, &sent_deadline); - // We want to allow some reasonable error given: - // - request_deadline() only has 1sec resolution so the best we can do is +-1 - // - if sent_deadline.tv_nsec is very close to the next second's boundary we - // can end up being off by 2 in one direction. - EXPECT_LE(response.param().request_deadline() - sent_deadline.tv_sec, 2); - EXPECT_GE(response.param().request_deadline() - sent_deadline.tv_sec, -1); -} - -// Ask server to echo back the deadline it sees. The rpc has no deadline. -TEST_P(ProxyEnd2endTest, EchoDeadlineForNoDeadlineRpc) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - request.mutable_param()->set_echo_deadline(true); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(response.param().request_deadline(), - gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec); -} - -TEST_P(ProxyEnd2endTest, UnimplementedRpc) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - Status s = stub_->Unimplemented(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), grpc::StatusCode::UNIMPLEMENTED); - EXPECT_EQ(s.error_message(), ""); - EXPECT_EQ(response.message(), ""); -} - -// Client cancels rpc after 10ms -TEST_P(ProxyEnd2endTest, ClientCancelsRpc) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - const int kCancelDelayUs = 10 * 1000; - request.mutable_param()->set_client_cancel_after_us(kCancelDelayUs); - - ClientContext context; - std::thread cancel_thread; - if (!GetParam().callback_server) { - cancel_thread = std::thread( - [&context, this](int delay) { CancelRpc(&context, delay, &service_); }, - kCancelDelayUs); - // Note: the unusual pattern above (and below) is caused by a conflict - // between two sets of compiler expectations. clang allows const to be - // captured without mention, so there is no need to capture kCancelDelayUs - // (and indeed clang-tidy complains if you do so). OTOH, a Windows compiler - // in our tests requires an explicit capture even for const. We square this - // circle by passing the const value in as an argument to the lambda. - } else { - cancel_thread = std::thread( - [&context, this](int delay) { - CancelRpc(&context, delay, &callback_service_); - }, - kCancelDelayUs); - } - Status s = stub_->Echo(&context, request, &response); - cancel_thread.join(); - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ(s.error_message(), "CANCELLED"); -} - -// Server cancels rpc after 1ms -TEST_P(ProxyEnd2endTest, ServerCancelsRpc) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - request.mutable_param()->set_server_cancel_after_us(1000); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); - EXPECT_TRUE(s.error_message().empty()); -} - -// Make the response larger than the flow control window. -TEST_P(ProxyEnd2endTest, HugeResponse) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("huge response"); - const size_t kResponseSize = 1024 * (1024 + 10); - request.mutable_param()->set_response_message_length(kResponseSize); - - ClientContext context; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::seconds(20); - context.set_deadline(deadline); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(kResponseSize, response.message().size()); - EXPECT_TRUE(s.ok()); -} - -TEST_P(ProxyEnd2endTest, Peer) { - // Peer is not meaningful for inproc - if (GetParam().inproc) { - return; - } - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("hello"); - request.mutable_param()->set_echo_peer(true); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(CheckIsLocalhost(response.param().peer())); - EXPECT_TRUE(CheckIsLocalhost(context.peer())); -} - -////////////////////////////////////////////////////////////////////////// -class SecureEnd2endTest : public End2endTest { - protected: - SecureEnd2endTest() { - GPR_ASSERT(!GetParam().use_proxy); - GPR_ASSERT(GetParam().credentials_type != kInsecureCredentialsType); - } -}; - -TEST_P(SecureEnd2endTest, SimpleRpcWithHost) { - ResetStub(); - - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - context.set_authority("foo.test.youtube.com"); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(response.has_param()); - EXPECT_EQ("special", response.param().host()); - EXPECT_TRUE(s.ok()); -} - -bool MetadataContains( - const std::multimap<grpc::string_ref, grpc::string_ref>& metadata, - const TString& key, const TString& value) { - int count = 0; - - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator iter = - metadata.begin(); - iter != metadata.end(); ++iter) { - if (ToString(iter->first) == key && ToString(iter->second) == value) { - count++; - } - } - return count == 1; -} - -TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorSuccess) { - auto* processor = new TestAuthMetadataProcessor(true); - StartServer(std::shared_ptr<AuthMetadataProcessor>(processor)); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(processor->GetCompatibleClientCreds()); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - request.mutable_param()->set_expected_client_identity( - TestAuthMetadataProcessor::kGoodGuy); - request.mutable_param()->set_expected_transport_security_type( - GetParam().credentials_type); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - - // Metadata should have been consumed by the processor. - EXPECT_FALSE(MetadataContains( - context.GetServerTrailingMetadata(), GRPC_AUTHORIZATION_METADATA_KEY, - TString("Bearer ") + TestAuthMetadataProcessor::kGoodGuy)); -} - -TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorFailure) { - auto* processor = new TestAuthMetadataProcessor(true); - StartServer(std::shared_ptr<AuthMetadataProcessor>(processor)); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(processor->GetIncompatibleClientCreds()); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED); -} - -TEST_P(SecureEnd2endTest, SetPerCallCredentials) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - std::shared_ptr<CallCredentials> creds = - GoogleIAMCredentials(kFakeToken, kFakeSelector); - context.set_credentials(creds); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - kFakeToken)); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - kFakeSelector)); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedFakeCredsDebugString); -} - -class CredentialsInterceptor : public experimental::Interceptor { - public: - explicit CredentialsInterceptor(experimental::ClientRpcInfo* info) - : info_(info) {} - - void Intercept(experimental::InterceptorBatchMethods* methods) override { - if (methods->QueryInterceptionHookPoint( - experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { - std::shared_ptr<CallCredentials> creds = - GoogleIAMCredentials(kFakeToken, kFakeSelector); - info_->client_context()->set_credentials(creds); - } - methods->Proceed(); - } - - private: - experimental::ClientRpcInfo* info_ = nullptr; -}; - -class CredentialsInterceptorFactory - : public experimental::ClientInterceptorFactoryInterface { - CredentialsInterceptor* CreateClientInterceptor( - experimental::ClientRpcInfo* info) override { - return new CredentialsInterceptor(info); - } -}; - -TEST_P(SecureEnd2endTest, CallCredentialsInterception) { - if (!GetParam().use_interceptors) { - return; - } - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators; - interceptor_creators.push_back( - y_absl::make_unique<CredentialsInterceptorFactory>()); - ResetStub(std::move(interceptor_creators)); - EchoRequest request; - EchoResponse response; - ClientContext context; - - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - kFakeToken)); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - kFakeSelector)); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedFakeCredsDebugString); -} - -TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { - if (!GetParam().use_interceptors) { - return; - } - std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators; - interceptor_creators.push_back( - y_absl::make_unique<CredentialsInterceptorFactory>()); - ResetStub(std::move(interceptor_creators)); - EchoRequest request; - EchoResponse response; - ClientContext context; - std::shared_ptr<CallCredentials> creds1 = - GoogleIAMCredentials(kWrongToken, kWrongSelector); - context.set_credentials(creds1); - EXPECT_EQ(context.credentials(), creds1); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedWrongCredsDebugString); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - kFakeToken)); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - kFakeSelector)); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedFakeCredsDebugString); -} - -TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - std::shared_ptr<CallCredentials> creds1 = - GoogleIAMCredentials(kFakeToken1, kFakeSelector1); - context.set_credentials(creds1); - EXPECT_EQ(context.credentials(), creds1); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedFakeCreds1DebugString); - std::shared_ptr<CallCredentials> creds2 = - GoogleIAMCredentials(kFakeToken2, kFakeSelector2); - context.set_credentials(creds2); - EXPECT_EQ(context.credentials(), creds2); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - kFakeToken2)); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - kFakeSelector2)); - EXPECT_FALSE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - kFakeToken1)); - EXPECT_FALSE(MetadataContains(context.GetServerTrailingMetadata(), - GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - kFakeSelector1)); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedFakeCreds2DebugString); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); -} - -TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kBadMetadataKey, - "Does not matter, will fail the key is invalid.", false, true, - 0)))); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedAuthMetadataPluginKeyFailureCredsDebugString); -} - -TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kGoodMetadataKey, - "With illegal \n value.", false, true, 0)))); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedAuthMetadataPluginValueFailureCredsDebugString); -} - -TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { - ResetStub(); - EchoRequest request; - request.mutable_param()->set_skip_cancelled_check(true); - EchoResponse response; - ClientContext context; - const int delay = 100; - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::now() + std::chrono::milliseconds(delay); - context.set_deadline(deadline); - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin("meta_key", "Does not matter", true, - true, delay)))); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - if (!s.ok()) { - EXPECT_TRUE(s.error_code() == StatusCode::DEADLINE_EXCEEDED || - s.error_code() == StatusCode::UNAVAILABLE); - } - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedAuthMetadataPluginWithDeadlineCredsDebugString); -} - -TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { - ResetStub(); - EchoRequest request; - request.mutable_param()->set_skip_cancelled_check(true); - EchoResponse response; - ClientContext context; - const int delay = 100; - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin("meta_key", "Does not matter", true, - true, delay)))); - request.set_message("Hello"); - - std::thread cancel_thread([&] { - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(delay, GPR_TIMESPAN))); - context.TryCancel(); - }); - Status s = stub_->Echo(&context, request, &response); - if (!s.ok()) { - EXPECT_TRUE(s.error_code() == StatusCode::CANCELLED || - s.error_code() == StatusCode::UNAVAILABLE); - } - cancel_thread.join(); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedAuthMetadataPluginWithDeadlineCredsDebugString); -} - -TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kGoodMetadataKey, - "Does not matter, will fail anyway (see 3rd param)", false, false, - 0)))); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); - EXPECT_EQ(s.error_message(), - TString("Getting metadata from plugin failed with error: ") + - kTestCredsPluginErrorMsg); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedNonBlockingAuthMetadataPluginFailureCredsDebugString); -} - -TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorSuccess) { - auto* processor = new TestAuthMetadataProcessor(false); - StartServer(std::shared_ptr<AuthMetadataProcessor>(processor)); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(processor->GetCompatibleClientCreds()); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - request.mutable_param()->set_expected_client_identity( - TestAuthMetadataProcessor::kGoodGuy); - request.mutable_param()->set_expected_transport_security_type( - GetParam().credentials_type); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - - // Metadata should have been consumed by the processor. - EXPECT_FALSE(MetadataContains( - context.GetServerTrailingMetadata(), GRPC_AUTHORIZATION_METADATA_KEY, - TString("Bearer ") + TestAuthMetadataProcessor::kGoodGuy)); - EXPECT_EQ( - context.credentials()->DebugString(), - kExpectedNonBlockingAuthMetadataPluginAndProcessorSuccessCredsDebugString); -} - -TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorFailure) { - auto* processor = new TestAuthMetadataProcessor(false); - StartServer(std::shared_ptr<AuthMetadataProcessor>(processor)); - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(processor->GetIncompatibleClientCreds()); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED); - EXPECT_EQ( - context.credentials()->DebugString(), - kExpectedNonBlockingAuthMetadataPluginAndProcessorFailureCredsDebugString); -} - -TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_credentials(grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin( - TestMetadataCredentialsPlugin::kGoodMetadataKey, - "Does not matter, will fail anyway (see 3rd param)", true, false, - 0)))); - request.set_message("Hello"); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); - EXPECT_EQ(s.error_message(), - TString("Getting metadata from plugin failed with error: ") + - kTestCredsPluginErrorMsg); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedBlockingAuthMetadataPluginFailureCredsDebugString); -} - -TEST_P(SecureEnd2endTest, CompositeCallCreds) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - const char kMetadataKey1[] = "call-creds-key1"; - const char kMetadataKey2[] = "call-creds-key2"; - const char kMetadataVal1[] = "call-creds-val1"; - const char kMetadataVal2[] = "call-creds-val2"; - - context.set_credentials(grpc::CompositeCallCredentials( - grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin(kMetadataKey1, kMetadataVal1, - true, true, 0))), - grpc::MetadataCredentialsFromPlugin( - std::unique_ptr<MetadataCredentialsPlugin>( - new TestMetadataCredentialsPlugin(kMetadataKey2, kMetadataVal2, - true, true, 0))))); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_TRUE(s.ok()); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - kMetadataKey1, kMetadataVal1)); - EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), - kMetadataKey2, kMetadataVal2)); - EXPECT_EQ(context.credentials()->DebugString(), - kExpectedCompositeCallCredsDebugString); -} - -TEST_P(SecureEnd2endTest, ClientAuthContext) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - request.mutable_param()->set_check_auth_context(GetParam().credentials_type == - kTlsCredentialsType); - request.mutable_param()->set_expected_transport_security_type( - GetParam().credentials_type); - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - - std::shared_ptr<const AuthContext> auth_ctx = context.auth_context(); - std::vector<grpc::string_ref> tst = - auth_ctx->FindPropertyValues("transport_security_type"); - ASSERT_EQ(1u, tst.size()); - EXPECT_EQ(GetParam().credentials_type, ToString(tst[0])); - if (GetParam().credentials_type == kTlsCredentialsType) { - EXPECT_EQ("x509_subject_alternative_name", - auth_ctx->GetPeerIdentityPropertyName()); - EXPECT_EQ(4u, auth_ctx->GetPeerIdentity().size()); - EXPECT_EQ("*.test.google.fr", ToString(auth_ctx->GetPeerIdentity()[0])); - EXPECT_EQ("waterzooi.test.google.be", - ToString(auth_ctx->GetPeerIdentity()[1])); - EXPECT_EQ("*.test.youtube.com", ToString(auth_ctx->GetPeerIdentity()[2])); - EXPECT_EQ("192.168.1.3", ToString(auth_ctx->GetPeerIdentity()[3])); - } -} - -class ResourceQuotaEnd2endTest : public End2endTest { - public: - ResourceQuotaEnd2endTest() - : server_resource_quota_("server_resource_quota") {} - - void ConfigureServerBuilder(ServerBuilder* builder) override { - builder->SetResourceQuota(server_resource_quota_); - } - - private: - ResourceQuota server_resource_quota_; -}; - -TEST_P(ResourceQuotaEnd2endTest, SimpleRequest) { - ResetStub(); - - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); -} - -// TODO(vjpai): refactor arguments into a struct if it makes sense -std::vector<TestScenario> CreateTestScenarios(bool use_proxy, - bool test_insecure, - bool test_secure, - bool test_inproc, - bool test_callback_server) { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types; - - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, - kClientChannelBackupPollIntervalMs); -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - - if (test_secure) { - credentials_types = - GetCredentialsProvider()->GetSecureCredentialsTypeList(); - } - auto insec_ok = [] { - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - return GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr; - }; - if (test_insecure && insec_ok()) { - credentials_types.push_back(kInsecureCredentialsType); - } - - // Test callback with inproc or if the event-engine allows it - GPR_ASSERT(!credentials_types.empty()); - for (const auto& cred : credentials_types) { - scenarios.emplace_back(false, false, false, cred, false); - scenarios.emplace_back(true, false, false, cred, false); - if (test_callback_server) { - // Note that these scenarios will be dynamically disabled if the event - // engine doesn't run in the background - scenarios.emplace_back(false, false, false, cred, true); - scenarios.emplace_back(true, false, false, cred, true); - } - if (use_proxy) { - scenarios.emplace_back(false, true, false, cred, false); - scenarios.emplace_back(true, true, false, cred, false); - } - } - if (test_inproc && insec_ok()) { - scenarios.emplace_back(false, false, true, kInsecureCredentialsType, false); - scenarios.emplace_back(true, false, true, kInsecureCredentialsType, false); - if (test_callback_server) { - scenarios.emplace_back(false, false, true, kInsecureCredentialsType, - true); - scenarios.emplace_back(true, false, true, kInsecureCredentialsType, true); - } - } - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P( - End2end, End2endTest, - ::testing::ValuesIn(CreateTestScenarios(false, true, true, true, true))); - -INSTANTIATE_TEST_SUITE_P( - End2endServerTryCancel, End2endServerTryCancelTest, - ::testing::ValuesIn(CreateTestScenarios(false, true, true, true, true))); - -INSTANTIATE_TEST_SUITE_P( - ProxyEnd2end, ProxyEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios(true, true, true, true, true))); - -INSTANTIATE_TEST_SUITE_P( - SecureEnd2end, SecureEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios(false, false, true, false, true))); - -INSTANTIATE_TEST_SUITE_P( - ResourceQuotaEnd2end, ResourceQuotaEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios(false, true, true, true, true))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/exception_test.cc b/contrib/libs/grpc/test/cpp/end2end/exception_test.cc deleted file mode 100644 index 1a4c418bed..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/exception_test.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/impl/codegen/port_platform.h> - -#include <exception> -#include <memory> - -#include <gtest/gtest.h> - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/test_config.h" - -namespace grpc { -namespace testing { - -const char* kErrorMessage = "This service caused an exception"; - -#if GRPC_ALLOW_EXCEPTIONS -class ExceptingServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - Status Echo(ServerContext* /*server_context*/, const EchoRequest* /*request*/, - EchoResponse* /*response*/) override { - throw -1; - } - Status RequestStream(ServerContext* /*context*/, - ServerReader<EchoRequest>* /*reader*/, - EchoResponse* /*response*/) override { - throw ServiceException(); - } - - private: - class ServiceException final : public std::exception { - public: - ServiceException() {} - - private: - const char* what() const noexcept override { return kErrorMessage; } - }; -}; - -class ExceptionTest : public ::testing::Test { - protected: - ExceptionTest() {} - - void SetUp() override { - ServerBuilder builder; - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - void TearDown() override { server_->Shutdown(); } - - void ResetStub() { - channel_ = server_->InProcessChannel(ChannelArguments()); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - ExceptingServiceImpl service_; -}; - -TEST_F(ExceptionTest, Unary) { - ResetStub(); - EchoRequest request; - EchoResponse response; - request.set_message("test"); - - for (int i = 0; i < 10; i++) { - ClientContext context; - Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN); - } -} - -TEST_F(ExceptionTest, RequestStream) { - ResetStub(); - EchoResponse response; - - for (int i = 0; i < 10; i++) { - ClientContext context; - auto stream = stub_->RequestStream(&context, &response); - stream->WritesDone(); - Status s = stream->Finish(); - - EXPECT_FALSE(s.ok()); - EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN); - } -} - -#endif // GRPC_ALLOW_EXCEPTIONS - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/filter_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/filter_end2end_test.cc deleted file mode 100644 index 839d6d17d0..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/filter_end2end_test.cc +++ /dev/null @@ -1,347 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <memory> -#include <mutex> -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/generic/async_generic_service.h> -#include <grpcpp/generic/generic_stub.h> -#include <grpcpp/impl/codegen/proto_utils.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/config.h> -#include <grpcpp/support/slice.h> - -#include "src/cpp/common/channel_filter.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { -namespace { - -void* tag(int i) { return reinterpret_cast<void*>(i); } - -void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { - bool ok; - void* got_tag; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - EXPECT_EQ(expect_ok, ok); - EXPECT_EQ(tag(i), got_tag); -} - -namespace { - -int global_num_connections = 0; -int global_num_calls = 0; -std::mutex global_mu; - -void IncrementConnectionCounter() { - std::unique_lock<std::mutex> lock(global_mu); - ++global_num_connections; -} - -void ResetConnectionCounter() { - std::unique_lock<std::mutex> lock(global_mu); - global_num_connections = 0; -} - -int GetConnectionCounterValue() { - std::unique_lock<std::mutex> lock(global_mu); - return global_num_connections; -} - -void IncrementCallCounter() { - std::unique_lock<std::mutex> lock(global_mu); - ++global_num_calls; -} - -void ResetCallCounter() { - std::unique_lock<std::mutex> lock(global_mu); - global_num_calls = 0; -} - -int GetCallCounterValue() { - std::unique_lock<std::mutex> lock(global_mu); - return global_num_calls; -} - -} // namespace - -class ChannelDataImpl : public ChannelData { - public: - grpc_error_handle Init(grpc_channel_element* /*elem*/, - grpc_channel_element_args* /*args*/) override { - IncrementConnectionCounter(); - return GRPC_ERROR_NONE; - } -}; - -class CallDataImpl : public CallData { - public: - void StartTransportStreamOpBatch(grpc_call_element* elem, - TransportStreamOpBatch* op) override { - // Incrementing the counter could be done from Init(), but we want - // to test that the individual methods are actually called correctly. - if (op->recv_initial_metadata() != nullptr) IncrementCallCounter(); - grpc_call_next_op(elem, op->op()); - } -}; - -class FilterEnd2endTest : public ::testing::Test { - protected: - FilterEnd2endTest() : server_host_("localhost") {} - - static void SetUpTestCase() { - // Workaround for - // https://github.com/google/google-toolbox-for-mac/issues/242 - static bool setup_done = false; - if (!setup_done) { - setup_done = true; - grpc::RegisterChannelFilter<ChannelDataImpl, CallDataImpl>( - "test-filter", GRPC_SERVER_CHANNEL, INT_MAX, nullptr); - } - } - - void SetUp() override { - int port = grpc_pick_unused_port_or_die(); - server_address_ << server_host_ << ":" << port; - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterAsyncGenericService(&generic_service_); - srv_cq_ = builder.AddCompletionQueue(); - server_ = builder.BuildAndStart(); - } - - void TearDown() override { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cli_cq_.Shutdown(); - srv_cq_->Shutdown(); - while (cli_cq_.Next(&ignored_tag, &ignored_ok)) { - } - while (srv_cq_->Next(&ignored_tag, &ignored_ok)) { - } - } - - void ResetStub() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - generic_stub_ = y_absl::make_unique<GenericStub>(channel); - ResetConnectionCounter(); - ResetCallCounter(); - } - - void server_ok(int i) { verify_ok(srv_cq_.get(), i, true); } - void client_ok(int i) { verify_ok(&cli_cq_, i, true); } - void server_fail(int i) { verify_ok(srv_cq_.get(), i, false); } - void client_fail(int i) { verify_ok(&cli_cq_, i, false); } - - void SendRpc(int num_rpcs) { - const TString kMethodName("/grpc.cpp.test.util.EchoTestService/Echo"); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter stream(&srv_ctx); - - // The string needs to be long enough to test heap-based slice. - send_request.set_message("Hello world. Hello world. Hello world."); - std::thread request_call([this]() { server_ok(4); }); - std::unique_ptr<GenericClientAsyncReaderWriter> call = - generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); - call->StartCall(tag(1)); - client_ok(1); - std::unique_ptr<ByteBuffer> send_buffer = - SerializeToByteBuffer(&send_request); - call->Write(*send_buffer, tag(2)); - // Send ByteBuffer can be destroyed after calling Write. - send_buffer.reset(); - client_ok(2); - call->WritesDone(tag(3)); - client_ok(3); - - generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(), - srv_cq_.get(), tag(4)); - - request_call.join(); - EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length())); - EXPECT_EQ(kMethodName, srv_ctx.method()); - ByteBuffer recv_buffer; - stream.Read(&recv_buffer, tag(5)); - server_ok(5); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - send_buffer = SerializeToByteBuffer(&send_response); - stream.Write(*send_buffer, tag(6)); - send_buffer.reset(); - server_ok(6); - - stream.Finish(Status::OK, tag(7)); - server_ok(7); - - recv_buffer.Clear(); - call->Read(&recv_buffer, tag(8)); - client_ok(8); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_response)); - - call->Finish(&recv_status, tag(9)); - client_ok(9); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - } - - CompletionQueue cli_cq_; - std::unique_ptr<ServerCompletionQueue> srv_cq_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<grpc::GenericStub> generic_stub_; - std::unique_ptr<Server> server_; - AsyncGenericService generic_service_; - const TString server_host_; - std::ostringstream server_address_; -}; - -TEST_F(FilterEnd2endTest, SimpleRpc) { - ResetStub(); - EXPECT_EQ(0, GetConnectionCounterValue()); - EXPECT_EQ(0, GetCallCounterValue()); - SendRpc(1); - EXPECT_EQ(1, GetConnectionCounterValue()); - EXPECT_EQ(1, GetCallCounterValue()); -} - -TEST_F(FilterEnd2endTest, SequentialRpcs) { - ResetStub(); - EXPECT_EQ(0, GetConnectionCounterValue()); - EXPECT_EQ(0, GetCallCounterValue()); - SendRpc(10); - EXPECT_EQ(1, GetConnectionCounterValue()); - EXPECT_EQ(10, GetCallCounterValue()); -} - -// One ping, one pong. -TEST_F(FilterEnd2endTest, SimpleBidiStreaming) { - ResetStub(); - EXPECT_EQ(0, GetConnectionCounterValue()); - EXPECT_EQ(0, GetCallCounterValue()); - - const TString kMethodName( - "/grpc.cpp.test.util.EchoTestService/BidiStream"); - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter srv_stream(&srv_ctx); - - cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); - send_request.set_message("Hello"); - std::thread request_call([this]() { server_ok(2); }); - std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream = - generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); - cli_stream->StartCall(tag(1)); - client_ok(1); - - generic_service_.RequestCall(&srv_ctx, &srv_stream, srv_cq_.get(), - srv_cq_.get(), tag(2)); - - request_call.join(); - EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length())); - EXPECT_EQ(kMethodName, srv_ctx.method()); - - std::unique_ptr<ByteBuffer> send_buffer = - SerializeToByteBuffer(&send_request); - cli_stream->Write(*send_buffer, tag(3)); - send_buffer.reset(); - client_ok(3); - - ByteBuffer recv_buffer; - srv_stream.Read(&recv_buffer, tag(4)); - server_ok(4); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - send_buffer = SerializeToByteBuffer(&send_response); - srv_stream.Write(*send_buffer, tag(5)); - send_buffer.reset(); - server_ok(5); - - cli_stream->Read(&recv_buffer, tag(6)); - client_ok(6); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_response)); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->WritesDone(tag(7)); - client_ok(7); - - srv_stream.Read(&recv_buffer, tag(8)); - server_fail(8); - - srv_stream.Finish(Status::OK, tag(9)); - server_ok(9); - - cli_stream->Finish(&recv_status, tag(10)); - client_ok(10); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - - EXPECT_EQ(1, GetCallCounterValue()); - EXPECT_EQ(1, GetConnectionCounterValue()); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/flaky_network_test.cc b/contrib/libs/grpc/test/cpp/end2end/flaky_network_test.cc deleted file mode 100644 index 70d5b8f0a8..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/flaky_network_test.cc +++ /dev/null @@ -1,552 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/support/port_platform.h> - -#include <algorithm> -#include <condition_variable> -#include <memory> -#include <mutex> -#include <random> -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/health_check_service_interface.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/core/lib/backoff/backoff.h" -#include "src/core/lib/gpr/env.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_credentials_provider.h" - -#ifdef GPR_LINUX -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { -namespace { - -struct TestScenario { - TestScenario(const TString& creds_type, const TString& content) - : credentials_type(creds_type), message_content(content) {} - const TString credentials_type; - const TString message_content; -}; - -class FlakyNetworkTest : public ::testing::TestWithParam<TestScenario> { - protected: - FlakyNetworkTest() - : server_host_("grpctest"), - interface_("lo:1"), - ipv4_address_("10.0.0.1"), - netmask_("/32") {} - - void InterfaceUp() { - std::ostringstream cmd; - // create interface_ with address ipv4_address_ - cmd << "ip addr add " << ipv4_address_ << netmask_ << " dev " << interface_; - std::system(cmd.str().c_str()); - } - - void InterfaceDown() { - std::ostringstream cmd; - // remove interface_ - cmd << "ip addr del " << ipv4_address_ << netmask_ << " dev " << interface_; - std::system(cmd.str().c_str()); - } - - void DNSUp() { - std::ostringstream cmd; - // Add DNS entry for server_host_ in /etc/hosts - cmd << "echo '" << ipv4_address_ << " " << server_host_ - << "' >> /etc/hosts"; - std::system(cmd.str().c_str()); - } - - void DNSDown() { - std::ostringstream cmd; - // Remove DNS entry for server_host_ from /etc/hosts - // NOTE: we can't do this in one step with sed -i because when we are - // running under docker, the file is mounted by docker so we can't change - // its inode from within the container (sed -i creates a new file and - // replaces the old file, which changes the inode) - cmd << "sed '/" << server_host_ << "/d' /etc/hosts > /etc/hosts.orig"; - std::system(cmd.str().c_str()); - - // clear the stream - cmd.str(""); - - cmd << "cat /etc/hosts.orig > /etc/hosts"; - std::system(cmd.str().c_str()); - } - - void DropPackets() { - std::ostringstream cmd; - // drop packets with src IP = ipv4_address_ - cmd << "iptables -A INPUT -s " << ipv4_address_ << " -j DROP"; - - std::system(cmd.str().c_str()); - // clear the stream - cmd.str(""); - - // drop packets with dst IP = ipv4_address_ - cmd << "iptables -A INPUT -d " << ipv4_address_ << " -j DROP"; - } - - void RestoreNetwork() { - std::ostringstream cmd; - // remove iptables rule to drop packets with src IP = ipv4_address_ - cmd << "iptables -D INPUT -s " << ipv4_address_ << " -j DROP"; - std::system(cmd.str().c_str()); - // clear the stream - cmd.str(""); - // remove iptables rule to drop packets with dest IP = ipv4_address_ - cmd << "iptables -D INPUT -d " << ipv4_address_ << " -j DROP"; - } - - void FlakeNetwork() { - std::ostringstream cmd; - // Emulate a flaky network connection over interface_. Add a delay of 100ms - // +/- 20ms, 0.1% packet loss, 1% duplicates and 0.01% corrupt packets. - cmd << "tc qdisc replace dev " << interface_ - << " root netem delay 100ms 20ms distribution normal loss 0.1% " - "duplicate " - "0.1% corrupt 0.01% "; - std::system(cmd.str().c_str()); - } - - void UnflakeNetwork() { - // Remove simulated network flake on interface_ - std::ostringstream cmd; - cmd << "tc qdisc del dev " << interface_ << " root netem"; - std::system(cmd.str().c_str()); - } - - void NetworkUp() { - InterfaceUp(); - DNSUp(); - } - - void NetworkDown() { - InterfaceDown(); - DNSDown(); - } - - void SetUp() override { - NetworkUp(); - grpc_init(); - StartServer(); - } - - void TearDown() override { - NetworkDown(); - StopServer(); - grpc_shutdown(); - } - - void StartServer() { - // TODO (pjaikumar): Ideally, we should allocate the port dynamically using - // grpc_pick_unused_port_or_die(). That doesn't work inside some docker - // containers because port_server listens on localhost which maps to - // ip6-looopback, but ipv6 support is not enabled by default in docker. - port_ = SERVER_PORT; - - server_ = y_absl::make_unique<ServerData>(port_, GetParam().credentials_type); - server_->Start(server_host_); - } - void StopServer() { server_->Shutdown(); } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> BuildStub( - const std::shared_ptr<Channel>& channel) { - return grpc::testing::EchoTestService::NewStub(channel); - } - - std::shared_ptr<Channel> BuildChannel( - const TString& lb_policy_name, - ChannelArguments args = ChannelArguments()) { - if (!lb_policy_name.empty()) { - args.SetLoadBalancingPolicyName(lb_policy_name); - } // else, default to pick first - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - std::ostringstream server_address; - server_address << server_host_ << ":" << port_; - return CreateCustomChannel(server_address.str(), channel_creds, args); - } - - bool SendRpc( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - int timeout_ms = 0, bool wait_for_ready = false) { - auto response = y_absl::make_unique<EchoResponse>(); - EchoRequest request; - auto& msg = GetParam().message_content; - request.set_message(msg); - ClientContext context; - if (timeout_ms > 0) { - context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); - // Allow an RPC to be canceled (for deadline exceeded) after it has - // reached the server. - request.mutable_param()->set_skip_cancelled_check(true); - } - // See https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md for - // details of wait-for-ready semantics - if (wait_for_ready) { - context.set_wait_for_ready(true); - } - Status status = stub->Echo(&context, request, response.get()); - auto ok = status.ok(); - if (ok) { - gpr_log(GPR_DEBUG, "RPC succeeded"); - } else { - gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str()); - } - return ok; - } - - struct ServerData { - int port_; - const TString creds_; - std::unique_ptr<Server> server_; - TestServiceImpl service_; - std::unique_ptr<std::thread> thread_; - bool server_ready_ = false; - - ServerData(int port, const TString& creds) - : port_(port), creds_(creds) {} - - void Start(const TString& server_host) { - gpr_log(GPR_INFO, "starting server on port %d", port_); - std::mutex mu; - std::unique_lock<std::mutex> lock(mu); - std::condition_variable cond; - thread_ = y_absl::make_unique<std::thread>( - std::bind(&ServerData::Serve, this, server_host, &mu, &cond)); - cond.wait(lock, [this] { return server_ready_; }); - server_ready_ = false; - gpr_log(GPR_INFO, "server startup complete"); - } - - void Serve(const TString& server_host, std::mutex* mu, - std::condition_variable* cond) { - std::ostringstream server_address; - server_address << server_host << ":" << port_; - ServerBuilder builder; - auto server_creds = - GetCredentialsProvider()->GetServerCredentials(creds_); - builder.AddListeningPort(server_address.str(), server_creds); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - std::lock_guard<std::mutex> lock(*mu); - server_ready_ = true; - cond->notify_one(); - } - - void Shutdown() { - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - thread_->join(); - } - }; - - bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(false /* try_to_connect */)) == - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - bool WaitForChannelReady(Channel* channel, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(true /* try_to_connect */)) != - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - private: - const TString server_host_; - const TString interface_; - const TString ipv4_address_; - const TString netmask_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<ServerData> server_; - const int SERVER_PORT = 32750; - int port_; -}; - -std::vector<TestScenario> CreateTestScenarios() { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types; - std::vector<TString> messages; - - credentials_types.push_back(kInsecureCredentialsType); - auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); - for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { - credentials_types.push_back(*sec); - } - - messages.push_back("🖖"); - for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024; k *= 32) { - TString big_msg; - for (size_t i = 0; i < k * 1024; ++i) { - char c = 'a' + (i % 26); - big_msg += c; - } - messages.push_back(big_msg); - } - for (auto cred = credentials_types.begin(); cred != credentials_types.end(); - ++cred) { - for (auto msg = messages.begin(); msg != messages.end(); msg++) { - scenarios.emplace_back(*cred, *msg); - } - } - - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P(FlakyNetworkTest, FlakyNetworkTest, - ::testing::ValuesIn(CreateTestScenarios())); - -// Network interface connected to server flaps -TEST_P(FlakyNetworkTest, NetworkTransition) { - const int kKeepAliveTimeMs = 1000; - const int kKeepAliveTimeoutMs = 1000; - ChannelArguments args; - args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs); - args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs); - args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); - args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0); - - auto channel = BuildChannel("pick_first", args); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - std::atomic_bool shutdown{false}; - std::thread sender = std::thread([this, &stub, &shutdown]() { - while (true) { - if (shutdown.load()) { - return; - } - SendRpc(stub); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - }); - - // bring down network - NetworkDown(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - // bring network interface back up - InterfaceUp(); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - // Restore DNS entry for server - DNSUp(); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - shutdown.store(true); - sender.join(); -} - -// Traffic to server server is blackholed temporarily with keepalives enabled -TEST_P(FlakyNetworkTest, ServerUnreachableWithKeepalive) { - const int kKeepAliveTimeMs = 1000; - const int kKeepAliveTimeoutMs = 1000; - const int kReconnectBackoffMs = 1000; - ChannelArguments args; - args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs); - args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs); - args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); - args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0); - // max time for a connection attempt - args.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, kReconnectBackoffMs); - // max time between reconnect attempts - args.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, kReconnectBackoffMs); - - gpr_log(GPR_DEBUG, "FlakyNetworkTest.ServerUnreachableWithKeepalive start"); - auto channel = BuildChannel("pick_first", args); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - std::atomic_bool shutdown{false}; - std::thread sender = std::thread([this, &stub, &shutdown]() { - while (true) { - if (shutdown.load()) { - return; - } - SendRpc(stub); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - }); - - // break network connectivity - gpr_log(GPR_DEBUG, "Adding iptables rule to drop packets"); - DropPackets(); - std::this_thread::sleep_for(std::chrono::milliseconds(10000)); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - // bring network interface back up - RestoreNetwork(); - gpr_log(GPR_DEBUG, "Removed iptables rule to drop packets"); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - shutdown.store(true); - sender.join(); - gpr_log(GPR_DEBUG, "FlakyNetworkTest.ServerUnreachableWithKeepalive end"); -} - -// -// Traffic to server server is blackholed temporarily with keepalives disabled -TEST_P(FlakyNetworkTest, ServerUnreachableNoKeepalive) { - auto channel = BuildChannel("pick_first", ChannelArguments()); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - // break network connectivity - DropPackets(); - - std::thread sender = std::thread([this, &stub]() { - // RPC with deadline should timeout - EXPECT_FALSE(SendRpc(stub, /*timeout_ms=*/500, /*wait_for_ready=*/true)); - // RPC without deadline forever until call finishes - EXPECT_TRUE(SendRpc(stub, /*timeout_ms=*/0, /*wait_for_ready=*/true)); - }); - - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - // bring network interface back up - RestoreNetwork(); - - // wait for RPC to finish - sender.join(); -} - -// Send RPCs over a flaky network connection -TEST_P(FlakyNetworkTest, FlakyNetwork) { - const int kKeepAliveTimeMs = 1000; - const int kKeepAliveTimeoutMs = 1000; - const int kMessageCount = 100; - ChannelArguments args; - args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs); - args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs); - args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); - args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0); - - auto channel = BuildChannel("pick_first", args); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - // simulate flaky network (packet loss, corruption and delays) - FlakeNetwork(); - for (int i = 0; i < kMessageCount; ++i) { - SendRpc(stub); - } - // remove network flakiness - UnflakeNetwork(); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); -} - -// Server is shutdown gracefully and restarted. Client keepalives are enabled -TEST_P(FlakyNetworkTest, ServerRestartKeepaliveEnabled) { - const int kKeepAliveTimeMs = 1000; - const int kKeepAliveTimeoutMs = 1000; - ChannelArguments args; - args.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, kKeepAliveTimeMs); - args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, kKeepAliveTimeoutMs); - args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1); - args.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0); - - auto channel = BuildChannel("pick_first", args); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - // server goes down, client should detect server going down and calls should - // fail - StopServer(); - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - EXPECT_FALSE(SendRpc(stub)); - - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - - // server restarts, calls succeed - StartServer(); - EXPECT_TRUE(WaitForChannelReady(channel.get())); - // EXPECT_TRUE(SendRpc(stub)); -} - -// Server is shutdown gracefully and restarted. Client keepalives are enabled -TEST_P(FlakyNetworkTest, ServerRestartKeepaliveDisabled) { - auto channel = BuildChannel("pick_first", ChannelArguments()); - auto stub = BuildStub(channel); - // Channel should be in READY state after we send an RPC - EXPECT_TRUE(SendRpc(stub)); - EXPECT_EQ(channel->GetState(false), GRPC_CHANNEL_READY); - - // server sends GOAWAY when it's shutdown, so client attempts to reconnect - StopServer(); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - - EXPECT_TRUE(WaitForChannelNotReady(channel.get())); - - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - - // server restarts, calls succeed - StartServer(); - EXPECT_TRUE(WaitForChannelReady(channel.get())); -} - -} // namespace -} // namespace testing -} // namespace grpc -#endif // GPR_LINUX - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/generic_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/generic_end2end_test.cc deleted file mode 100644 index dae816531e..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/generic_end2end_test.cc +++ /dev/null @@ -1,431 +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. - * - */ - -#include <memory> -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/generic/async_generic_service.h> -#include <grpcpp/generic/generic_stub.h> -#include <grpcpp/impl/codegen/proto_utils.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/slice.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { -namespace { - -void* tag(int i) { return reinterpret_cast<void*>(i); } - -void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { - bool ok; - void* got_tag; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - EXPECT_EQ(expect_ok, ok); - EXPECT_EQ(tag(i), got_tag); -} - -class GenericEnd2endTest : public ::testing::Test { - protected: - GenericEnd2endTest() : server_host_("localhost") {} - - void SetUp() override { - shut_down_ = false; - int port = grpc_pick_unused_port_or_die(); - server_address_ << server_host_ << ":" << port; - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterAsyncGenericService(&generic_service_); - // Include a second call to RegisterAsyncGenericService to make sure that - // we get an error in the log, since it is not allowed to have 2 async - // generic services - builder.RegisterAsyncGenericService(&generic_service_); - srv_cq_ = builder.AddCompletionQueue(); - server_ = builder.BuildAndStart(); - } - - void ShutDownServerAndCQs() { - if (!shut_down_) { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cli_cq_.Shutdown(); - srv_cq_->Shutdown(); - while (cli_cq_.Next(&ignored_tag, &ignored_ok)) { - } - while (srv_cq_->Next(&ignored_tag, &ignored_ok)) { - } - shut_down_ = true; - } - } - void TearDown() override { ShutDownServerAndCQs(); } - - void ResetStub() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - generic_stub_ = y_absl::make_unique<GenericStub>(channel); - } - - void server_ok(int i) { verify_ok(srv_cq_.get(), i, true); } - void client_ok(int i) { verify_ok(&cli_cq_, i, true); } - void server_fail(int i) { verify_ok(srv_cq_.get(), i, false); } - void client_fail(int i) { verify_ok(&cli_cq_, i, false); } - - void SendRpc(int num_rpcs) { - SendRpc(num_rpcs, false, gpr_inf_future(GPR_CLOCK_MONOTONIC)); - } - - void SendRpc(int num_rpcs, bool check_deadline, gpr_timespec deadline) { - const TString kMethodName("/grpc.cpp.test.util.EchoTestService/Echo"); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter stream(&srv_ctx); - - // The string needs to be long enough to test heap-based slice. - send_request.set_message("Hello world. Hello world. Hello world."); - - if (check_deadline) { - cli_ctx.set_deadline(deadline); - } - - // Rather than using the original kMethodName, make a short-lived - // copy to also confirm that we don't refer to this object beyond - // the initial call preparation - const TString* method_name = new TString(kMethodName); - - std::unique_ptr<GenericClientAsyncReaderWriter> call = - generic_stub_->PrepareCall(&cli_ctx, *method_name, &cli_cq_); - - delete method_name; // Make sure that this is not needed after invocation - - std::thread request_call([this]() { server_ok(4); }); - call->StartCall(tag(1)); - client_ok(1); - std::unique_ptr<ByteBuffer> send_buffer = - SerializeToByteBuffer(&send_request); - call->Write(*send_buffer, tag(2)); - // Send ByteBuffer can be destroyed after calling Write. - send_buffer.reset(); - client_ok(2); - call->WritesDone(tag(3)); - client_ok(3); - - generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(), - srv_cq_.get(), tag(4)); - - request_call.join(); - EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length())); - EXPECT_EQ(kMethodName, srv_ctx.method()); - - if (check_deadline) { - EXPECT_TRUE(gpr_time_similar(deadline, srv_ctx.raw_deadline(), - gpr_time_from_millis(1000, GPR_TIMESPAN))); - } - - ByteBuffer recv_buffer; - stream.Read(&recv_buffer, tag(5)); - server_ok(5); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - send_buffer = SerializeToByteBuffer(&send_response); - stream.Write(*send_buffer, tag(6)); - send_buffer.reset(); - server_ok(6); - - stream.Finish(Status::OK, tag(7)); - server_ok(7); - - recv_buffer.Clear(); - call->Read(&recv_buffer, tag(8)); - client_ok(8); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_response)); - - call->Finish(&recv_status, tag(9)); - client_ok(9); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - } - - // Return errors to up to one call that comes in on the supplied completion - // queue, until the CQ is being shut down (and therefore we can no longer - // enqueue further events). - void DriveCompletionQueue() { - enum class Event : uintptr_t { - kCallReceived, - kResponseSent, - }; - // Request the call, but only if the main thread hasn't beaten us to - // shutting down the CQ. - grpc::GenericServerContext server_context; - grpc::GenericServerAsyncReaderWriter reader_writer(&server_context); - - { - std::lock_guard<std::mutex> lock(shutting_down_mu_); - if (!shutting_down_) { - generic_service_.RequestCall( - &server_context, &reader_writer, srv_cq_.get(), srv_cq_.get(), - reinterpret_cast<void*>(Event::kCallReceived)); - } - } - // Process events. - { - Event event; - bool ok; - while (srv_cq_->Next(reinterpret_cast<void**>(&event), &ok)) { - std::lock_guard<std::mutex> lock(shutting_down_mu_); - if (shutting_down_) { - // The main thread has started shutting down. Simply continue to drain - // events. - continue; - } - - switch (event) { - case Event::kCallReceived: - reader_writer.Finish( - ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "go away"), - reinterpret_cast<void*>(Event::kResponseSent)); - break; - - case Event::kResponseSent: - // We are done. - break; - } - } - } - } - - CompletionQueue cli_cq_; - std::unique_ptr<ServerCompletionQueue> srv_cq_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<grpc::GenericStub> generic_stub_; - std::unique_ptr<Server> server_; - AsyncGenericService generic_service_; - const TString server_host_; - std::ostringstream server_address_; - bool shutting_down_; - bool shut_down_; - std::mutex shutting_down_mu_; -}; - -TEST_F(GenericEnd2endTest, SimpleRpc) { - ResetStub(); - SendRpc(1); -} - -TEST_F(GenericEnd2endTest, SequentialRpcs) { - ResetStub(); - SendRpc(10); -} - -TEST_F(GenericEnd2endTest, SequentialUnaryRpcs) { - ResetStub(); - const int num_rpcs = 10; - const TString kMethodName("/grpc.cpp.test.util.EchoTestService/Echo"); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter stream(&srv_ctx); - - // The string needs to be long enough to test heap-based slice. - send_request.set_message("Hello world. Hello world. Hello world."); - - std::unique_ptr<ByteBuffer> cli_send_buffer = - SerializeToByteBuffer(&send_request); - std::thread request_call([this]() { server_ok(4); }); - std::unique_ptr<GenericClientAsyncResponseReader> call = - generic_stub_->PrepareUnaryCall(&cli_ctx, kMethodName, *cli_send_buffer, - &cli_cq_); - call->StartCall(); - ByteBuffer cli_recv_buffer; - call->Finish(&cli_recv_buffer, &recv_status, tag(1)); - std::thread client_check([this] { client_ok(1); }); - - generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(), - srv_cq_.get(), tag(4)); - request_call.join(); - EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length())); - EXPECT_EQ(kMethodName, srv_ctx.method()); - - ByteBuffer srv_recv_buffer; - stream.Read(&srv_recv_buffer, tag(5)); - server_ok(5); - EXPECT_TRUE(ParseFromByteBuffer(&srv_recv_buffer, &recv_request)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - std::unique_ptr<ByteBuffer> srv_send_buffer = - SerializeToByteBuffer(&send_response); - stream.Write(*srv_send_buffer, tag(6)); - server_ok(6); - - stream.Finish(Status::OK, tag(7)); - server_ok(7); - - client_check.join(); - EXPECT_TRUE(ParseFromByteBuffer(&cli_recv_buffer, &recv_response)); - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } -} - -// One ping, one pong. -TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { - ResetStub(); - - const TString kMethodName( - "/grpc.cpp.test.util.EchoTestService/BidiStream"); - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - ClientContext cli_ctx; - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter srv_stream(&srv_ctx); - - cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); - send_request.set_message("Hello"); - std::thread request_call([this]() { server_ok(2); }); - std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream = - generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); - cli_stream->StartCall(tag(1)); - client_ok(1); - - generic_service_.RequestCall(&srv_ctx, &srv_stream, srv_cq_.get(), - srv_cq_.get(), tag(2)); - request_call.join(); - - EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length())); - EXPECT_EQ(kMethodName, srv_ctx.method()); - - std::unique_ptr<ByteBuffer> send_buffer = - SerializeToByteBuffer(&send_request); - cli_stream->Write(*send_buffer, tag(3)); - send_buffer.reset(); - client_ok(3); - - ByteBuffer recv_buffer; - srv_stream.Read(&recv_buffer, tag(4)); - server_ok(4); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - send_buffer = SerializeToByteBuffer(&send_response); - srv_stream.Write(*send_buffer, tag(5)); - send_buffer.reset(); - server_ok(5); - - cli_stream->Read(&recv_buffer, tag(6)); - client_ok(6); - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_response)); - EXPECT_EQ(send_response.message(), recv_response.message()); - - cli_stream->WritesDone(tag(7)); - client_ok(7); - - srv_stream.Read(&recv_buffer, tag(8)); - server_fail(8); - - srv_stream.Finish(Status::OK, tag(9)); - server_ok(9); - - cli_stream->Finish(&recv_status, tag(10)); - client_ok(10); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); -} - -TEST_F(GenericEnd2endTest, Deadline) { - ResetStub(); - SendRpc(1, true, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(10, GPR_TIMESPAN))); -} - -TEST_F(GenericEnd2endTest, ShortDeadline) { - ResetStub(); - - ClientContext cli_ctx; - EchoRequest request; - EchoResponse response; - - shutting_down_ = false; - std::thread driver([this] { DriveCompletionQueue(); }); - - request.set_message(""); - cli_ctx.set_deadline(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_micros(500, GPR_TIMESPAN))); - Status s = stub_->Echo(&cli_ctx, request, &response); - EXPECT_FALSE(s.ok()); - { - std::lock_guard<std::mutex> lock(shutting_down_mu_); - shutting_down_ = true; - } - ShutDownServerAndCQs(); - driver.join(); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/grpclb_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/grpclb_end2end_test.cc deleted file mode 100644 index 1f71145b66..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/grpclb_end2end_test.cc +++ /dev/null @@ -1,2038 +0,0 @@ -// -// Copyright 2017 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include <deque> -#include <memory> -#include <mutex> -#include <set> -#include <sstream> -#include <util/generic/string.h> -#include <thread> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" -#include "y_absl/strings/str_cat.h" -#include "y_absl/strings/str_format.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/impl/codegen/sync.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" -#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h" -#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/ext/service_config/service_config.h" -#include "src/core/lib/address_utils/parse_address.h" -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/cpp/server/secure_server_credentials.h" -#include "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/resolve_localhost_ip46.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/counted_service.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_config.h" - -// TODO(dgq): Other scenarios in need of testing: -// - Send a serverlist with faulty ip:port addresses (port > 2^16, etc). -// - Test reception of invalid serverlist -// - Test against a non-LB server. -// - Random LB server closing the stream unexpectedly. -// -// Findings from end to end testing to be covered here: -// - Handling of LB servers restart, including reconnection after backing-off -// retries. -// - Destruction of load balanced channel (and therefore of grpclb instance) -// while: -// 1) the internal LB call is still active. This should work by virtue -// of the weak reference the LB call holds. The call should be terminated as -// part of the grpclb shutdown process. -// 2) the retry timer is active. Again, the weak reference it holds should -// prevent a premature call to \a glb_destroy. - -using std::chrono::system_clock; - -using grpc::lb::v1::LoadBalancer; -using grpc::lb::v1::LoadBalanceRequest; -using grpc::lb::v1::LoadBalanceResponse; - -namespace grpc { -namespace testing { -namespace { - -constexpr char kDefaultServiceConfig[] = - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"grpclb\":{} }\n" - " ]\n" - "}"; - -using BackendService = CountedService<TestServiceImpl>; -using BalancerService = CountedService<LoadBalancer::Service>; - -const char g_kCallCredsMdKey[] = "Balancer should not ..."; -const char g_kCallCredsMdValue[] = "... receive me"; - -class BackendServiceImpl : public BackendService { - public: - BackendServiceImpl() {} - - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - // Backend should receive the call credentials metadata. - auto call_credentials_entry = - context->client_metadata().find(g_kCallCredsMdKey); - EXPECT_NE(call_credentials_entry, context->client_metadata().end()); - if (call_credentials_entry != context->client_metadata().end()) { - EXPECT_EQ(call_credentials_entry->second, g_kCallCredsMdValue); - } - IncreaseRequestCount(); - const auto status = TestServiceImpl::Echo(context, request, response); - IncreaseResponseCount(); - AddClient(context->peer().c_str()); - return status; - } - - void Start() {} - - void Shutdown() {} - - std::set<TString> clients() { - grpc::internal::MutexLock lock(&clients_mu_); - return clients_; - } - - private: - void AddClient(const TString& client) { - grpc::internal::MutexLock lock(&clients_mu_); - clients_.insert(client); - } - - grpc::internal::Mutex clients_mu_; - std::set<TString> clients_ Y_ABSL_GUARDED_BY(&clients_mu_); -}; - -TString Ip4ToPackedString(const char* ip_str) { - struct in_addr ip4; - GPR_ASSERT(inet_pton(AF_INET, ip_str, &ip4) == 1); - return TString(reinterpret_cast<const char*>(&ip4), sizeof(ip4)); -} - -TString Ip6ToPackedString(const char* ip_str) { - struct in6_addr ip6; - GPR_ASSERT(inet_pton(AF_INET6, ip_str, &ip6) == 1); - return TString(reinterpret_cast<const char*>(&ip6), sizeof(ip6)); -} - -struct ClientStats { - size_t num_calls_started = 0; - size_t num_calls_finished = 0; - size_t num_calls_finished_with_client_failed_to_send = 0; - size_t num_calls_finished_known_received = 0; - std::map<TString, size_t> drop_token_counts; - - ClientStats& operator+=(const ClientStats& other) { - num_calls_started += other.num_calls_started; - num_calls_finished += other.num_calls_finished; - num_calls_finished_with_client_failed_to_send += - other.num_calls_finished_with_client_failed_to_send; - num_calls_finished_known_received += - other.num_calls_finished_known_received; - for (const auto& p : other.drop_token_counts) { - drop_token_counts[p.first] += p.second; - } - return *this; - } - - void Reset() { - num_calls_started = 0; - num_calls_finished = 0; - num_calls_finished_with_client_failed_to_send = 0; - num_calls_finished_known_received = 0; - drop_token_counts.clear(); - } -}; - -class BalancerServiceImpl : public BalancerService { - public: - using Stream = ServerReaderWriter<LoadBalanceResponse, LoadBalanceRequest>; - using ResponseDelayPair = std::pair<LoadBalanceResponse, int>; - - explicit BalancerServiceImpl(int client_load_reporting_interval_seconds) - : client_load_reporting_interval_seconds_( - client_load_reporting_interval_seconds) {} - - Status BalanceLoad(ServerContext* context, Stream* stream) override { - gpr_log(GPR_INFO, "LB[%p]: BalanceLoad", this); - { - grpc::internal::MutexLock lock(&mu_); - if (serverlist_done_) goto done; - } - { - // Balancer shouldn't receive the call credentials metadata. - EXPECT_EQ(context->client_metadata().find(g_kCallCredsMdKey), - context->client_metadata().end()); - LoadBalanceRequest request; - std::vector<ResponseDelayPair> responses_and_delays; - - if (!stream->Read(&request)) { - goto done; - } else { - if (request.has_initial_request()) { - grpc::internal::MutexLock lock(&mu_); - service_names_.push_back(request.initial_request().name()); - } - } - IncreaseRequestCount(); - gpr_log(GPR_INFO, "LB[%p]: received initial message '%s'", this, - request.DebugString().c_str()); - - // TODO(juanlishen): Initial response should always be the first response. - if (client_load_reporting_interval_seconds_ > 0) { - LoadBalanceResponse initial_response; - initial_response.mutable_initial_response() - ->mutable_client_stats_report_interval() - ->set_seconds(client_load_reporting_interval_seconds_); - stream->Write(initial_response); - } - - { - grpc::internal::MutexLock lock(&mu_); - responses_and_delays = responses_and_delays_; - } - for (const auto& response_and_delay : responses_and_delays) { - SendResponse(stream, response_and_delay.first, - response_and_delay.second); - } - { - grpc::internal::MutexLock lock(&mu_); - while (!serverlist_done_) { - serverlist_cond_.Wait(&mu_); - } - } - - if (client_load_reporting_interval_seconds_ > 0) { - request.Clear(); - while (stream->Read(&request)) { - gpr_log(GPR_INFO, "LB[%p]: received client load report message '%s'", - this, request.DebugString().c_str()); - GPR_ASSERT(request.has_client_stats()); - ClientStats load_report; - load_report.num_calls_started = - request.client_stats().num_calls_started(); - load_report.num_calls_finished = - request.client_stats().num_calls_finished(); - load_report.num_calls_finished_with_client_failed_to_send = - request.client_stats() - .num_calls_finished_with_client_failed_to_send(); - load_report.num_calls_finished_known_received = - request.client_stats().num_calls_finished_known_received(); - for (const auto& drop_token_count : - request.client_stats().calls_finished_with_drop()) { - load_report - .drop_token_counts[drop_token_count.load_balance_token()] = - drop_token_count.num_calls(); - } - // We need to acquire the lock here in order to prevent the notify_one - // below from firing before its corresponding wait is executed. - grpc::internal::MutexLock lock(&mu_); - load_report_queue_.emplace_back(std::move(load_report)); - load_report_cond_.Signal(); - } - } - } - done: - gpr_log(GPR_INFO, "LB[%p]: done", this); - return Status::OK; - } - - void add_response(const LoadBalanceResponse& response, int send_after_ms) { - grpc::internal::MutexLock lock(&mu_); - responses_and_delays_.push_back(std::make_pair(response, send_after_ms)); - } - - void Start() { - grpc::internal::MutexLock lock(&mu_); - serverlist_done_ = false; - responses_and_delays_.clear(); - load_report_queue_.clear(); - } - - void Shutdown() { - NotifyDoneWithServerlists(); - gpr_log(GPR_INFO, "LB[%p]: shut down", this); - } - - ClientStats WaitForLoadReport() { - grpc::internal::MutexLock lock(&mu_); - if (load_report_queue_.empty()) { - while (load_report_queue_.empty()) { - load_report_cond_.Wait(&mu_); - } - } - ClientStats load_report = std::move(load_report_queue_.front()); - load_report_queue_.pop_front(); - return load_report; - } - - void NotifyDoneWithServerlists() { - grpc::internal::MutexLock lock(&mu_); - if (!serverlist_done_) { - serverlist_done_ = true; - serverlist_cond_.SignalAll(); - } - } - - std::vector<TString> service_names() { - grpc::internal::MutexLock lock(&mu_); - return service_names_; - } - - private: - void SendResponse(Stream* stream, const LoadBalanceResponse& response, - int delay_ms) { - gpr_log(GPR_INFO, "LB[%p]: sleeping for %d ms...", this, delay_ms); - if (delay_ms > 0) { - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(delay_ms)); - } - gpr_log(GPR_INFO, "LB[%p]: Woke up! Sending response '%s'", this, - response.DebugString().c_str()); - IncreaseResponseCount(); - stream->Write(response); - } - - const int client_load_reporting_interval_seconds_; - std::vector<ResponseDelayPair> responses_and_delays_; - std::vector<TString> service_names_; - - grpc::internal::Mutex mu_; - grpc::internal::CondVar serverlist_cond_; - bool serverlist_done_ Y_ABSL_GUARDED_BY(mu_) = false; - grpc::internal::CondVar load_report_cond_; - std::deque<ClientStats> load_report_queue_ Y_ABSL_GUARDED_BY(mu_); -}; - -class GrpclbEnd2endTest : public ::testing::Test { - protected: - GrpclbEnd2endTest(size_t num_backends, size_t num_balancers, - int client_load_reporting_interval_seconds) - : server_host_("localhost"), - num_backends_(num_backends), - num_balancers_(num_balancers), - client_load_reporting_interval_seconds_( - client_load_reporting_interval_seconds) {} - - static void SetUpTestCase() { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - grpc_init(); - } - - static void TearDownTestCase() { grpc_shutdown(); } - - void SetUp() override { - bool localhost_resolves_to_ipv4 = false; - bool localhost_resolves_to_ipv6 = false; - grpc_core::LocalhostResolves(&localhost_resolves_to_ipv4, - &localhost_resolves_to_ipv6); - ipv6_only_ = !localhost_resolves_to_ipv4 && localhost_resolves_to_ipv6; - response_generator_ = - grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); - // Start the backends. - for (size_t i = 0; i < num_backends_; ++i) { - backends_.emplace_back(new ServerThread<BackendServiceImpl>("backend")); - backends_.back()->Start(server_host_); - } - // Start the load balancers. - for (size_t i = 0; i < num_balancers_; ++i) { - balancers_.emplace_back(new ServerThread<BalancerServiceImpl>( - "balancer", client_load_reporting_interval_seconds_)); - balancers_.back()->Start(server_host_); - } - ResetStub(); - } - - void TearDown() override { - ShutdownAllBackends(); - for (auto& balancer : balancers_) balancer->Shutdown(); - } - - void StartAllBackends() { - for (auto& backend : backends_) backend->Start(server_host_); - } - - void StartBackend(size_t index) { backends_[index]->Start(server_host_); } - - void ShutdownAllBackends() { - for (auto& backend : backends_) backend->Shutdown(); - } - - void ShutdownBackend(size_t index) { backends_[index]->Shutdown(); } - - void ResetStub(int fallback_timeout = 0, - const TString& expected_targets = "", - int subchannel_cache_delay_ms = 0) { - ChannelArguments args; - if (fallback_timeout > 0) args.SetGrpclbFallbackTimeout(fallback_timeout); - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_.get()); - if (!expected_targets.empty()) { - args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets); - } - if (subchannel_cache_delay_ms > 0) { - args.SetInt(GRPC_ARG_GRPCLB_SUBCHANNEL_CACHE_INTERVAL_MS, - subchannel_cache_delay_ms); - } - std::ostringstream uri; - uri << "fake:///" << kApplicationTargetName_; - // TODO(dgq): templatize tests to run everything using both secure and - // insecure channel credentials. - grpc_channel_credentials* channel_creds = - grpc_fake_transport_security_credentials_create(); - grpc_call_credentials* call_creds = grpc_md_only_test_credentials_create( - g_kCallCredsMdKey, g_kCallCredsMdValue, false); - std::shared_ptr<ChannelCredentials> creds( - new SecureChannelCredentials(grpc_composite_channel_credentials_create( - channel_creds, call_creds, nullptr))); - call_creds->Unref(); - channel_creds->Unref(); - channel_ = ::grpc::CreateCustomChannel(uri.str(), creds, args); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - void ResetBackendCounters() { - for (auto& backend : backends_) backend->service_.ResetCounters(); - } - - ClientStats WaitForLoadReports() { - ClientStats client_stats; - for (auto& balancer : balancers_) { - client_stats += balancer->service_.WaitForLoadReport(); - } - return client_stats; - } - - bool SeenAllBackends(size_t start_index = 0, size_t stop_index = 0) { - if (stop_index == 0) stop_index = backends_.size(); - for (size_t i = start_index; i < stop_index; ++i) { - if (backends_[i]->service_.request_count() == 0) return false; - } - return true; - } - - void SendRpcAndCount(int* num_total, int* num_ok, int* num_failure, - int* num_drops) { - const Status status = SendRpc(); - if (status.ok()) { - ++*num_ok; - } else { - if (status.error_message() == "drop directed by grpclb balancer") { - ++*num_drops; - } else { - ++*num_failure; - } - } - ++*num_total; - } - - std::tuple<int, int, int> WaitForAllBackends(int num_requests_multiple_of = 1, - size_t start_index = 0, - size_t stop_index = 0) { - int num_ok = 0; - int num_failure = 0; - int num_drops = 0; - int num_total = 0; - while (!SeenAllBackends(start_index, stop_index)) { - SendRpcAndCount(&num_total, &num_ok, &num_failure, &num_drops); - } - while (num_total % num_requests_multiple_of != 0) { - SendRpcAndCount(&num_total, &num_ok, &num_failure, &num_drops); - } - ResetBackendCounters(); - gpr_log(GPR_INFO, - "Performed %d warm up requests (a multiple of %d) against the " - "backends. %d succeeded, %d failed, %d dropped.", - num_total, num_requests_multiple_of, num_ok, num_failure, - num_drops); - return std::make_tuple(num_ok, num_failure, num_drops); - } - - void WaitForBackend(size_t backend_idx) { - do { - (void)SendRpc(); - } while (backends_[backend_idx]->service_.request_count() == 0); - ResetBackendCounters(); - } - - struct AddressData { - int port; - TString balancer_name; - }; - - grpc_core::ServerAddressList CreateLbAddressesFromAddressDataList( - const std::vector<AddressData>& address_data) { - grpc_core::ServerAddressList addresses; - for (const auto& addr : address_data) { - y_absl::StatusOr<grpc_core::URI> lb_uri = - grpc_core::URI::Parse(y_absl::StrCat( - ipv6_only_ ? "ipv6:[::1]:" : "ipv4:127.0.0.1:", addr.port)); - GPR_ASSERT(lb_uri.ok()); - grpc_resolved_address address; - GPR_ASSERT(grpc_parse_uri(*lb_uri, &address)); - grpc_arg arg = grpc_channel_arg_string_create( - const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY), - const_cast<char*>(addr.balancer_name.c_str())); - grpc_channel_args* args = - grpc_channel_args_copy_and_add(nullptr, &arg, 1); - addresses.emplace_back(address.addr, address.len, args); - } - return addresses; - } - - grpc_core::Resolver::Result MakeResolverResult( - const std::vector<AddressData>& balancer_address_data, - const std::vector<AddressData>& backend_address_data = {}, - const char* service_config_json = kDefaultServiceConfig) { - grpc_core::Resolver::Result result; - result.addresses = - CreateLbAddressesFromAddressDataList(backend_address_data); - grpc_error_handle error = GRPC_ERROR_NONE; - result.service_config = - grpc_core::ServiceConfig::Create(nullptr, service_config_json, &error); - GPR_ASSERT(error == GRPC_ERROR_NONE); - grpc_core::ServerAddressList balancer_addresses = - CreateLbAddressesFromAddressDataList(balancer_address_data); - grpc_arg arg = CreateGrpclbBalancerAddressesArg(&balancer_addresses); - result.args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); - return result; - } - - void SetNextResolutionAllBalancers( - const char* service_config_json = kDefaultServiceConfig) { - std::vector<AddressData> addresses; - for (size_t i = 0; i < balancers_.size(); ++i) { - addresses.emplace_back(AddressData{balancers_[i]->port_, ""}); - } - SetNextResolution(addresses, {}, service_config_json); - } - - void SetNextResolution( - const std::vector<AddressData>& balancer_address_data, - const std::vector<AddressData>& backend_address_data = {}, - const char* service_config_json = kDefaultServiceConfig) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = MakeResolverResult( - balancer_address_data, backend_address_data, service_config_json); - response_generator_->SetResponse(std::move(result)); - } - - void SetNextReresolutionResponse( - const std::vector<AddressData>& balancer_address_data, - const std::vector<AddressData>& backend_address_data = {}, - const char* service_config_json = kDefaultServiceConfig) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = MakeResolverResult( - balancer_address_data, backend_address_data, service_config_json); - response_generator_->SetReresolutionResponse(std::move(result)); - } - - std::vector<int> GetBackendPorts(size_t start_index = 0, - size_t stop_index = 0) const { - if (stop_index == 0) stop_index = backends_.size(); - std::vector<int> backend_ports; - for (size_t i = start_index; i < stop_index; ++i) { - backend_ports.push_back(backends_[i]->port_); - } - return backend_ports; - } - - void ScheduleResponseForBalancer(size_t i, - const LoadBalanceResponse& response, - int delay_ms) { - balancers_[i]->service_.add_response(response, delay_ms); - } - - LoadBalanceResponse BuildResponseForBackends( - const std::vector<int>& backend_ports, - const std::map<TString, size_t>& drop_token_counts) { - LoadBalanceResponse response; - for (const auto& drop_token_count : drop_token_counts) { - for (size_t i = 0; i < drop_token_count.second; ++i) { - auto* server = response.mutable_server_list()->add_servers(); - server->set_drop(true); - server->set_load_balance_token(drop_token_count.first); - } - } - for (const int& backend_port : backend_ports) { - auto* server = response.mutable_server_list()->add_servers(); - server->set_ip_address(ipv6_only_ ? Ip6ToPackedString("::1") - : Ip4ToPackedString("127.0.0.1")); - server->set_port(backend_port); - static int token_count = 0; - server->set_load_balance_token( - y_absl::StrFormat("token%03d", ++token_count)); - } - return response; - } - - Status SendRpc(EchoResponse* response = nullptr, int timeout_ms = 1000, - bool wait_for_ready = false, - const Status& expected_status = Status::OK) { - const bool local_response = (response == nullptr); - if (local_response) response = new EchoResponse; - EchoRequest request; - request.set_message(kRequestMessage_); - if (!expected_status.ok()) { - auto* error = request.mutable_param()->mutable_expected_error(); - error->set_code(expected_status.error_code()); - error->set_error_message(expected_status.error_message()); - } - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); - if (wait_for_ready) context.set_wait_for_ready(true); - Status status = stub_->Echo(&context, request, response); - if (local_response) delete response; - return status; - } - - void CheckRpcSendOk(const size_t times = 1, const int timeout_ms = 1000, - bool wait_for_ready = false) { - for (size_t i = 0; i < times; ++i) { - EchoResponse response; - const Status status = SendRpc(&response, timeout_ms, wait_for_ready); - EXPECT_TRUE(status.ok()) << "code=" << status.error_code() - << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); - } - } - - void CheckRpcSendFailure() { - const Status status = SendRpc(); - EXPECT_FALSE(status.ok()); - } - - template <typename T> - struct ServerThread { - template <typename... Args> - explicit ServerThread(const TString& type, Args&&... args) - : port_(grpc_pick_unused_port_or_die()), - type_(type), - service_(std::forward<Args>(args)...) {} - - void Start(const TString& server_host) { - gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_); - GPR_ASSERT(!running_); - running_ = true; - service_.Start(); - grpc::internal::Mutex mu; - // We need to acquire the lock here in order to prevent the notify_one - // by ServerThread::Serve from firing before the wait below is hit. - grpc::internal::MutexLock lock(&mu); - grpc::internal::CondVar cond; - thread_ = y_absl::make_unique<std::thread>( - std::bind(&ServerThread::Serve, this, server_host, &mu, &cond)); - cond.Wait(&mu); - gpr_log(GPR_INFO, "%s server startup complete", type_.c_str()); - } - - void Serve(const TString& server_host, grpc::internal::Mutex* mu, - grpc::internal::CondVar* cond) { - // We need to acquire the lock here in order to prevent the notify_one - // below from firing before its corresponding wait is executed. - grpc::internal::MutexLock lock(mu); - std::ostringstream server_address; - server_address << server_host << ":" << port_; - ServerBuilder builder; - std::shared_ptr<ServerCredentials> creds(new SecureServerCredentials( - grpc_fake_transport_security_server_credentials_create())); - builder.AddListeningPort(server_address.str(), creds); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - cond->Signal(); - } - - void Shutdown() { - if (!running_) return; - gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str()); - service_.Shutdown(); - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - thread_->join(); - gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str()); - running_ = false; - } - - const int port_; - TString type_; - T service_; - std::unique_ptr<Server> server_; - std::unique_ptr<std::thread> thread_; - bool running_ = false; - }; - - const TString server_host_; - const size_t num_backends_; - const size_t num_balancers_; - const int client_load_reporting_interval_seconds_; - bool ipv6_only_ = false; - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::vector<std::unique_ptr<ServerThread<BackendServiceImpl>>> backends_; - std::vector<std::unique_ptr<ServerThread<BalancerServiceImpl>>> balancers_; - grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> - response_generator_; - const TString kRequestMessage_ = "Live long and prosper."; - const TString kApplicationTargetName_ = "application_target_name"; -}; - -class SingleBalancerTest : public GrpclbEnd2endTest { - public: - SingleBalancerTest() : GrpclbEnd2endTest(4, 1, 0) {} -}; - -TEST_F(SingleBalancerTest, Vanilla) { - SetNextResolutionAllBalancers(); - const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // We need to wait for all backends to come online. - WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); - } - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, SubchannelCaching) { - ResetStub(/*fallback_timeout=*/0, /*expected_targets=*/"", - /*subchannel_cache_delay_ms=*/1500); - SetNextResolutionAllBalancers(); - // Initially send all backends. - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Then remove backends 0 and 1. - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(2), {}), 1000); - // Now re-add backend 1. - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(1), {}), 1000); - // Wait for all backends to come online. - WaitForAllBackends(); - // Send RPCs for long enough to get all responses. - gpr_timespec deadline = grpc_timeout_milliseconds_to_deadline(3000); - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) < 0); - // Backend 0 should have received less traffic than the others. - // Backend 1 would have received less traffic than 2 and 3. - gpr_log(GPR_INFO, "BACKEND 0: %" PRIuPTR " requests", - backends_[0]->service_.request_count()); - EXPECT_GT(backends_[0]->service_.request_count(), 0); - for (size_t i = 1; i < backends_.size(); ++i) { - gpr_log(GPR_INFO, "BACKEND %" PRIuPTR ": %" PRIuPTR " requests", i, - backends_[i]->service_.request_count()); - EXPECT_GT(backends_[i]->service_.request_count(), - backends_[0]->service_.request_count()) - << "backend " << i; - if (i >= 2) { - EXPECT_GT(backends_[i]->service_.request_count(), - backends_[1]->service_.request_count()) - << "backend " << i; - } - } - // Backend 1 should never have lost its connection from the client. - EXPECT_EQ(1UL, backends_[1]->service_.clients().size()); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // And sent 3 responses. - EXPECT_EQ(3U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, ReturnServerStatus) { - SetNextResolutionAllBalancers(); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // We need to wait for all backends to come online. - WaitForAllBackends(); - // Send a request that the backend will fail, and make sure we get - // back the right status. - Status expected(StatusCode::INVALID_ARGUMENT, "He's dead, Jim!"); - Status actual = SendRpc(/*response=*/nullptr, /*timeout_ms=*/1000, - /*wait_for_ready=*/false, expected); - EXPECT_EQ(actual.error_code(), expected.error_code()); - EXPECT_EQ(actual.error_message(), expected.error_message()); -} - -TEST_F(SingleBalancerTest, SelectGrpclbWithMigrationServiceConfig) { - SetNextResolutionAllBalancers( - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"grpclb\":{} }\n" - " ]\n" - "}"); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - CheckRpcSendOk(1, 1000 /* timeout_ms */, true /* wait_for_ready */); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, - SelectGrpclbWithMigrationServiceConfigAndNoAddresses) { - const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); - ResetStub(kFallbackTimeoutMs); - SetNextResolution({}, {}, - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"does_not_exist\":{} },\n" - " { \"grpclb\":{} }\n" - " ]\n" - "}"); - // Try to connect. - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(true)); - // Should go into state TRANSIENT_FAILURE when we enter fallback mode. - const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(1); - grpc_connectivity_state state; - while ((state = channel_->GetState(false)) != - GRPC_CHANNEL_TRANSIENT_FAILURE) { - ASSERT_TRUE(channel_->WaitForStateChange(state, deadline)); - } - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, UsePickFirstChildPolicy) { - SetNextResolutionAllBalancers( - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"grpclb\":{\n" - " \"childPolicy\":[\n" - " { \"pick_first\":{} }\n" - " ]\n" - " } }\n" - " ]\n" - "}"); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - const size_t kNumRpcs = num_backends_ * 2; - CheckRpcSendOk(kNumRpcs, 1000 /* timeout_ms */, true /* wait_for_ready */); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // Check that all requests went to the first backend. This verifies - // that we used pick_first instead of round_robin as the child policy. - EXPECT_EQ(backends_[0]->service_.request_count(), kNumRpcs); - for (size_t i = 1; i < backends_.size(); ++i) { - EXPECT_EQ(backends_[i]->service_.request_count(), 0UL); - } - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, SwapChildPolicy) { - SetNextResolutionAllBalancers( - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"grpclb\":{\n" - " \"childPolicy\":[\n" - " { \"pick_first\":{} }\n" - " ]\n" - " } }\n" - " ]\n" - "}"); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - const size_t kNumRpcs = num_backends_ * 2; - CheckRpcSendOk(kNumRpcs, 1000 /* timeout_ms */, true /* wait_for_ready */); - // Check that all requests went to the first backend. This verifies - // that we used pick_first instead of round_robin as the child policy. - EXPECT_EQ(backends_[0]->service_.request_count(), kNumRpcs); - for (size_t i = 1; i < backends_.size(); ++i) { - EXPECT_EQ(backends_[i]->service_.request_count(), 0UL); - } - // Send new resolution that removes child policy from service config. - SetNextResolutionAllBalancers(); - WaitForAllBackends(); - CheckRpcSendOk(kNumRpcs, 1000 /* timeout_ms */, true /* wait_for_ready */); - // Check that every backend saw the same number of requests. This verifies - // that we used round_robin. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(backends_[i]->service_.request_count(), 2UL); - } - // Done. - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, SameBackendListedMultipleTimes) { - SetNextResolutionAllBalancers(); - // Same backend listed twice. - std::vector<int> ports; - ports.push_back(backends_[0]->port_); - ports.push_back(backends_[0]->port_); - const size_t kNumRpcsPerAddress = 10; - ScheduleResponseForBalancer(0, BuildResponseForBackends(ports, {}), 0); - // We need to wait for the backend to come online. - WaitForBackend(0); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * ports.size()); - // Backend should have gotten 20 requests. - EXPECT_EQ(kNumRpcsPerAddress * 2, backends_[0]->service_.request_count()); - // And they should have come from a single client port, because of - // subchannel sharing. - EXPECT_EQ(1UL, backends_[0]->service_.clients().size()); - balancers_[0]->service_.NotifyDoneWithServerlists(); -} - -TEST_F(SingleBalancerTest, SecureNaming) { - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({AddressData{balancers_[0]->port_, "lb"}}); - const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // We need to wait for all backends to come online. - WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); - } - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // Check LB policy name for the channel. - EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName()); -} - -TEST_F(SingleBalancerTest, SecureNamingDeathTest) { - GRPC_GTEST_FLAG_SET_DEATH_TEST_STYLE("threadsafe"); - // Make sure that we blow up (via abort() from the security connector) when - // the name from the balancer doesn't match expectations. - ASSERT_DEATH_IF_SUPPORTED( - { - ResetStub(0, kApplicationTargetName_ + ";lb"); - SetNextResolution({AddressData{balancers_[0]->port_, "woops"}}); - channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); - }, - ""); -} - -TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { - SetNextResolutionAllBalancers(); - const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); - const int kCallDeadlineMs = kServerlistDelayMs * 2; - // First response is an empty serverlist, sent right away. - ScheduleResponseForBalancer(0, LoadBalanceResponse(), 0); - // Send non-empty serverlist only after kServerlistDelayMs - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), kServerlistDelayMs); - const auto t0 = system_clock::now(); - // Client will block: LB will initially send empty serverlist. - CheckRpcSendOk(1, kCallDeadlineMs, true /* wait_for_ready */); - const auto ellapsed_ms = - std::chrono::duration_cast<std::chrono::milliseconds>( - system_clock::now() - t0); - // but eventually, the LB sends a serverlist update that allows the call to - // proceed. The call delay must be larger than the delay in sending the - // populated serverlist but under the call's deadline (which is enforced by - // the call's deadline). - EXPECT_GT(ellapsed_ms.count(), kServerlistDelayMs); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent two responses. - EXPECT_EQ(2U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) { - SetNextResolutionAllBalancers(); - const size_t kNumUnreachableServers = 5; - std::vector<int> ports; - for (size_t i = 0; i < kNumUnreachableServers; ++i) { - ports.push_back(grpc_pick_unused_port_or_die()); - } - ScheduleResponseForBalancer(0, BuildResponseForBackends(ports, {}), 0); - const Status status = SendRpc(); - // The error shouldn't be DEADLINE_EXCEEDED. - EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code()); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, Fallback) { - SetNextResolutionAllBalancers(); - const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); - const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); - const size_t kNumBackendsInResolution = backends_.size() / 2; - - ResetStub(kFallbackTimeoutMs); - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - backend_addresses.emplace_back(AddressData{backends_[i]->port_, ""}); - } - SetNextResolution(balancer_addresses, backend_addresses); - - // Send non-empty serverlist only after kServerlistDelayMs. - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - GetBackendPorts(kNumBackendsInResolution /* start_index */), {}), - kServerlistDelayMs); - - // Wait until all the fallback backends are reachable. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - WaitForBackend(i); - } - - // The first request. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(kNumBackendsInResolution); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - - // Fallback is used: each backend returned by the resolver should have - // gotten one request. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - - // Wait until the serverlist reception has been processed and all backends - // in the serverlist are reachable. - for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - WaitForBackend(i); - } - - // Send out the second request. - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(backends_.size() - kNumBackendsInResolution); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - - // Serverlist is used: each backend returned by the balancer should - // have gotten one request. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); - } - - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, FallbackUpdate) { - SetNextResolutionAllBalancers(); - const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); - const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); - const size_t kNumBackendsInResolution = backends_.size() / 3; - const size_t kNumBackendsInResolutionUpdate = backends_.size() / 3; - - ResetStub(kFallbackTimeoutMs); - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - backend_addresses.emplace_back(AddressData{backends_[i]->port_, ""}); - } - SetNextResolution(balancer_addresses, backend_addresses); - - // Send non-empty serverlist only after kServerlistDelayMs. - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - GetBackendPorts(kNumBackendsInResolution + - kNumBackendsInResolutionUpdate /* start_index */), - {}), - kServerlistDelayMs); - - // Wait until all the fallback backends are reachable. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - WaitForBackend(i); - } - - // The first request. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(kNumBackendsInResolution); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - - // Fallback is used: each backend returned by the resolver should have - // gotten one request. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - - balancer_addresses.clear(); - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - backend_addresses.clear(); - for (size_t i = kNumBackendsInResolution; - i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - backend_addresses.emplace_back(AddressData{backends_[i]->port_, ""}); - } - SetNextResolution(balancer_addresses, backend_addresses); - - // Wait until the resolution update has been processed and all the new - // fallback backends are reachable. - for (size_t i = kNumBackendsInResolution; - i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - WaitForBackend(i); - } - - // Send out the second request. - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(kNumBackendsInResolutionUpdate); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - - // The resolution update is used: each backend in the resolution update should - // have gotten one request. - for (size_t i = 0; i < kNumBackendsInResolution; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution; - i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution + kNumBackendsInResolutionUpdate; - i < backends_.size(); ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - - // Wait until the serverlist reception has been processed and all backends - // in the serverlist are reachable. - for (size_t i = kNumBackendsInResolution + kNumBackendsInResolutionUpdate; - i < backends_.size(); ++i) { - WaitForBackend(i); - } - - // Send out the third request. - gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH =========="); - CheckRpcSendOk(backends_.size() - kNumBackendsInResolution - - kNumBackendsInResolutionUpdate); - gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH =========="); - - // Serverlist is used: each backend returned by the balancer should - // have gotten one request. - for (size_t i = 0; - i < kNumBackendsInResolution + kNumBackendsInResolutionUpdate; ++i) { - EXPECT_EQ(0U, backends_[i]->service_.request_count()); - } - for (size_t i = kNumBackendsInResolution + kNumBackendsInResolutionUpdate; - i < backends_.size(); ++i) { - EXPECT_EQ(1U, backends_[i]->service_.request_count()); - } - - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, - FallbackAfterStartup_LoseContactWithBalancerThenBackends) { - // First two backends are fallback, last two are pointed to by balancer. - const size_t kNumFallbackBackends = 2; - const size_t kNumBalancerBackends = backends_.size() - kNumFallbackBackends; - std::vector<AddressData> backend_addresses; - for (size_t i = 0; i < kNumFallbackBackends; ++i) { - backend_addresses.emplace_back(AddressData{backends_[i]->port_, ""}); - } - std::vector<AddressData> balancer_addresses; - for (size_t i = 0; i < balancers_.size(); ++i) { - balancer_addresses.emplace_back(AddressData{balancers_[i]->port_, ""}); - } - SetNextResolution(balancer_addresses, backend_addresses); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(kNumFallbackBackends), {}), - 0); - // Try to connect. - channel_->GetState(true /* try_to_connect */); - WaitForAllBackends(1 /* num_requests_multiple_of */, - kNumFallbackBackends /* start_index */); - // Stop balancer. RPCs should continue going to backends from balancer. - balancers_[0]->Shutdown(); - CheckRpcSendOk(100 * kNumBalancerBackends); - for (size_t i = kNumFallbackBackends; i < backends_.size(); ++i) { - EXPECT_EQ(100UL, backends_[i]->service_.request_count()); - } - // Stop backends from balancer. This should put us in fallback mode. - for (size_t i = kNumFallbackBackends; i < backends_.size(); ++i) { - ShutdownBackend(i); - } - WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, - kNumFallbackBackends /* stop_index */); - // Restart the backends from the balancer. We should *not* start - // sending traffic back to them at this point (although the behavior - // in xds may be different). - for (size_t i = kNumFallbackBackends; i < backends_.size(); ++i) { - StartBackend(i); - } - CheckRpcSendOk(100 * kNumBalancerBackends); - for (size_t i = 0; i < kNumFallbackBackends; ++i) { - EXPECT_EQ(100UL, backends_[i]->service_.request_count()); - } - // Now start the balancer again. This should cause us to exit - // fallback mode. - balancers_[0]->Start(server_host_); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(kNumFallbackBackends), {}), - 0); - WaitForAllBackends(1 /* num_requests_multiple_of */, - kNumFallbackBackends /* start_index */); -} - -TEST_F(SingleBalancerTest, - FallbackAfterStartup_LoseContactWithBackendsThenBalancer) { - // First two backends are fallback, last two are pointed to by balancer. - const size_t kNumFallbackBackends = 2; - const size_t kNumBalancerBackends = backends_.size() - kNumFallbackBackends; - std::vector<AddressData> backend_addresses; - for (size_t i = 0; i < kNumFallbackBackends; ++i) { - backend_addresses.emplace_back(AddressData{backends_[i]->port_, ""}); - } - std::vector<AddressData> balancer_addresses; - for (size_t i = 0; i < balancers_.size(); ++i) { - balancer_addresses.emplace_back(AddressData{balancers_[i]->port_, ""}); - } - SetNextResolution(balancer_addresses, backend_addresses); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(kNumFallbackBackends), {}), - 0); - // Try to connect. - channel_->GetState(true /* try_to_connect */); - WaitForAllBackends(1 /* num_requests_multiple_of */, - kNumFallbackBackends /* start_index */); - // Stop backends from balancer. Since we are still in contact with - // the balancer at this point, RPCs should be failing. - for (size_t i = kNumFallbackBackends; i < backends_.size(); ++i) { - ShutdownBackend(i); - } - CheckRpcSendFailure(); - // Stop balancer. This should put us in fallback mode. - balancers_[0]->Shutdown(); - WaitForAllBackends(1 /* num_requests_multiple_of */, 0 /* start_index */, - kNumFallbackBackends /* stop_index */); - // Restart the backends from the balancer. We should *not* start - // sending traffic back to them at this point (although the behavior - // in xds may be different). - for (size_t i = kNumFallbackBackends; i < backends_.size(); ++i) { - StartBackend(i); - } - CheckRpcSendOk(100 * kNumBalancerBackends); - for (size_t i = 0; i < kNumFallbackBackends; ++i) { - EXPECT_EQ(100UL, backends_[i]->service_.request_count()); - } - // Now start the balancer again. This should cause us to exit - // fallback mode. - balancers_[0]->Start(server_host_); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(kNumFallbackBackends), {}), - 0); - WaitForAllBackends(1 /* num_requests_multiple_of */, - kNumFallbackBackends /* start_index */); -} - -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerChannelFails) { - const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); - ResetStub(kFallbackTimeoutMs); - // Return an unreachable balancer and one fallback backend. - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back( - AddressData{grpc_pick_unused_port_or_die(), ""}); - std::vector<AddressData> backend_addresses; - backend_addresses.emplace_back(AddressData{backends_[0]->port_, ""}); - SetNextResolution(balancer_addresses, backend_addresses); - // Send RPC with deadline less than the fallback timeout and make sure it - // succeeds. - CheckRpcSendOk(/* times */ 1, /* timeout_ms */ 1000, - /* wait_for_ready */ false); -} - -TEST_F(SingleBalancerTest, FallbackEarlyWhenBalancerCallFails) { - const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); - ResetStub(kFallbackTimeoutMs); - // Return one balancer and one fallback backend. - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - backend_addresses.emplace_back(AddressData{backends_[0]->port_, ""}); - SetNextResolution(balancer_addresses, backend_addresses); - // Balancer drops call without sending a serverlist. - balancers_[0]->service_.NotifyDoneWithServerlists(); - // Send RPC with deadline less than the fallback timeout and make sure it - // succeeds. - CheckRpcSendOk(/* times */ 1, /* timeout_ms */ 1000, - /* wait_for_ready */ false); -} - -TEST_F(SingleBalancerTest, FallbackControlledByBalancer_BeforeFirstServerlist) { - const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor(); - ResetStub(kFallbackTimeoutMs); - // Return one balancer and one fallback backend. - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - backend_addresses.emplace_back(AddressData{backends_[0]->port_, ""}); - SetNextResolution(balancer_addresses, backend_addresses); - // Balancer explicitly tells client to fallback. - LoadBalanceResponse resp; - resp.mutable_fallback_response(); - ScheduleResponseForBalancer(0, resp, 0); - // Send RPC with deadline less than the fallback timeout and make sure it - // succeeds. - CheckRpcSendOk(/* times */ 1, /* timeout_ms */ 1000, - /* wait_for_ready */ false); -} - -TEST_F(SingleBalancerTest, FallbackControlledByBalancer_AfterFirstServerlist) { - // Return one balancer and one fallback backend (backend 0). - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - backend_addresses.emplace_back(AddressData{backends_[0]->port_, ""}); - SetNextResolution(balancer_addresses, backend_addresses); - // Balancer initially sends serverlist, then tells client to fall back, - // then sends the serverlist again. - // The serverlist points to backend 1. - LoadBalanceResponse serverlist_resp = - BuildResponseForBackends({backends_[1]->port_}, {}); - LoadBalanceResponse fallback_resp; - fallback_resp.mutable_fallback_response(); - ScheduleResponseForBalancer(0, serverlist_resp, 0); - ScheduleResponseForBalancer(0, fallback_resp, 100); - ScheduleResponseForBalancer(0, serverlist_resp, 100); - // Requests initially go to backend 1, then go to backend 0 in - // fallback mode, then go back to backend 1 when we exit fallback. - WaitForBackend(1); - WaitForBackend(0); - WaitForBackend(1); -} - -TEST_F(SingleBalancerTest, BackendsRestart) { - SetNextResolutionAllBalancers(); - const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - // Stop backends. RPCs should fail. - ShutdownAllBackends(); - CheckRpcSendFailure(); - // Restart backends. RPCs should start succeeding again. - StartAllBackends(); - CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */, - true /* wait_for_ready */); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, ServiceNameFromLbPolicyConfig) { - constexpr char kServiceConfigWithTarget[] = - "{\n" - " \"loadBalancingConfig\":[\n" - " { \"grpclb\":{\n" - " \"serviceName\":\"test_service\"\n" - " }}\n" - " ]\n" - "}"; - - SetNextResolutionAllBalancers(kServiceConfigWithTarget); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Make sure that trying to connect works without a call. - channel_->GetState(true /* try_to_connect */); - // We need to wait for all backends to come online. - WaitForAllBackends(); - EXPECT_EQ(balancers_[0]->service_.service_names().back(), "test_service"); -} - -class UpdatesTest : public GrpclbEnd2endTest { - public: - UpdatesTest() : GrpclbEnd2endTest(4, 3, 0) {} -}; - -TEST_F(UpdatesTest, UpdateBalancersButKeepUsingOriginalBalancer) { - SetNextResolutionAllBalancers(); - const std::vector<int> first_backend{GetBackendPorts()[0]}; - const std::vector<int> second_backend{GetBackendPorts()[1]}; - ScheduleResponseForBalancer(0, BuildResponseForBackends(first_backend, {}), - 0); - ScheduleResponseForBalancer(1, BuildResponseForBackends(second_backend, {}), - 0); - - // Wait until the first backend is ready. - WaitForBackend(0); - - // Send 10 requests. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - - // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); - - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); - - std::vector<AddressData> addresses; - addresses.emplace_back(AddressData{balancers_[1]->port_, ""}); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolution(addresses); - gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // The current LB call is still working, so grpclb continued using it to the - // first balancer, which doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); -} - -// Send an update with the same set of LBs as the one in SetUp() in order to -// verify that the LB channel inside grpclb keeps the initial connection (which -// by definition is also present in the update). -TEST_F(UpdatesTest, UpdateBalancersRepeated) { - SetNextResolutionAllBalancers(); - const std::vector<int> first_backend{GetBackendPorts()[0]}; - const std::vector<int> second_backend{GetBackendPorts()[0]}; - - ScheduleResponseForBalancer(0, BuildResponseForBackends(first_backend, {}), - 0); - ScheduleResponseForBalancer(1, BuildResponseForBackends(second_backend, {}), - 0); - - // Wait until the first backend is ready. - WaitForBackend(0); - - // Send 10 requests. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - - // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); - - balancers_[0]->service_.NotifyDoneWithServerlists(); - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); - - std::vector<AddressData> addresses; - addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - addresses.emplace_back(AddressData{balancers_[1]->port_, ""}); - addresses.emplace_back(AddressData{balancers_[2]->port_, ""}); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolution(addresses); - gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // grpclb continued using the original LB call to the first balancer, which - // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - balancers_[0]->service_.NotifyDoneWithServerlists(); - - addresses.clear(); - addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - addresses.emplace_back(AddressData{balancers_[1]->port_, ""}); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 2 =========="); - SetNextResolution(addresses); - gpr_log(GPR_INFO, "========= UPDATE 2 DONE =========="); - - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(10000, GPR_TIMESPAN)); - // Send 10 seconds worth of RPCs - do { - CheckRpcSendOk(); - } while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0); - // grpclb continued using the original LB call to the first balancer, which - // doesn't assign the second backend. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - balancers_[0]->service_.NotifyDoneWithServerlists(); -} - -TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { - std::vector<AddressData> addresses; - addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - SetNextResolution(addresses); - const std::vector<int> first_backend{GetBackendPorts()[0]}; - const std::vector<int> second_backend{GetBackendPorts()[1]}; - - ScheduleResponseForBalancer(0, BuildResponseForBackends(first_backend, {}), - 0); - ScheduleResponseForBalancer(1, BuildResponseForBackends(second_backend, {}), - 0); - - // Start servers and send 10 RPCs per server. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); - - // Kill balancer 0 - gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); - balancers_[0]->Shutdown(); - gpr_log(GPR_INFO, "********** KILLED BALANCER 0 *************"); - - // This is serviced by the existing RR policy - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - // All 10 requests should again have gone to the first backend. - EXPECT_EQ(20U, backends_[0]->service_.request_count()); - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); - - addresses.clear(); - addresses.emplace_back(AddressData{balancers_[1]->port_, ""}); - gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); - SetNextResolution(addresses); - gpr_log(GPR_INFO, "========= UPDATE 1 DONE =========="); - - // Wait until update has been processed, as signaled by the second backend - // receiving a request. In the meantime, the client continues to be serviced - // (by the first backend) without interruption. - EXPECT_EQ(0U, backends_[1]->service_.request_count()); - WaitForBackend(1); - - // This is serviced by the updated RR policy - backends_[1]->service_.ResetCounters(); - gpr_log(GPR_INFO, "========= BEFORE THIRD BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH THIRD BATCH =========="); - // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->service_.request_count()); - - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // The second balancer, published as part of the first update, may end up - // getting two requests (that is, 1 <= #req <= 2) if the LB call retry timer - // firing races with the arrival of the update containing the second - // balancer. - EXPECT_GE(balancers_[1]->service_.request_count(), 1U); - EXPECT_GE(balancers_[1]->service_.response_count(), 1U); - EXPECT_LE(balancers_[1]->service_.request_count(), 2U); - EXPECT_LE(balancers_[1]->service_.response_count(), 2U); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); -} - -TEST_F(UpdatesTest, ReresolveDeadBackend) { - ResetStub(500); - // The first resolution contains the addresses of a balancer that never - // responds, and a fallback backend. - std::vector<AddressData> balancer_addresses; - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - std::vector<AddressData> backend_addresses; - backend_addresses.emplace_back(AddressData{backends_[0]->port_, ""}); - SetNextResolution(balancer_addresses, backend_addresses); - // Ask channel to connect to trigger resolver creation. - channel_->GetState(true); - // The re-resolution result will contain the addresses of the same balancer - // and a new fallback backend. - balancer_addresses.clear(); - balancer_addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - backend_addresses.clear(); - backend_addresses.emplace_back(AddressData{backends_[1]->port_, ""}); - SetNextReresolutionResponse(balancer_addresses, backend_addresses); - - // Start servers and send 10 RPCs per server. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the fallback backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); - - // Kill backend 0. - gpr_log(GPR_INFO, "********** ABOUT TO KILL BACKEND 0 *************"); - backends_[0]->Shutdown(); - gpr_log(GPR_INFO, "********** KILLED BACKEND 0 *************"); - - // Wait until re-resolution has finished, as signaled by the second backend - // receiving a request. - WaitForBackend(1); - - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->service_.request_count()); - - balancers_[0]->service_.NotifyDoneWithServerlists(); - balancers_[1]->service_.NotifyDoneWithServerlists(); - balancers_[2]->service_.NotifyDoneWithServerlists(); - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(0U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); -} - -// TODO(juanlishen): Should be removed when the first response is always the -// initial response. Currently, if client load reporting is not enabled, the -// balancer doesn't send initial response. When the backend shuts down, an -// unexpected re-resolution will happen. This test configuration is a workaround -// for test ReresolveDeadBalancer. -class UpdatesWithClientLoadReportingTest : public GrpclbEnd2endTest { - public: - UpdatesWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 3, 2) {} -}; - -TEST_F(UpdatesWithClientLoadReportingTest, ReresolveDeadBalancer) { - const std::vector<int> first_backend{GetBackendPorts()[0]}; - const std::vector<int> second_backend{GetBackendPorts()[1]}; - ScheduleResponseForBalancer(0, BuildResponseForBackends(first_backend, {}), - 0); - ScheduleResponseForBalancer(1, BuildResponseForBackends(second_backend, {}), - 0); - - // Ask channel to connect to trigger resolver creation. - channel_->GetState(true); - std::vector<AddressData> addresses; - addresses.emplace_back(AddressData{balancers_[0]->port_, ""}); - SetNextResolution(addresses); - addresses.clear(); - addresses.emplace_back(AddressData{balancers_[1]->port_, ""}); - SetNextReresolutionResponse(addresses); - - // Start servers and send 10 RPCs per server. - gpr_log(GPR_INFO, "========= BEFORE FIRST BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH FIRST BATCH =========="); - // All 10 requests should have gone to the first backend. - EXPECT_EQ(10U, backends_[0]->service_.request_count()); - - // Kill backend 0. - gpr_log(GPR_INFO, "********** ABOUT TO KILL BACKEND 0 *************"); - backends_[0]->Shutdown(); - gpr_log(GPR_INFO, "********** KILLED BACKEND 0 *************"); - - CheckRpcSendFailure(); - - // Balancer 0 got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - EXPECT_EQ(0U, balancers_[1]->service_.request_count()); - EXPECT_EQ(0U, balancers_[1]->service_.response_count()); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); - - // Kill balancer 0. - gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************"); - balancers_[0]->Shutdown(); - gpr_log(GPR_INFO, "********** KILLED BALANCER 0 *************"); - - // Wait until re-resolution has finished, as signaled by the second backend - // receiving a request. - WaitForBackend(1); - - // This is serviced by the new serverlist. - gpr_log(GPR_INFO, "========= BEFORE SECOND BATCH =========="); - CheckRpcSendOk(10); - gpr_log(GPR_INFO, "========= DONE WITH SECOND BATCH =========="); - // All 10 requests should have gone to the second backend. - EXPECT_EQ(10U, backends_[1]->service_.request_count()); - - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - // After balancer 0 is killed, we restart an LB call immediately (because we - // disconnect to a previously connected balancer). Although we will cancel - // this call when the re-resolution update is done and another LB call restart - // is needed, this old call may still succeed reaching the LB server if - // re-resolution is slow. So balancer 1 may have received 2 requests and sent - // 2 responses. - EXPECT_GE(balancers_[1]->service_.request_count(), 1U); - EXPECT_GE(balancers_[1]->service_.response_count(), 1U); - EXPECT_LE(balancers_[1]->service_.request_count(), 2U); - EXPECT_LE(balancers_[1]->service_.response_count(), 2U); - EXPECT_EQ(0U, balancers_[2]->service_.request_count()); - EXPECT_EQ(0U, balancers_[2]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, Drop) { - SetNextResolutionAllBalancers(); - const size_t kNumRpcsPerAddress = 100; - const int num_of_drop_by_rate_limiting_addresses = 1; - const int num_of_drop_by_load_balancing_addresses = 2; - const int num_of_drop_addresses = num_of_drop_by_rate_limiting_addresses + - num_of_drop_by_load_balancing_addresses; - const int num_total_addresses = num_backends_ + num_of_drop_addresses; - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - GetBackendPorts(), - {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), - 0); - // Wait until all backends are ready. - WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs for each server and drop address. - size_t num_drops = 0; - for (size_t i = 0; i < kNumRpcsPerAddress * num_total_addresses; ++i) { - EchoResponse response; - const Status status = SendRpc(&response); - if (!status.ok() && - status.error_message() == "drop directed by grpclb balancer") { - ++num_drops; - } else { - EXPECT_TRUE(status.ok()) << "code=" << status.error_code() - << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); - } - } - EXPECT_EQ(kNumRpcsPerAddress * num_of_drop_addresses, num_drops); - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); - } - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); -} - -TEST_F(SingleBalancerTest, DropAllFirst) { - SetNextResolutionAllBalancers(); - // All registered addresses are marked as "drop". - const int num_of_drop_by_rate_limiting_addresses = 1; - const int num_of_drop_by_load_balancing_addresses = 1; - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), - 0); - const Status status = SendRpc(nullptr, 1000, true); - EXPECT_FALSE(status.ok()); - EXPECT_EQ(status.error_message(), "drop directed by grpclb balancer"); -} - -TEST_F(SingleBalancerTest, DropAll) { - SetNextResolutionAllBalancers(); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - const int num_of_drop_by_rate_limiting_addresses = 1; - const int num_of_drop_by_load_balancing_addresses = 1; - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), - 1000); - - // First call succeeds. - CheckRpcSendOk(); - // But eventually, the update with only dropped servers is processed and calls - // fail. - Status status; - do { - status = SendRpc(nullptr, 1000, true); - } while (status.ok()); - EXPECT_FALSE(status.ok()); - EXPECT_EQ(status.error_message(), "drop directed by grpclb balancer"); -} - -class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest { - public: - SingleBalancerWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 1, 3) {} -}; - -TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { - SetNextResolutionAllBalancers(); - const size_t kNumRpcsPerAddress = 100; - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(), {}), 0); - // Wait until all backends are ready. - int num_ok = 0; - int num_failure = 0; - int num_drops = 0; - std::tie(num_ok, num_failure, num_drops) = WaitForAllBackends(); - // Send kNumRpcsPerAddress RPCs per server. - CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); - } - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - - ClientStats client_stats; - do { - client_stats += WaitForLoadReports(); - } while (client_stats.num_calls_finished != - kNumRpcsPerAddress * num_backends_ + num_ok); - EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + num_ok, - client_stats.num_calls_started); - EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + num_ok, - client_stats.num_calls_finished); - EXPECT_EQ(0U, client_stats.num_calls_finished_with_client_failed_to_send); - EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + (num_ok + num_drops), - client_stats.num_calls_finished_known_received); - EXPECT_THAT(client_stats.drop_token_counts, ::testing::ElementsAre()); -} - -TEST_F(SingleBalancerWithClientLoadReportingTest, BalancerRestart) { - SetNextResolutionAllBalancers(); - const size_t kNumBackendsFirstPass = 2; - const size_t kNumBackendsSecondPass = - backends_.size() - kNumBackendsFirstPass; - // Balancer returns backends starting at index 1. - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends(GetBackendPorts(0, kNumBackendsFirstPass), {}), - 0); - // Wait until all backends returned by the balancer are ready. - int num_ok = 0; - int num_failure = 0; - int num_drops = 0; - std::tie(num_ok, num_failure, num_drops) = - WaitForAllBackends(/* num_requests_multiple_of */ 1, /* start_index */ 0, - /* stop_index */ kNumBackendsFirstPass); - balancers_[0]->service_.NotifyDoneWithServerlists(); - ClientStats client_stats = WaitForLoadReports(); - EXPECT_EQ(static_cast<size_t>(num_ok), client_stats.num_calls_started); - EXPECT_EQ(static_cast<size_t>(num_ok), client_stats.num_calls_finished); - EXPECT_EQ(0U, client_stats.num_calls_finished_with_client_failed_to_send); - EXPECT_EQ(static_cast<size_t>(num_ok), - client_stats.num_calls_finished_known_received); - EXPECT_THAT(client_stats.drop_token_counts, ::testing::ElementsAre()); - // Shut down the balancer. - balancers_[0]->Shutdown(); - // Send 10 more requests per backend. This will continue using the - // last serverlist we received from the balancer before it was shut down. - ResetBackendCounters(); - CheckRpcSendOk(kNumBackendsFirstPass); - // Each backend should have gotten 1 request. - for (size_t i = 0; i < kNumBackendsFirstPass; ++i) { - EXPECT_EQ(1UL, backends_[i]->service_.request_count()); - } - // Now restart the balancer, this time pointing to all backends. - balancers_[0]->Start(server_host_); - ScheduleResponseForBalancer( - 0, BuildResponseForBackends(GetBackendPorts(kNumBackendsFirstPass), {}), - 0); - // Wait for queries to start going to one of the new backends. - // This tells us that we're now using the new serverlist. - do { - CheckRpcSendOk(); - } while (backends_[2]->service_.request_count() == 0 && - backends_[3]->service_.request_count() == 0); - // Send one RPC per backend. - CheckRpcSendOk(kNumBackendsSecondPass); - balancers_[0]->service_.NotifyDoneWithServerlists(); - // Check client stats. - client_stats = WaitForLoadReports(); - EXPECT_EQ(kNumBackendsSecondPass + 1, client_stats.num_calls_started); - EXPECT_EQ(kNumBackendsSecondPass + 1, client_stats.num_calls_finished); - EXPECT_EQ(0U, client_stats.num_calls_finished_with_client_failed_to_send); - EXPECT_EQ(kNumBackendsSecondPass + 1, - client_stats.num_calls_finished_known_received); - EXPECT_THAT(client_stats.drop_token_counts, ::testing::ElementsAre()); -} - -TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) { - SetNextResolutionAllBalancers(); - const size_t kNumRpcsPerAddress = 3; - const int num_of_drop_by_rate_limiting_addresses = 2; - const int num_of_drop_by_load_balancing_addresses = 1; - const int num_of_drop_addresses = num_of_drop_by_rate_limiting_addresses + - num_of_drop_by_load_balancing_addresses; - const int num_total_addresses = num_backends_ + num_of_drop_addresses; - ScheduleResponseForBalancer( - 0, - BuildResponseForBackends( - GetBackendPorts(), - {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), - 0); - // Wait until all backends are ready. - int num_warmup_ok = 0; - int num_warmup_failure = 0; - int num_warmup_drops = 0; - std::tie(num_warmup_ok, num_warmup_failure, num_warmup_drops) = - WaitForAllBackends(num_total_addresses /* num_requests_multiple_of */); - const int num_total_warmup_requests = - num_warmup_ok + num_warmup_failure + num_warmup_drops; - size_t num_drops = 0; - for (size_t i = 0; i < kNumRpcsPerAddress * num_total_addresses; ++i) { - EchoResponse response; - const Status status = SendRpc(&response); - if (!status.ok() && - status.error_message() == "drop directed by grpclb balancer") { - ++num_drops; - } else { - EXPECT_TRUE(status.ok()) << "code=" << status.error_code() - << " message=" << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage_); - } - } - EXPECT_EQ(kNumRpcsPerAddress * num_of_drop_addresses, num_drops); - // Each backend should have gotten 100 requests. - for (size_t i = 0; i < backends_.size(); ++i) { - EXPECT_EQ(kNumRpcsPerAddress, backends_[i]->service_.request_count()); - } - balancers_[0]->service_.NotifyDoneWithServerlists(); - // The balancer got a single request. - EXPECT_EQ(1U, balancers_[0]->service_.request_count()); - // and sent a single response. - EXPECT_EQ(1U, balancers_[0]->service_.response_count()); - - const ClientStats client_stats = WaitForLoadReports(); - EXPECT_EQ( - kNumRpcsPerAddress * num_total_addresses + num_total_warmup_requests, - client_stats.num_calls_started); - EXPECT_EQ( - kNumRpcsPerAddress * num_total_addresses + num_total_warmup_requests, - client_stats.num_calls_finished); - EXPECT_EQ(0U, client_stats.num_calls_finished_with_client_failed_to_send); - EXPECT_EQ(kNumRpcsPerAddress * num_backends_ + num_warmup_ok, - client_stats.num_calls_finished_known_received); - // The number of warmup request is a multiple of the number of addresses. - // Therefore, all addresses in the scheduled balancer response are hit the - // same number of times. - const int num_times_drop_addresses_hit = - num_warmup_drops / num_of_drop_addresses; - EXPECT_THAT( - client_stats.drop_token_counts, - ::testing::ElementsAre( - ::testing::Pair("load_balancing", - (kNumRpcsPerAddress + num_times_drop_addresses_hit)), - ::testing::Pair( - "rate_limiting", - (kNumRpcsPerAddress + num_times_drop_addresses_hit) * 2))); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - const auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/hybrid_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/hybrid_end2end_test.cc deleted file mode 100644 index 72b3213bac..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/hybrid_end2end_test.cc +++ /dev/null @@ -1,976 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <memory> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/generic/async_generic_service.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/iomgr.h" -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" - -namespace grpc { -namespace testing { -namespace { - -void* tag(int i) { return reinterpret_cast<void*>(i); } - -bool VerifyReturnSuccess(CompletionQueue* cq, int i) { - void* got_tag; - bool ok; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - EXPECT_EQ(tag(i), got_tag); - return ok; -} - -void Verify(CompletionQueue* cq, int i, bool expect_ok) { - EXPECT_EQ(expect_ok, VerifyReturnSuccess(cq, i)); -} - -// Handlers to handle async request at a server. To be run in a separate thread. -template <class Service> -void HandleEcho(Service* service, ServerCompletionQueue* cq, bool dup_service) { - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - EchoRequest recv_request; - EchoResponse send_response; - service->RequestEcho(&srv_ctx, &recv_request, &response_writer, cq, cq, - tag(1)); - Verify(cq, 1, true); - send_response.set_message(recv_request.message()); - if (dup_service) { - send_response.mutable_message()->append("_dup"); - } - response_writer.Finish(send_response, Status::OK, tag(2)); - Verify(cq, 2, true); -} - -// Handlers to handle raw request at a server. To be run in a -// separate thread. Note that this is the same as the async version, except -// that the req/resp are ByteBuffers -template <class Service> -void HandleRawEcho(Service* service, ServerCompletionQueue* cq, - bool /*dup_service*/) { - ServerContext srv_ctx; - GenericServerAsyncResponseWriter response_writer(&srv_ctx); - ByteBuffer recv_buffer; - service->RequestEcho(&srv_ctx, &recv_buffer, &response_writer, cq, cq, - tag(1)); - Verify(cq, 1, true); - EchoRequest recv_request; - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EchoResponse send_response; - send_response.set_message(recv_request.message()); - auto send_buffer = SerializeToByteBuffer(&send_response); - response_writer.Finish(*send_buffer, Status::OK, tag(2)); - Verify(cq, 2, true); -} - -template <class Service> -void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) { - ServerContext srv_ctx; - EchoRequest recv_request; - EchoResponse send_response; - ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); - service->RequestRequestStream(&srv_ctx, &srv_stream, cq, cq, tag(1)); - Verify(cq, 1, true); - int i = 1; - do { - i++; - send_response.mutable_message()->append(recv_request.message()); - srv_stream.Read(&recv_request, tag(i)); - } while (VerifyReturnSuccess(cq, i)); - srv_stream.Finish(send_response, Status::OK, tag(100)); - Verify(cq, 100, true); -} - -template <class Service> -void HandleRawClientStreaming(Service* service, ServerCompletionQueue* cq) { - ServerContext srv_ctx; - ByteBuffer recv_buffer; - EchoRequest recv_request; - EchoResponse send_response; - GenericServerAsyncReader srv_stream(&srv_ctx); - service->RequestRequestStream(&srv_ctx, &srv_stream, cq, cq, tag(1)); - Verify(cq, 1, true); - int i = 1; - while (true) { - i++; - srv_stream.Read(&recv_buffer, tag(i)); - if (!VerifyReturnSuccess(cq, i)) { - break; - } - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - send_response.mutable_message()->append(recv_request.message()); - } - auto send_buffer = SerializeToByteBuffer(&send_response); - srv_stream.Finish(*send_buffer, Status::OK, tag(100)); - Verify(cq, 100, true); -} - -template <class Service> -void HandleServerStreaming(Service* service, ServerCompletionQueue* cq) { - ServerContext srv_ctx; - EchoRequest recv_request; - EchoResponse send_response; - ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); - service->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, cq, cq, - tag(1)); - Verify(cq, 1, true); - send_response.set_message(recv_request.message() + "0"); - srv_stream.Write(send_response, tag(2)); - Verify(cq, 2, true); - send_response.set_message(recv_request.message() + "1"); - srv_stream.Write(send_response, tag(3)); - Verify(cq, 3, true); - send_response.set_message(recv_request.message() + "2"); - srv_stream.Write(send_response, tag(4)); - Verify(cq, 4, true); - srv_stream.Finish(Status::OK, tag(5)); - Verify(cq, 5, true); -} - -void HandleGenericEcho(GenericServerAsyncReaderWriter* stream, - CompletionQueue* cq) { - ByteBuffer recv_buffer; - stream->Read(&recv_buffer, tag(2)); - Verify(cq, 2, true); - EchoRequest recv_request; - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - EchoResponse send_response; - send_response.set_message(recv_request.message()); - auto send_buffer = SerializeToByteBuffer(&send_response); - stream->Write(*send_buffer, tag(3)); - Verify(cq, 3, true); - stream->Finish(Status::OK, tag(4)); - Verify(cq, 4, true); -} - -void HandleGenericRequestStream(GenericServerAsyncReaderWriter* stream, - CompletionQueue* cq) { - ByteBuffer recv_buffer; - EchoRequest recv_request; - EchoResponse send_response; - int i = 1; - while (true) { - i++; - stream->Read(&recv_buffer, tag(i)); - if (!VerifyReturnSuccess(cq, i)) { - break; - } - EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); - send_response.mutable_message()->append(recv_request.message()); - } - auto send_buffer = SerializeToByteBuffer(&send_response); - stream->Write(*send_buffer, tag(99)); - Verify(cq, 99, true); - stream->Finish(Status::OK, tag(100)); - Verify(cq, 100, true); -} - -// Request and handle one generic call. -void HandleGenericCall(AsyncGenericService* service, - ServerCompletionQueue* cq) { - GenericServerContext srv_ctx; - GenericServerAsyncReaderWriter stream(&srv_ctx); - service->RequestCall(&srv_ctx, &stream, cq, cq, tag(1)); - Verify(cq, 1, true); - if (srv_ctx.method() == "/grpc.testing.EchoTestService/Echo") { - HandleGenericEcho(&stream, cq); - } else if (srv_ctx.method() == - "/grpc.testing.EchoTestService/RequestStream") { - HandleGenericRequestStream(&stream, cq); - } else { // other methods not handled yet. - gpr_log(GPR_ERROR, "method: %s", srv_ctx.method().c_str()); - GPR_ASSERT(0); - } -} - -class TestServiceImplDupPkg - : public ::grpc::testing::duplicate::EchoTestService::Service { - public: - Status Echo(ServerContext* /*context*/, const EchoRequest* request, - EchoResponse* response) override { - response->set_message(request->message() + "_dup"); - return Status::OK; - } -}; - -class HybridEnd2endTest : public ::testing::TestWithParam<bool> { - protected: - HybridEnd2endTest() {} - - static void SetUpTestCase() { -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - } - - void SetUp() override { - inproc_ = (::testing::UnitTest::GetInstance() - ->current_test_info() - ->value_param() != nullptr) - ? GetParam() - : false; - } - - bool SetUpServer(::grpc::Service* service1, ::grpc::Service* service2, - AsyncGenericService* generic_service, - CallbackGenericService* callback_generic_service, - int max_message_size = 0) { - int port = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port; - - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - grpc::InsecureServerCredentials()); - // Always add a sync unimplemented service: we rely on having at least one - // synchronous method to get a listening cq - builder.RegisterService(&unimplemented_service_); - builder.RegisterService(service1); - if (service2) { - builder.RegisterService(service2); - } - if (generic_service) { - builder.RegisterAsyncGenericService(generic_service); - } - if (callback_generic_service) { - builder.RegisterCallbackGenericService(callback_generic_service); - } - - if (max_message_size != 0) { - builder.SetMaxMessageSize(max_message_size); - } - - // Create a separate cq for each potential handler. - for (int i = 0; i < 5; i++) { - cqs_.push_back(builder.AddCompletionQueue(false)); - } - server_ = builder.BuildAndStart(); - - // If there is a generic callback service, this setup is only successful if - // we have an iomgr that can run in the background or are inprocess - return !callback_generic_service || grpc_iomgr_run_in_background() || - inproc_; - } - - void TearDown() override { - if (server_) { - server_->Shutdown(); - } - void* ignored_tag; - bool ignored_ok; - for (auto it = cqs_.begin(); it != cqs_.end(); ++it) { - (*it)->Shutdown(); - while ((*it)->Next(&ignored_tag, &ignored_ok)) { - } - } - } - - void ResetStub() { - std::shared_ptr<Channel> channel = - inproc_ ? server_->InProcessChannel(ChannelArguments()) - : grpc::CreateChannel(server_address_.str(), - InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - // Test all rpc methods. - void TestAllMethods() { - SendEcho(); - SendSimpleClientStreaming(); - SendSimpleServerStreaming(); - SendBidiStreaming(); - } - - void SendEcho() { - EchoRequest send_request; - EchoResponse recv_response; - ClientContext cli_ctx; - cli_ctx.set_wait_for_ready(true); - send_request.set_message("Hello"); - Status recv_status = stub_->Echo(&cli_ctx, send_request, &recv_response); - EXPECT_EQ(send_request.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - - void SendEchoToDupService() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel); - EchoRequest send_request; - EchoResponse recv_response; - ClientContext cli_ctx; - cli_ctx.set_wait_for_ready(true); - send_request.set_message("Hello"); - Status recv_status = stub->Echo(&cli_ctx, send_request, &recv_response); - EXPECT_EQ(send_request.message() + "_dup", recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - - void SendSimpleClientStreaming() { - EchoRequest send_request; - EchoResponse recv_response; - TString expected_message; - ClientContext cli_ctx; - cli_ctx.set_wait_for_ready(true); - send_request.set_message("Hello"); - auto stream = stub_->RequestStream(&cli_ctx, &recv_response); - for (int i = 0; i < 5; i++) { - EXPECT_TRUE(stream->Write(send_request)); - expected_message.append(send_request.message()); - } - stream->WritesDone(); - Status recv_status = stream->Finish(); - EXPECT_EQ(expected_message, recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - - void SendSimpleServerStreaming() { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_wait_for_ready(true); - request.set_message("hello"); - - auto stream = stub_->ResponseStream(&context, request); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "0"); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "1"); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "2"); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); - } - - void SendSimpleServerStreamingToDupService() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - auto stub = grpc::testing::duplicate::EchoTestService::NewStub(channel); - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_wait_for_ready(true); - request.set_message("hello"); - - auto stream = stub->ResponseStream(&context, request); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "0_dup"); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "1_dup"); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message() + "2_dup"); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); - } - - void SendBidiStreaming() { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_wait_for_ready(true); - TString msg("hello"); - - auto stream = stub_->BidiStream(&context); - - request.set_message(msg + "0"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "1"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "2"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - stream->WritesDone(); - EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); - } - - grpc::testing::UnimplementedEchoService::Service unimplemented_service_; - std::vector<std::unique_ptr<ServerCompletionQueue>> cqs_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - bool inproc_; -}; - -TEST_F(HybridEnd2endTest, AsyncEcho) { - typedef EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(), - false); - TestAllMethods(); - echo_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, RawEcho) { - typedef EchoTestService::WithRawMethod_Echo<TestServiceImpl> SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread echo_handler_thread(HandleRawEcho<SType>, &service, cqs_[0].get(), - false); - TestAllMethods(); - echo_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, RawRequestStream) { - typedef EchoTestService::WithRawMethod_RequestStream<TestServiceImpl> SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>, - &service, cqs_[0].get()); - TestAllMethods(); - request_stream_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, AsyncEchoRawRequestStream) { - typedef EchoTestService::WithRawMethod_RequestStream< - EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>> - SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(), - false); - std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - request_stream_handler_thread.join(); - echo_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, GenericEchoRawRequestStream) { - typedef EchoTestService::WithRawMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo<TestServiceImpl>> - SType; - SType service; - AsyncGenericService generic_service; - SetUpServer(&service, nullptr, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - generic_handler_thread.join(); - request_stream_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>> - SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(), - false); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - echo_handler_thread.join(); - request_stream_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - SetUpServer(&service, nullptr, nullptr, nullptr); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one sync method. -TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - TestServiceImplDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendEchoToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one sync streamed unary method. -class StreamedUnaryDupPkg - : public duplicate::EchoTestService::WithStreamedUnaryMethod_Echo< - TestServiceImplDupPkg> { - public: - Status StreamedEcho( - ServerContext* /*context*/, - ServerUnaryStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - resp.set_message(req.message() + "_dup"); - GPR_ASSERT(stream->Write(resp)); - return Status::OK; - } -}; - -TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_SyncStreamedUnaryDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - StreamedUnaryDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr, 8192); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendEchoToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service that is fully Streamed Unary -class FullyStreamedUnaryDupPkg - : public duplicate::EchoTestService::StreamedUnaryService { - public: - Status StreamedEcho( - ServerContext* /*context*/, - ServerUnaryStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - resp.set_message(req.message() + "_dup"); - GPR_ASSERT(stream->Write(resp)); - return Status::OK; - } -}; - -TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_SyncFullyStreamedUnaryDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - FullyStreamedUnaryDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr, 8192); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendEchoToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one sync split server streaming method. -class SplitResponseStreamDupPkg - : public duplicate::EchoTestService:: - WithSplitStreamingMethod_ResponseStream<TestServiceImplDupPkg> { - public: - Status StreamedResponseStream( - ServerContext* /*context*/, - ServerSplitStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - resp.set_message(req.message() + ToString(i) + "_dup"); - GPR_ASSERT(stream->Write(resp)); - } - return Status::OK; - } -}; - -TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_SyncSplitStreamedDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - SplitResponseStreamDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr, 8192); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendSimpleServerStreamingToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service that is fully split server streamed -class FullySplitStreamedDupPkg - : public duplicate::EchoTestService::SplitStreamedService { - public: - Status StreamedResponseStream( - ServerContext* /*context*/, - ServerSplitStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - resp.set_message(req.message() + ToString(i) + "_dup"); - GPR_ASSERT(stream->Write(resp)); - } - return Status::OK; - } -}; - -TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_FullySplitStreamedDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - FullySplitStreamedDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr, 8192); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendSimpleServerStreamingToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service that is fully server streamed -class FullyStreamedDupPkg : public duplicate::EchoTestService::StreamedService { - public: - Status StreamedEcho( - ServerContext* /*context*/, - ServerUnaryStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - resp.set_message(req.message() + "_dup"); - GPR_ASSERT(stream->Write(resp)); - return Status::OK; - } - Status StreamedResponseStream( - ServerContext* /*context*/, - ServerSplitStreamer<EchoRequest, EchoResponse>* stream) override { - EchoRequest req; - EchoResponse resp; - uint32_t next_msg_sz; - stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); - GPR_ASSERT(stream->Read(&req)); - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - resp.set_message(req.message() + ToString(i) + "_dup"); - GPR_ASSERT(stream->Write(resp)); - } - return Status::OK; - } -}; - -TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_FullyStreamedDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - FullyStreamedDupPkg dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr, 8192); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendEchoToDupService(); - SendSimpleServerStreamingToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one async method. -TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> - SType; - SType service; - duplicate::EchoTestService::AsyncService dup_service; - SetUpServer(&service, &dup_service, nullptr, nullptr); - ResetStub(); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - std::thread echo_handler_thread( - HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service, - cqs_[2].get(), true); - TestAllMethods(); - SendEchoToDupService(); - response_stream_handler_thread.join(); - request_stream_handler_thread.join(); - echo_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, GenericEcho) { - EchoTestService::WithGenericMethod_Echo<TestServiceImpl> service; - AsyncGenericService generic_service; - SetUpServer(&service, nullptr, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - TestAllMethods(); - generic_handler_thread.join(); -} - -TEST_P(HybridEnd2endTest, CallbackGenericEcho) { - EchoTestService::WithGenericMethod_Echo<TestServiceImpl> service; - class GenericEchoService : public CallbackGenericService { - private: - ServerGenericBidiReactor* CreateReactor( - GenericCallbackServerContext* context) override { - EXPECT_EQ(context->method(), "/grpc.testing.EchoTestService/Echo"); - gpr_log(GPR_DEBUG, "Constructor of generic service %d", - static_cast<int>(context->deadline().time_since_epoch().count())); - - class Reactor : public ServerGenericBidiReactor { - public: - Reactor() { StartRead(&request_); } - - private: - void OnDone() override { delete this; } - void OnReadDone(bool ok) override { - if (!ok) { - EXPECT_EQ(reads_complete_, 1); - } else { - EXPECT_EQ(reads_complete_++, 0); - response_ = request_; - StartWrite(&response_); - StartRead(&request_); - } - } - void OnWriteDone(bool ok) override { - Finish(ok ? Status::OK - : Status(StatusCode::UNKNOWN, "Unexpected failure")); - } - ByteBuffer request_; - ByteBuffer response_; - std::atomic_int reads_complete_{0}; - }; - return new Reactor; - } - } generic_service; - - if (!SetUpServer(&service, nullptr, nullptr, &generic_service)) { - return; - } - ResetStub(); - TestAllMethods(); -} - -TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo<TestServiceImpl>> - SType; - SType service; - AsyncGenericService generic_service; - SetUpServer(&service, nullptr, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - generic_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one sync method. -TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo<TestServiceImpl>> - SType; - SType service; - AsyncGenericService generic_service; - TestServiceImplDupPkg dup_service; - SetUpServer(&service, &dup_service, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - TestAllMethods(); - SendEchoToDupService(); - generic_handler_thread.join(); - request_stream_handler_thread.join(); -} - -// Add a second service with one async method. -TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo<TestServiceImpl>> - SType; - SType service; - AsyncGenericService generic_service; - duplicate::EchoTestService::AsyncService dup_service; - SetUpServer(&service, &dup_service, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - std::thread echo_handler_thread( - HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service, - cqs_[2].get(), true); - TestAllMethods(); - SendEchoToDupService(); - generic_handler_thread.join(); - request_stream_handler_thread.join(); - echo_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) { - typedef EchoTestService::WithAsyncMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>> - SType; - SType service; - AsyncGenericService generic_service; - SetUpServer(&service, nullptr, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread request_stream_handler_thread(HandleClientStreaming<SType>, - &service, cqs_[1].get()); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[2].get()); - TestAllMethods(); - generic_handler_thread.join(); - request_stream_handler_thread.join(); - response_stream_handler_thread.join(); -} - -TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) { - typedef EchoTestService::WithGenericMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>> - SType; - SType service; - AsyncGenericService generic_service; - SetUpServer(&service, nullptr, &generic_service, nullptr); - ResetStub(); - std::thread generic_handler_thread(HandleGenericCall, &generic_service, - cqs_[0].get()); - std::thread generic_handler_thread2(HandleGenericCall, &generic_service, - cqs_[1].get()); - std::thread response_stream_handler_thread(HandleServerStreaming<SType>, - &service, cqs_[2].get()); - TestAllMethods(); - generic_handler_thread.join(); - generic_handler_thread2.join(); - response_stream_handler_thread.join(); -} - -// If WithGenericMethod is called and no generic service is registered, the -// server will fail to build. -TEST_F(HybridEnd2endTest, GenericMethodWithoutGenericService) { - EchoTestService::WithGenericMethod_RequestStream< - EchoTestService::WithGenericMethod_Echo< - EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>> - service; - SetUpServer(&service, nullptr, nullptr, nullptr); - EXPECT_EQ(nullptr, server_.get()); -} - -INSTANTIATE_TEST_SUITE_P(HybridEnd2endTest, HybridEnd2endTest, - ::testing::Bool()); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/message_allocator_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/message_allocator_end2end_test.cc deleted file mode 100644 index 04b8be75b8..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/message_allocator_end2end_test.cc +++ /dev/null @@ -1,400 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <atomic> -#include <condition_variable> -#include <functional> -#include <memory> -#include <mutex> -#include <sstream> -#include <thread> - -#include <google/protobuf/arena.h> -#include <gtest/gtest.h> - -#include <grpc/impl/codegen/log.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/support/client_callback.h> -#include <grpcpp/support/message_allocator.h> - -#include "src/core/lib/iomgr/iomgr.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/test_credentials_provider.h" - -namespace grpc { -namespace testing { -namespace { - -class CallbackTestServiceImpl : public EchoTestService::CallbackService { - public: - explicit CallbackTestServiceImpl() {} - - void SetAllocatorMutator( - std::function<void(RpcAllocatorState* allocator_state, - const EchoRequest* req, EchoResponse* resp)> - mutator) { - allocator_mutator_ = std::move(mutator); - } - - ServerUnaryReactor* Echo(CallbackServerContext* context, - const EchoRequest* request, - EchoResponse* response) override { - response->set_message(request->message()); - if (allocator_mutator_) { - allocator_mutator_(context->GetRpcAllocatorState(), request, response); - } - auto* reactor = context->DefaultReactor(); - reactor->Finish(Status::OK); - return reactor; - } - - private: - std::function<void(RpcAllocatorState* allocator_state, const EchoRequest* req, - EchoResponse* resp)> - allocator_mutator_; -}; - -enum class Protocol { INPROC, TCP }; - -class TestScenario { - public: - TestScenario(Protocol protocol, const TString& creds_type) - : protocol(protocol), credentials_type(creds_type) {} - void Log() const; - Protocol protocol; - const TString credentials_type; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{protocol=" - << (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP") - << "," << scenario.credentials_type << "}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_INFO, "%s", out.str().c_str()); -} - -class MessageAllocatorEnd2endTestBase - : public ::testing::TestWithParam<TestScenario> { - protected: - MessageAllocatorEnd2endTestBase() { GetParam().Log(); } - - ~MessageAllocatorEnd2endTestBase() override = default; - - void CreateServer(MessageAllocator<EchoRequest, EchoResponse>* allocator) { - ServerBuilder builder; - - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - if (GetParam().protocol == Protocol::TCP) { - picked_port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << picked_port_; - builder.AddListeningPort(server_address_.str(), server_creds); - } - callback_service_.SetMessageAllocatorFor_Echo(allocator); - builder.RegisterService(&callback_service_); - - server_ = builder.BuildAndStart(); - } - - void DestroyServer() { - if (server_) { - server_->Shutdown(); - server_.reset(); - } - } - - void ResetStub() { - ChannelArguments args; - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - switch (GetParam().protocol) { - case Protocol::TCP: - channel_ = ::grpc::CreateCustomChannel(server_address_.str(), - channel_creds, args); - break; - case Protocol::INPROC: - channel_ = server_->InProcessChannel(args); - break; - default: - assert(false); - } - stub_ = EchoTestService::NewStub(channel_); - } - - void TearDown() override { - DestroyServer(); - if (picked_port_ > 0) { - grpc_recycle_unused_port(picked_port_); - } - } - - void SendRpcs(int num_rpcs) { - TString test_string(""); - for (int i = 0; i < num_rpcs; i++) { - EchoRequest request; - EchoResponse response; - ClientContext cli_ctx; - - test_string += TString(1024, 'x'); - request.set_message(test_string); - TString val; - cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); - - std::mutex mu; - std::condition_variable cv; - bool done = false; - stub_->async()->Echo( - &cli_ctx, &request, &response, - [&request, &response, &done, &mu, &cv, val](Status s) { - GPR_ASSERT(s.ok()); - - EXPECT_EQ(request.message(), response.message()); - std::lock_guard<std::mutex> l(mu); - done = true; - cv.notify_one(); - }); - std::unique_lock<std::mutex> l(mu); - while (!done) { - cv.wait(l); - } - } - } - - int picked_port_{0}; - std::shared_ptr<Channel> channel_; - std::unique_ptr<EchoTestService::Stub> stub_; - CallbackTestServiceImpl callback_service_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; -}; - -class NullAllocatorTest : public MessageAllocatorEnd2endTestBase {}; - -TEST_P(NullAllocatorTest, SimpleRpc) { - CreateServer(nullptr); - ResetStub(); - SendRpcs(1); -} - -class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { - public: - class SimpleAllocator : public MessageAllocator<EchoRequest, EchoResponse> { - public: - class MessageHolderImpl : public MessageHolder<EchoRequest, EchoResponse> { - public: - MessageHolderImpl(std::atomic_int* request_deallocation_count, - std::atomic_int* messages_deallocation_count) - : request_deallocation_count_(request_deallocation_count), - messages_deallocation_count_(messages_deallocation_count) { - set_request(new EchoRequest); - set_response(new EchoResponse); - } - void Release() override { - (*messages_deallocation_count_)++; - delete request(); - delete response(); - delete this; - } - void FreeRequest() override { - (*request_deallocation_count_)++; - delete request(); - set_request(nullptr); - } - - EchoRequest* ReleaseRequest() { - auto* ret = request(); - set_request(nullptr); - return ret; - } - - private: - std::atomic_int* const request_deallocation_count_; - std::atomic_int* const messages_deallocation_count_; - }; - MessageHolder<EchoRequest, EchoResponse>* AllocateMessages() override { - allocation_count++; - return new MessageHolderImpl(&request_deallocation_count, - &messages_deallocation_count); - } - int allocation_count = 0; - std::atomic_int request_deallocation_count{0}; - std::atomic_int messages_deallocation_count{0}; - }; -}; - -TEST_P(SimpleAllocatorTest, SimpleRpc) { - const int kRpcCount = 10; - std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator); - CreateServer(allocator.get()); - ResetStub(); - SendRpcs(kRpcCount); - // messages_deallocaton_count is updated in Release after server side OnDone. - // Destroy server to make sure it has been updated. - DestroyServer(); - EXPECT_EQ(kRpcCount, allocator->allocation_count); - EXPECT_EQ(kRpcCount, allocator->messages_deallocation_count); - EXPECT_EQ(0, allocator->request_deallocation_count); -} - -TEST_P(SimpleAllocatorTest, RpcWithEarlyFreeRequest) { - const int kRpcCount = 10; - std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator); - auto mutator = [](RpcAllocatorState* allocator_state, const EchoRequest* req, - EchoResponse* resp) { - auto* info = - static_cast<SimpleAllocator::MessageHolderImpl*>(allocator_state); - EXPECT_EQ(req, info->request()); - EXPECT_EQ(resp, info->response()); - allocator_state->FreeRequest(); - EXPECT_EQ(nullptr, info->request()); - }; - callback_service_.SetAllocatorMutator(mutator); - CreateServer(allocator.get()); - ResetStub(); - SendRpcs(kRpcCount); - // messages_deallocaton_count is updated in Release after server side OnDone. - // Destroy server to make sure it has been updated. - DestroyServer(); - EXPECT_EQ(kRpcCount, allocator->allocation_count); - EXPECT_EQ(kRpcCount, allocator->messages_deallocation_count); - EXPECT_EQ(kRpcCount, allocator->request_deallocation_count); -} - -TEST_P(SimpleAllocatorTest, RpcWithReleaseRequest) { - const int kRpcCount = 10; - std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator); - std::vector<EchoRequest*> released_requests; - auto mutator = [&released_requests](RpcAllocatorState* allocator_state, - const EchoRequest* req, - EchoResponse* resp) { - auto* info = - static_cast<SimpleAllocator::MessageHolderImpl*>(allocator_state); - EXPECT_EQ(req, info->request()); - EXPECT_EQ(resp, info->response()); - released_requests.push_back(info->ReleaseRequest()); - EXPECT_EQ(nullptr, info->request()); - }; - callback_service_.SetAllocatorMutator(mutator); - CreateServer(allocator.get()); - ResetStub(); - SendRpcs(kRpcCount); - // messages_deallocaton_count is updated in Release after server side OnDone. - // Destroy server to make sure it has been updated. - DestroyServer(); - EXPECT_EQ(kRpcCount, allocator->allocation_count); - EXPECT_EQ(kRpcCount, allocator->messages_deallocation_count); - EXPECT_EQ(0, allocator->request_deallocation_count); - EXPECT_EQ(static_cast<unsigned>(kRpcCount), released_requests.size()); - for (auto* req : released_requests) { - delete req; - } -} - -class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase { - public: - class ArenaAllocator : public MessageAllocator<EchoRequest, EchoResponse> { - public: - class MessageHolderImpl : public MessageHolder<EchoRequest, EchoResponse> { - public: - MessageHolderImpl() { - set_request( - google::protobuf::Arena::CreateMessage<EchoRequest>(&arena_)); - set_response( - google::protobuf::Arena::CreateMessage<EchoResponse>(&arena_)); - } - void Release() override { delete this; } - void FreeRequest() override { GPR_ASSERT(0); } - - private: - google::protobuf::Arena arena_; - }; - MessageHolder<EchoRequest, EchoResponse>* AllocateMessages() override { - allocation_count++; - return new MessageHolderImpl; - } - int allocation_count = 0; - }; -}; - -TEST_P(ArenaAllocatorTest, SimpleRpc) { - const int kRpcCount = 10; - std::unique_ptr<ArenaAllocator> allocator(new ArenaAllocator); - CreateServer(allocator.get()); - ResetStub(); - SendRpcs(kRpcCount); - EXPECT_EQ(kRpcCount, allocator->allocation_count); -} - -std::vector<TestScenario> CreateTestScenarios(bool test_insecure) { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types{ - GetCredentialsProvider()->GetSecureCredentialsTypeList()}; - auto insec_ok = [] { - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - return GetCredentialsProvider()->GetChannelCredentials( - kInsecureCredentialsType, nullptr) != nullptr; - }; - if (test_insecure && insec_ok()) { - credentials_types.push_back(kInsecureCredentialsType); - } - GPR_ASSERT(!credentials_types.empty()); - - Protocol parr[]{Protocol::INPROC, Protocol::TCP}; - for (Protocol p : parr) { - for (const auto& cred : credentials_types) { - // TODO(vjpai): Test inproc with secure credentials when feasible - if (p == Protocol::INPROC && - (cred != kInsecureCredentialsType || !insec_ok())) { - continue; - } - scenarios.emplace_back(p, cred); - } - } - return scenarios; -} - -INSTANTIATE_TEST_SUITE_P(NullAllocatorTest, NullAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); -INSTANTIATE_TEST_SUITE_P(SimpleAllocatorTest, SimpleAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); -INSTANTIATE_TEST_SUITE_P(ArenaAllocatorTest, ArenaAllocatorTest, - ::testing::ValuesIn(CreateTestScenarios(true))); - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/mock_test.cc b/contrib/libs/grpc/test/cpp/end2end/mock_test.cc deleted file mode 100644 index dc4b34e21d..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/mock_test.cc +++ /dev/null @@ -1,433 +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. - * - */ - -#include <climits> -#include <iostream> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/types/optional.h" - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> -#include <grpcpp/test/default_reactor_test_peer.h> -#include <grpcpp/test/mock_stream.h> - -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "src/proto/grpc/testing/echo_mock.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -using grpc::testing::DefaultReactorTestPeer; -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; -using grpc::testing::EchoTestService; -using grpc::testing::MockClientReaderWriter; -using std::vector; -using ::testing::_; -using ::testing::AtLeast; -using ::testing::DoAll; -using ::testing::Return; -using ::testing::SaveArg; -using ::testing::SetArgPointee; -using ::testing::WithArg; - -namespace grpc { -namespace testing { - -namespace { -class FakeClient { - public: - explicit FakeClient(EchoTestService::StubInterface* stub) : stub_(stub) {} - - void DoEcho() { - ClientContext context; - EchoRequest request; - EchoResponse response; - request.set_message("hello world"); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.ok()); - } - - void DoRequestStream() { - EchoRequest request; - EchoResponse response; - - ClientContext context; - TString msg("hello"); - TString exp(msg); - - std::unique_ptr<ClientWriterInterface<EchoRequest>> cstream = - stub_->RequestStream(&context, &response); - - request.set_message(msg); - EXPECT_TRUE(cstream->Write(request)); - - msg = ", world"; - request.set_message(msg); - exp.append(msg); - EXPECT_TRUE(cstream->Write(request)); - - cstream->WritesDone(); - Status s = cstream->Finish(); - - EXPECT_EQ(exp, response.message()); - EXPECT_TRUE(s.ok()); - } - - void DoResponseStream() { - EchoRequest request; - EchoResponse response; - request.set_message("hello world"); - - ClientContext context; - std::unique_ptr<ClientReaderInterface<EchoResponse>> cstream = - stub_->ResponseStream(&context, request); - - TString exp = ""; - EXPECT_TRUE(cstream->Read(&response)); - exp.append(response.message() + " "); - - EXPECT_TRUE(cstream->Read(&response)); - exp.append(response.message()); - - EXPECT_FALSE(cstream->Read(&response)); - EXPECT_EQ(request.message(), exp); - - Status s = cstream->Finish(); - EXPECT_TRUE(s.ok()); - } - - void DoBidiStream() { - EchoRequest request; - EchoResponse response; - ClientContext context; - TString msg("hello"); - - std::unique_ptr<ClientReaderWriterInterface<EchoRequest, EchoResponse>> - stream = stub_->BidiStream(&context); - - request.set_message(msg + "0"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "1"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - request.set_message(msg + "2"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(response.message(), request.message()); - - stream->WritesDone(); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - EXPECT_TRUE(s.ok()); - } - - void ResetStub(EchoTestService::StubInterface* stub) { stub_ = stub; } - - private: - EchoTestService::StubInterface* stub_; -}; - -class CallbackTestServiceImpl : public EchoTestService::CallbackService { - public: - ServerUnaryReactor* Echo(CallbackServerContext* context, - const EchoRequest* request, - EchoResponse* response) override { - // Make the mock service explicitly treat empty input messages as invalid - // arguments so that we can test various results of status. In general, a - // mocked service should just use the original service methods, but we are - // adding this variance in Status return value just to improve coverage in - // this test. - auto* reactor = context->DefaultReactor(); - if (request->message().length() > 0) { - response->set_message(request->message()); - reactor->Finish(Status::OK); - } else { - reactor->Finish(Status(StatusCode::INVALID_ARGUMENT, "Invalid request")); - } - return reactor; - } -}; - -class MockCallbackTest : public ::testing::Test { - protected: - CallbackTestServiceImpl service_; - ServerContext context_; -}; - -TEST_F(MockCallbackTest, MockedCallSucceedsWithWait) { - CallbackServerContext ctx; - EchoRequest req; - EchoResponse resp; - struct { - grpc::internal::Mutex mu; - grpc::internal::CondVar cv; - y_absl::optional<grpc::Status> Y_ABSL_GUARDED_BY(mu) status; - } status; - DefaultReactorTestPeer peer(&ctx, [&](::grpc::Status s) { - grpc::internal::MutexLock l(&status.mu); - status.status = std::move(s); - status.cv.Signal(); - }); - - req.set_message("mock 1"); - auto* reactor = service_.Echo(&ctx, &req, &resp); - - grpc::internal::MutexLock l(&status.mu); - while (!status.status.has_value()) { - status.cv.Wait(&status.mu); - } - - EXPECT_EQ(reactor, peer.reactor()); - EXPECT_TRUE(peer.test_status_set()); - EXPECT_TRUE(peer.test_status().ok()); - EXPECT_TRUE(status.status.has_value()); - EXPECT_TRUE(status.status.value().ok()); - EXPECT_EQ(req.message(), resp.message()); -} - -TEST_F(MockCallbackTest, MockedCallSucceeds) { - CallbackServerContext ctx; - EchoRequest req; - EchoResponse resp; - DefaultReactorTestPeer peer(&ctx); - - req.set_message("ha ha, consider yourself mocked."); - auto* reactor = service_.Echo(&ctx, &req, &resp); - EXPECT_EQ(reactor, peer.reactor()); - EXPECT_TRUE(peer.test_status_set()); - EXPECT_TRUE(peer.test_status().ok()); -} - -TEST_F(MockCallbackTest, MockedCallFails) { - CallbackServerContext ctx; - EchoRequest req; - EchoResponse resp; - DefaultReactorTestPeer peer(&ctx); - - auto* reactor = service_.Echo(&ctx, &req, &resp); - EXPECT_EQ(reactor, peer.reactor()); - EXPECT_TRUE(peer.test_status_set()); - EXPECT_EQ(peer.test_status().error_code(), StatusCode::INVALID_ARGUMENT); -} - -class TestServiceImpl : public EchoTestService::Service { - public: - Status Echo(ServerContext* /*context*/, const EchoRequest* request, - EchoResponse* response) override { - response->set_message(request->message()); - return Status::OK; - } - - Status RequestStream(ServerContext* /*context*/, - ServerReader<EchoRequest>* reader, - EchoResponse* response) override { - EchoRequest request; - TString resp(""); - while (reader->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); - resp.append(request.message()); - } - response->set_message(resp); - return Status::OK; - } - - Status ResponseStream(ServerContext* /*context*/, const EchoRequest* request, - ServerWriter<EchoResponse>* writer) override { - EchoResponse response; - vector<TString> tokens = split(request->message()); - for (const TString& token : tokens) { - response.set_message(token); - writer->Write(response); - } - return Status::OK; - } - - Status BidiStream( - ServerContext* /*context*/, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - EchoRequest request; - EchoResponse response; - while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); - response.set_message(request.message()); - stream->Write(response); - } - return Status::OK; - } - - private: - vector<TString> split(const TString& input) { - TString buff(""); - vector<TString> result; - - for (auto n : input) { - if (n != ' ') { - buff += n; - continue; - } - if (buff.empty()) continue; - result.push_back(buff); - buff = ""; - } - if (!buff.empty()) result.push_back(buff); - - return result; - } -}; - -class MockTest : public ::testing::Test { - protected: - MockTest() {} - - void SetUp() override { - int port = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port; - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - void TearDown() override { server_->Shutdown(); } - - void ResetStub() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - TestServiceImpl service_; -}; - -// Do one real rpc and one mocked one -TEST_F(MockTest, SimpleRpc) { - ResetStub(); - FakeClient client(stub_.get()); - client.DoEcho(); - MockEchoTestServiceStub stub; - EchoResponse resp; - resp.set_message("hello world"); - EXPECT_CALL(stub, Echo(_, _, _)) - .Times(AtLeast(1)) - .WillOnce(DoAll(SetArgPointee<2>(resp), Return(Status::OK))); - client.ResetStub(&stub); - client.DoEcho(); -} - -TEST_F(MockTest, ClientStream) { - ResetStub(); - FakeClient client(stub_.get()); - client.DoRequestStream(); - - MockEchoTestServiceStub stub; - auto w = new MockClientWriter<EchoRequest>(); - EchoResponse resp; - resp.set_message("hello, world"); - - EXPECT_CALL(*w, Write(_, _)).Times(2).WillRepeatedly(Return(true)); - EXPECT_CALL(*w, WritesDone()); - EXPECT_CALL(*w, Finish()).WillOnce(Return(Status::OK)); - - EXPECT_CALL(stub, RequestStreamRaw(_, _)) - .WillOnce(DoAll(SetArgPointee<1>(resp), Return(w))); - client.ResetStub(&stub); - client.DoRequestStream(); -} - -TEST_F(MockTest, ServerStream) { - ResetStub(); - FakeClient client(stub_.get()); - client.DoResponseStream(); - - MockEchoTestServiceStub stub; - auto r = new MockClientReader<EchoResponse>(); - EchoResponse resp1; - resp1.set_message("hello"); - EchoResponse resp2; - resp2.set_message("world"); - - EXPECT_CALL(*r, Read(_)) - .WillOnce(DoAll(SetArgPointee<0>(resp1), Return(true))) - .WillOnce(DoAll(SetArgPointee<0>(resp2), Return(true))) - .WillOnce(Return(false)); - EXPECT_CALL(*r, Finish()).WillOnce(Return(Status::OK)); - - EXPECT_CALL(stub, ResponseStreamRaw(_, _)).WillOnce(Return(r)); - - client.ResetStub(&stub); - client.DoResponseStream(); -} - -ACTION_P(copy, msg) { arg0->set_message(msg->message()); } - -TEST_F(MockTest, BidiStream) { - ResetStub(); - FakeClient client(stub_.get()); - client.DoBidiStream(); - MockEchoTestServiceStub stub; - auto rw = new MockClientReaderWriter<EchoRequest, EchoResponse>(); - EchoRequest msg; - - EXPECT_CALL(*rw, Write(_, _)) - .Times(3) - .WillRepeatedly(DoAll(SaveArg<0>(&msg), Return(true))); - EXPECT_CALL(*rw, Read(_)) - .WillOnce(DoAll(WithArg<0>(copy(&msg)), Return(true))) - .WillOnce(DoAll(WithArg<0>(copy(&msg)), Return(true))) - .WillOnce(DoAll(WithArg<0>(copy(&msg)), Return(true))) - .WillOnce(Return(false)); - EXPECT_CALL(*rw, WritesDone()); - EXPECT_CALL(*rw, Finish()).WillOnce(Return(Status::OK)); - - EXPECT_CALL(stub, BidiStreamRaw(_)).WillOnce(Return(rw)); - client.ResetStub(&stub); - client.DoBidiStream(); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/nonblocking_test.cc b/contrib/libs/grpc/test/cpp/end2end/nonblocking_test.cc deleted file mode 100644 index 392e7de21e..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/nonblocking_test.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <memory> - -#include "y_absl/memory/memory.h" - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/tls.h" -#include "src/core/lib/iomgr/port.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -#ifdef GRPC_POSIX_SOCKET -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET - -#include <gtest/gtest.h> - -#ifdef GRPC_POSIX_SOCKET -// Thread-local variable to so that only polls from this test assert -// non-blocking (not polls from resolver, timer thread, etc), and only when the -// thread is waiting on polls caused by CompletionQueue::AsyncNext (not for -// picking a port or other reasons). -static GPR_THREAD_LOCAL(bool) g_is_nonblocking_poll; - -namespace { - -int maybe_assert_non_blocking_poll(struct pollfd* pfds, nfds_t nfds, - int timeout) { - // Only assert that this poll should have zero timeout if we're in the - // middle of a zero-timeout CQ Next. - if (g_is_nonblocking_poll) { - GPR_ASSERT(timeout == 0); - } - return poll(pfds, nfds, timeout); -} - -} // namespace - -namespace grpc { -namespace testing { -namespace { - -void* tag(int i) { return reinterpret_cast<void*>(static_cast<intptr_t>(i)); } -int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); } - -class NonblockingTest : public ::testing::Test { - protected: - NonblockingTest() {} - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port_; - - // Setup server - BuildAndStartServer(); - } - - bool LoopForTag(void** tag, bool* ok) { - // Temporarily set the thread-local nonblocking poll flag so that the polls - // caused by this loop are indeed sent by the library with zero timeout. - bool orig_val = g_is_nonblocking_poll; - g_is_nonblocking_poll = true; - for (;;) { - auto r = cq_->AsyncNext(tag, ok, gpr_time_0(GPR_CLOCK_REALTIME)); - if (r == CompletionQueue::SHUTDOWN) { - g_is_nonblocking_poll = orig_val; - return false; - } else if (r == CompletionQueue::GOT_EVENT) { - g_is_nonblocking_poll = orig_val; - return true; - } - } - } - - void TearDown() override { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cq_->Shutdown(); - while (LoopForTag(&ignored_tag, &ignored_ok)) { - } - stub_.reset(); - grpc_recycle_unused_port(port_); - } - - void BuildAndStartServer() { - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - grpc::InsecureServerCredentials()); - service_ = - y_absl::make_unique<grpc::testing::EchoTestService::AsyncService>(); - builder.RegisterService(service_.get()); - cq_ = builder.AddCompletionQueue(); - server_ = builder.BuildAndStart(); - } - - void ResetStub() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), grpc::InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - void SendRpc(int num_rpcs) { - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - ServerContext srv_ctx; - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); - - send_request.set_message("hello non-blocking world"); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->PrepareAsyncEcho(&cli_ctx, send_request, cq_.get())); - - response_reader->StartCall(); - response_reader->Finish(&recv_response, &recv_status, tag(4)); - - service_->RequestEcho(&srv_ctx, &recv_request, &response_writer, - cq_.get(), cq_.get(), tag(2)); - - void* got_tag; - bool ok; - EXPECT_TRUE(LoopForTag(&got_tag, &ok)); - EXPECT_TRUE(ok); - EXPECT_EQ(detag(got_tag), 2); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - response_writer.Finish(send_response, Status::OK, tag(3)); - - int tagsum = 0; - int tagprod = 1; - EXPECT_TRUE(LoopForTag(&got_tag, &ok)); - EXPECT_TRUE(ok); - tagsum += detag(got_tag); - tagprod *= detag(got_tag); - - EXPECT_TRUE(LoopForTag(&got_tag, &ok)); - EXPECT_TRUE(ok); - tagsum += detag(got_tag); - tagprod *= detag(got_tag); - - EXPECT_EQ(tagsum, 7); - EXPECT_EQ(tagprod, 12); - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.ok()); - } - } - - std::unique_ptr<ServerCompletionQueue> cq_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::unique_ptr<grpc::testing::EchoTestService::AsyncService> service_; - std::ostringstream server_address_; - int port_; -}; - -TEST_F(NonblockingTest, SimpleRpc) { - ResetStub(); - SendRpc(10); -} - -} // namespace -} // namespace testing -} // namespace grpc - -#endif // GRPC_POSIX_SOCKET - -int main(int argc, char** argv) { -#ifdef GRPC_POSIX_SOCKET - // Override the poll function before anything else can happen - grpc_poll_function = maybe_assert_non_blocking_poll; - - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - - // Start the nonblocking poll thread-local variable as false because the - // thread that issues RPCs starts by picking a port (which has non-zero - // timeout). - g_is_nonblocking_poll = false; - - int ret = RUN_ALL_TESTS(); - - return ret; -#else // GRPC_POSIX_SOCKET - (void)argc; - (void)argv; - return 0; -#endif // GRPC_POSIX_SOCKET -} diff --git a/contrib/libs/grpc/test/cpp/end2end/port_sharing_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/port_sharing_end2end_test.cc deleted file mode 100644 index 96ecc4cc76..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/port_sharing_end2end_test.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <mutex> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/iomgr/port.h" -#include "src/core/lib/iomgr/tcp_server.h" -#include "src/core/lib/security/credentials/credentials.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/core/util/test_tcp_server.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_credentials_provider.h" - -#ifdef GRPC_POSIX_SOCKET_TCP_SERVER - -#include "src/core/lib/iomgr/tcp_posix.h" - -namespace grpc { -namespace testing { -namespace { - -class TestScenario { - public: - TestScenario(bool server_port, bool pending_data, - const TString& creds_type) - : server_has_port(server_port), - queue_pending_data(pending_data), - credentials_type(creds_type) {} - void Log() const; - // server has its own port or not - bool server_has_port; - // whether tcp server should read some data before handoff - bool queue_pending_data; - const TString credentials_type; -}; - -std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { - return out << "TestScenario{server_has_port=" - << (scenario.server_has_port ? "true" : "false") - << ", queue_pending_data=" - << (scenario.queue_pending_data ? "true" : "false") - << ", credentials='" << scenario.credentials_type << "'}"; -} - -void TestScenario::Log() const { - std::ostringstream out; - out << *this; - gpr_log(GPR_ERROR, "%s", out.str().c_str()); -} - -// Set up a test tcp server which is in charge of accepting connections and -// handing off the connections as fds. -class TestTcpServer { - public: - TestTcpServer() - : shutdown_(false), - queue_data_(false), - port_(grpc_pick_unused_port_or_die()) { - std::ostringstream server_address; - server_address << "localhost:" << port_; - address_ = server_address.str(); - test_tcp_server_init(&tcp_server_, &TestTcpServer::OnConnect, this); - GRPC_CLOSURE_INIT(&on_fd_released_, &TestTcpServer::OnFdReleased, this, - grpc_schedule_on_exec_ctx); - } - - ~TestTcpServer() { - running_thread_.join(); - test_tcp_server_destroy(&tcp_server_); - grpc_recycle_unused_port(port_); - } - - // Read some data before handing off the connection. - void SetQueueData() { queue_data_ = true; } - - void Start() { - test_tcp_server_start(&tcp_server_, port_); - gpr_log(GPR_INFO, "Test TCP server started at %s", address_.c_str()); - } - - const TString& address() { return address_; } - - void SetAcceptor( - std::unique_ptr<experimental::ExternalConnectionAcceptor> acceptor) { - connection_acceptor_ = std::move(acceptor); - } - - void Run() { - running_thread_ = std::thread([this]() { - while (true) { - { - std::lock_guard<std::mutex> lock(mu_); - if (shutdown_) { - return; - } - } - test_tcp_server_poll(&tcp_server_, 1); - } - }); - } - - void Shutdown() { - std::lock_guard<std::mutex> lock(mu_); - shutdown_ = true; - } - - static void OnConnect(void* arg, grpc_endpoint* tcp, - grpc_pollset* accepting_pollset, - grpc_tcp_server_acceptor* acceptor) { - auto* self = static_cast<TestTcpServer*>(arg); - self->OnConnect(tcp, accepting_pollset, acceptor); - } - - static void OnFdReleased(void* arg, grpc_error_handle err) { - auto* self = static_cast<TestTcpServer*>(arg); - self->OnFdReleased(err); - } - - private: - void OnConnect(grpc_endpoint* tcp, grpc_pollset* /*accepting_pollset*/, - grpc_tcp_server_acceptor* acceptor) { - TString peer(grpc_endpoint_get_peer(tcp)); - gpr_log(GPR_INFO, "Got incoming connection! from %s", peer.c_str()); - EXPECT_FALSE(acceptor->external_connection); - listener_fd_ = grpc_tcp_server_port_fd( - acceptor->from_server, acceptor->port_index, acceptor->fd_index); - gpr_free(acceptor); - grpc_tcp_destroy_and_release_fd(tcp, &fd_, &on_fd_released_); - } - - void OnFdReleased(grpc_error_handle err) { - EXPECT_EQ(GRPC_ERROR_NONE, err); - experimental::ExternalConnectionAcceptor::NewConnectionParameters p; - p.listener_fd = listener_fd_; - p.fd = fd_; - if (queue_data_) { - char buf[1024]; - ssize_t read_bytes = 0; - while (read_bytes <= 0) { - read_bytes = read(fd_, buf, 1024); - } - Slice data(buf, read_bytes); - p.read_buffer = ByteBuffer(&data, 1); - } - gpr_log(GPR_INFO, "Handing off fd %d with data size %d from listener fd %d", - fd_, static_cast<int>(p.read_buffer.Length()), listener_fd_); - connection_acceptor_->HandleNewConnection(&p); - } - - std::mutex mu_; - bool shutdown_; - - int listener_fd_ = -1; - int fd_ = -1; - bool queue_data_ = false; - - grpc_closure on_fd_released_; - std::thread running_thread_; - int port_ = -1; - TString address_; - std::unique_ptr<experimental::ExternalConnectionAcceptor> - connection_acceptor_; - test_tcp_server tcp_server_; -}; - -class PortSharingEnd2endTest : public ::testing::TestWithParam<TestScenario> { - protected: - PortSharingEnd2endTest() : is_server_started_(false), first_picked_port_(0) { - GetParam().Log(); - } - - void SetUp() override { - if (GetParam().queue_pending_data) { - tcp_server1_.SetQueueData(); - tcp_server2_.SetQueueData(); - } - tcp_server1_.Start(); - tcp_server2_.Start(); - ServerBuilder builder; - if (GetParam().server_has_port) { - int port = grpc_pick_unused_port_or_die(); - first_picked_port_ = port; - server_address_ << "localhost:" << port; - auto creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - builder.AddListeningPort(server_address_.str(), creds); - gpr_log(GPR_INFO, "gRPC server listening on %s", - server_address_.str().c_str()); - } - auto server_creds = GetCredentialsProvider()->GetServerCredentials( - GetParam().credentials_type); - auto acceptor1 = builder.experimental().AddExternalConnectionAcceptor( - ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, - server_creds); - tcp_server1_.SetAcceptor(std::move(acceptor1)); - auto acceptor2 = builder.experimental().AddExternalConnectionAcceptor( - ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD, - server_creds); - tcp_server2_.SetAcceptor(std::move(acceptor2)); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - is_server_started_ = true; - - tcp_server1_.Run(); - tcp_server2_.Run(); - } - - void TearDown() override { - tcp_server1_.Shutdown(); - tcp_server2_.Shutdown(); - if (is_server_started_) { - server_->Shutdown(); - } - if (first_picked_port_ > 0) { - grpc_recycle_unused_port(first_picked_port_); - } - } - - void ResetStubs() { - EXPECT_TRUE(is_server_started_); - ChannelArguments args; - args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); - auto channel_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &args); - channel_handoff1_ = - CreateCustomChannel(tcp_server1_.address(), channel_creds, args); - stub_handoff1_ = EchoTestService::NewStub(channel_handoff1_); - channel_handoff2_ = - CreateCustomChannel(tcp_server2_.address(), channel_creds, args); - stub_handoff2_ = EchoTestService::NewStub(channel_handoff2_); - if (GetParam().server_has_port) { - ChannelArguments direct_args; - direct_args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1); - auto direct_creds = GetCredentialsProvider()->GetChannelCredentials( - GetParam().credentials_type, &direct_args); - channel_direct_ = - CreateCustomChannel(server_address_.str(), direct_creds, direct_args); - stub_direct_ = EchoTestService::NewStub(channel_direct_); - } - } - - bool is_server_started_; - // channel/stub to the test tcp server, the connection will be handed to the - // grpc server. - std::shared_ptr<Channel> channel_handoff1_; - std::unique_ptr<EchoTestService::Stub> stub_handoff1_; - std::shared_ptr<Channel> channel_handoff2_; - std::unique_ptr<EchoTestService::Stub> stub_handoff2_; - // channel/stub to talk to the grpc server directly, if applicable. - std::shared_ptr<Channel> channel_direct_; - std::unique_ptr<EchoTestService::Stub> stub_direct_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - TestServiceImpl service_; - TestTcpServer tcp_server1_; - TestTcpServer tcp_server2_; - int first_picked_port_; -}; - -void SendRpc(EchoTestService::Stub* stub, int num_rpcs) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello hello hello hello"); - - for (int i = 0; i < num_rpcs; ++i) { - ClientContext context; - Status s = stub->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - } -} - -std::vector<TestScenario> CreateTestScenarios() { - std::vector<TestScenario> scenarios; - std::vector<TString> credentials_types; - -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - - credentials_types = GetCredentialsProvider()->GetSecureCredentialsTypeList(); - // Only allow insecure credentials type when it is registered with the - // provider. User may create providers that do not have insecure. - if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, - nullptr) != nullptr) { - credentials_types.push_back(kInsecureCredentialsType); - } - - GPR_ASSERT(!credentials_types.empty()); - for (const auto& cred : credentials_types) { - for (auto server_has_port : {true, false}) { - for (auto queue_pending_data : {true, false}) { - scenarios.emplace_back(server_has_port, queue_pending_data, cred); - } - } - } - return scenarios; -} - -TEST_P(PortSharingEnd2endTest, HandoffAndDirectCalls) { - ResetStubs(); - SendRpc(stub_handoff1_.get(), 5); - if (GetParam().server_has_port) { - SendRpc(stub_direct_.get(), 5); - } -} - -TEST_P(PortSharingEnd2endTest, MultipleHandoff) { - for (int i = 0; i < 3; i++) { - ResetStubs(); - SendRpc(stub_handoff2_.get(), 1); - } -} - -TEST_P(PortSharingEnd2endTest, TwoHandoffPorts) { - for (int i = 0; i < 3; i++) { - ResetStubs(); - SendRpc(stub_handoff1_.get(), 5); - SendRpc(stub_handoff2_.get(), 5); - } -} - -INSTANTIATE_TEST_SUITE_P(PortSharingEnd2end, PortSharingEnd2endTest, - ::testing::ValuesIn(CreateTestScenarios())); - -} // namespace -} // namespace testing -} // namespace grpc - -#endif // GRPC_POSIX_SOCKET_TCP_SERVER - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/proto_server_reflection_test.cc b/contrib/libs/grpc/test/cpp/end2end/proto_server_reflection_test.cc deleted file mode 100644 index b9a0c6e8b9..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/proto_server_reflection_test.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/proto_server_reflection_plugin.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/proto_reflection_descriptor_database.h" - -namespace grpc { -namespace testing { - -class ProtoServerReflectionTest : public ::testing::Test { - public: - ProtoServerReflectionTest() {} - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - ref_desc_pool_ = protobuf::DescriptorPool::generated_pool(); - - ServerBuilder builder; - TString server_address = "localhost:" + to_string(port_); - builder.AddListeningPort(server_address, InsecureServerCredentials()); - server_ = builder.BuildAndStart(); - } - - void ResetStub() { - string target = "dns:localhost:" + to_string(port_); - std::shared_ptr<Channel> channel = - grpc::CreateChannel(target, InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - desc_db_ = y_absl::make_unique<ProtoReflectionDescriptorDatabase>(channel); - desc_pool_ = y_absl::make_unique<protobuf::DescriptorPool>(desc_db_.get()); - } - - string to_string(const int number) { - std::stringstream strs; - strs << number; - return strs.str(); - } - - void CompareService(const TString& service) { - const protobuf::ServiceDescriptor* service_desc = - desc_pool_->FindServiceByName(service); - const protobuf::ServiceDescriptor* ref_service_desc = - ref_desc_pool_->FindServiceByName(service); - EXPECT_TRUE(service_desc != nullptr); - EXPECT_TRUE(ref_service_desc != nullptr); - EXPECT_EQ(service_desc->DebugString(), ref_service_desc->DebugString()); - - const protobuf::FileDescriptor* file_desc = service_desc->file(); - if (known_files_.find(file_desc->package() + "/" + file_desc->name()) != - known_files_.end()) { - EXPECT_EQ(file_desc->DebugString(), - ref_service_desc->file()->DebugString()); - known_files_.insert(file_desc->package() + "/" + file_desc->name()); - } - - for (int i = 0; i < service_desc->method_count(); ++i) { - CompareMethod(service_desc->method(i)->full_name()); - } - } - - void CompareMethod(const TString& method) { - const protobuf::MethodDescriptor* method_desc = - desc_pool_->FindMethodByName(method); - const protobuf::MethodDescriptor* ref_method_desc = - ref_desc_pool_->FindMethodByName(method); - EXPECT_TRUE(method_desc != nullptr); - EXPECT_TRUE(ref_method_desc != nullptr); - EXPECT_EQ(method_desc->DebugString(), ref_method_desc->DebugString()); - - CompareType(method_desc->input_type()->full_name()); - CompareType(method_desc->output_type()->full_name()); - } - - void CompareType(const TString& type) { - if (known_types_.find(type) != known_types_.end()) { - return; - } - - const protobuf::Descriptor* desc = desc_pool_->FindMessageTypeByName(type); - const protobuf::Descriptor* ref_desc = - ref_desc_pool_->FindMessageTypeByName(type); - EXPECT_TRUE(desc != nullptr); - EXPECT_TRUE(ref_desc != nullptr); - EXPECT_EQ(desc->DebugString(), ref_desc->DebugString()); - } - - protected: - std::unique_ptr<Server> server_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<ProtoReflectionDescriptorDatabase> desc_db_; - std::unique_ptr<protobuf::DescriptorPool> desc_pool_; - std::unordered_set<string> known_files_; - std::unordered_set<string> known_types_; - const protobuf::DescriptorPool* ref_desc_pool_; - int port_; - reflection::ProtoServerReflectionPlugin plugin_; -}; - -TEST_F(ProtoServerReflectionTest, CheckResponseWithLocalDescriptorPool) { - ResetStub(); - - std::vector<TString> services; - desc_db_->GetServices(&services); - // The service list has at least one service (reflection servcie). - EXPECT_TRUE(!services.empty()); - - for (auto it = services.begin(); it != services.end(); ++it) { - CompareService(*it); - } -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/raw_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/raw_end2end_test.cc deleted file mode 100644 index e0c29cd61b..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/raw_end2end_test.cc +++ /dev/null @@ -1,370 +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. - * - */ - -#include <cinttypes> -#include <memory> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/port.h" -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/byte_buffer_proto_helper.h" -#include "test/cpp/util/string_ref_helper.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { - -namespace { - -void* tag(int i) { return reinterpret_cast<void*>(i); } -int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); } - -class Verifier { - public: - Verifier() {} - - // Expect sets the expected ok value for a specific tag - Verifier& Expect(int i, bool expect_ok) { - expectations_[tag(i)] = expect_ok; - return *this; - } - - // Next waits for 1 async tag to complete, checks its - // expectations, and returns the tag - int Next(CompletionQueue* cq, bool ignore_ok) { - bool ok; - void* got_tag; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - GotTag(got_tag, ok, ignore_ok); - return detag(got_tag); - } - - // Verify keeps calling Next until all currently set - // expected tags are complete - void Verify(CompletionQueue* cq) { - GPR_ASSERT(!expectations_.empty()); - while (!expectations_.empty()) { - Next(cq, false); - } - } - - private: - void GotTag(void* got_tag, bool ok, bool ignore_ok) { - auto it = expectations_.find(got_tag); - if (it != expectations_.end()) { - if (!ignore_ok) { - EXPECT_EQ(it->second, ok); - } - expectations_.erase(it); - } - } - - std::map<void*, bool> expectations_; -}; - -class RawEnd2EndTest : public ::testing::Test { - protected: - RawEnd2EndTest() {} - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port_; - } - - void TearDown() override { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cq_->Shutdown(); - while (cq_->Next(&ignored_tag, &ignored_ok)) { - } - stub_.reset(); - grpc_recycle_unused_port(port_); - } - - template <typename ServerType> - std::unique_ptr<ServerType> BuildAndStartServer() { - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - grpc::InsecureServerCredentials()); - std::unique_ptr<ServerType> service(new ServerType()); - builder.RegisterService(service.get()); - cq_ = builder.AddCompletionQueue(); - server_ = builder.BuildAndStart(); - return service; - } - - void ResetStub() { - ChannelArguments args; - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), grpc::InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - std::unique_ptr<ServerCompletionQueue> cq_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - int port_; - - // For the client application to populate and send to server. - EchoRequest send_request_; - ::grpc::ByteBuffer send_request_buffer_; - - // For the server to give to gRPC to be populated by incoming request - // from client. - EchoRequest recv_request_; - ::grpc::ByteBuffer recv_request_buffer_; - - // For the server application to populate and send back to client. - EchoResponse send_response_; - ::grpc::ByteBuffer send_response_buffer_; - - // For the client to give to gRPC to be populated by incoming response - // from server. - EchoResponse recv_response_; - ::grpc::ByteBuffer recv_response_buffer_; - Status recv_status_; - - // Both sides need contexts - ClientContext cli_ctx_; - ServerContext srv_ctx_; -}; - -// Regular Async, both peers use proto -TEST_F(RawEnd2EndTest, PureAsyncService) { - typedef grpc::testing::EchoTestService::AsyncService SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); - grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx_); - - send_request_.set_message("hello"); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get())); - service->RequestEcho(&srv_ctx_, &recv_request_, &response_writer, cq_.get(), - cq_.get(), tag(2)); - response_reader->Finish(&recv_response_, &recv_status_, tag(4)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - send_response_.set_message(recv_request_.message()); - response_writer.Finish(send_response_, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(send_response_.message(), recv_response_.message()); - EXPECT_TRUE(recv_status_.ok()); -} - -// Client uses proto, server uses generic codegen, unary -TEST_F(RawEnd2EndTest, RawServerUnary) { - typedef grpc::testing::EchoTestService::WithRawMethod_Echo< - grpc::testing::EchoTestService::Service> - SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); - grpc::GenericServerAsyncResponseWriter response_writer(&srv_ctx_); - - send_request_.set_message("hello unary"); - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( - stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get())); - service->RequestEcho(&srv_ctx_, &recv_request_buffer_, &response_writer, - cq_.get(), cq_.get(), tag(2)); - response_reader->Finish(&recv_response_, &recv_status_, tag(4)); - Verifier().Expect(2, true).Verify(cq_.get()); - EXPECT_TRUE(ParseFromByteBuffer(&recv_request_buffer_, &recv_request_)); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - send_response_.set_message(recv_request_.message()); - EXPECT_TRUE( - SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_)); - response_writer.Finish(send_response_buffer_, Status::OK, tag(3)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - - EXPECT_EQ(send_response_.message(), recv_response_.message()); - EXPECT_TRUE(recv_status_.ok()); -} - -// Client uses proto, server uses generic codegen, client streaming -TEST_F(RawEnd2EndTest, RawServerClientStreaming) { - typedef grpc::testing::EchoTestService::WithRawMethod_RequestStream< - grpc::testing::EchoTestService::Service> - SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); - - grpc::GenericServerAsyncReader srv_stream(&srv_ctx_); - - send_request_.set_message("hello client streaming"); - std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( - stub_->AsyncRequestStream(&cli_ctx_, &recv_response_, cq_.get(), tag(1))); - - service->RequestRequestStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - Verifier().Expect(2, true).Expect(1, true).Verify(cq_.get()); - - cli_stream->Write(send_request_, tag(3)); - srv_stream.Read(&recv_request_buffer_, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - ParseFromByteBuffer(&recv_request_buffer_, &recv_request_); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - - cli_stream->Write(send_request_, tag(5)); - srv_stream.Read(&recv_request_buffer_, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - - ParseFromByteBuffer(&recv_request_buffer_, &recv_request_); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - cli_stream->WritesDone(tag(7)); - srv_stream.Read(&recv_request_buffer_, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - ParseFromByteBuffer(&recv_request_buffer_, &recv_request_); - send_response_.set_message(recv_request_.message()); - SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_); - srv_stream.Finish(send_response_buffer_, Status::OK, tag(9)); - cli_stream->Finish(&recv_status_, tag(10)); - Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get()); - - EXPECT_EQ(send_response_.message(), recv_response_.message()); - EXPECT_TRUE(recv_status_.ok()); -} - -// Client uses proto, server uses generic codegen, server streaming -TEST_F(RawEnd2EndTest, RawServerServerStreaming) { - typedef grpc::testing::EchoTestService::WithRawMethod_ResponseStream< - grpc::testing::EchoTestService::Service> - SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); - grpc::GenericServerAsyncWriter srv_stream(&srv_ctx_); - - send_request_.set_message("hello server streaming"); - std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( - stub_->AsyncResponseStream(&cli_ctx_, send_request_, cq_.get(), tag(1))); - - service->RequestResponseStream(&srv_ctx_, &recv_request_buffer_, &srv_stream, - cq_.get(), cq_.get(), tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - ParseFromByteBuffer(&recv_request_buffer_, &recv_request_); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - - send_response_.set_message(recv_request_.message()); - SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_); - srv_stream.Write(send_response_buffer_, tag(3)); - cli_stream->Read(&recv_response_, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - EXPECT_EQ(send_response_.message(), recv_response_.message()); - - srv_stream.Write(send_response_buffer_, tag(5)); - cli_stream->Read(&recv_response_, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_response_.message(), recv_response_.message()); - - srv_stream.Finish(Status::OK, tag(7)); - cli_stream->Read(&recv_response_, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - cli_stream->Finish(&recv_status_, tag(9)); - Verifier().Expect(9, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status_.ok()); -} - -// Client uses proto, server uses generic codegen, bidi streaming -TEST_F(RawEnd2EndTest, RawServerBidiStreaming) { - typedef grpc::testing::EchoTestService::WithRawMethod_BidiStream< - grpc::testing::EchoTestService::Service> - SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); - - grpc::GenericServerAsyncReaderWriter srv_stream(&srv_ctx_); - - send_request_.set_message("hello bidi streaming"); - std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> - cli_stream(stub_->AsyncBidiStream(&cli_ctx_, cq_.get(), tag(1))); - - service->RequestBidiStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(), - tag(2)); - - Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get()); - - cli_stream->Write(send_request_, tag(3)); - srv_stream.Read(&recv_request_buffer_, tag(4)); - Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get()); - ParseFromByteBuffer(&recv_request_buffer_, &recv_request_); - EXPECT_EQ(send_request_.message(), recv_request_.message()); - - send_response_.set_message(recv_request_.message()); - SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_); - srv_stream.Write(send_response_buffer_, tag(5)); - cli_stream->Read(&recv_response_, tag(6)); - Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get()); - EXPECT_EQ(send_response_.message(), recv_response_.message()); - - cli_stream->WritesDone(tag(7)); - srv_stream.Read(&recv_request_buffer_, tag(8)); - Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get()); - - srv_stream.Finish(Status::OK, tag(9)); - cli_stream->Finish(&recv_status_, tag(10)); - Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get()); - - EXPECT_TRUE(recv_status_.ok()); -} - -// Testing that this pattern compiles -TEST_F(RawEnd2EndTest, CompileTest) { - typedef grpc::testing::EchoTestService::WithRawMethod_Echo< - grpc::testing::EchoTestService::AsyncService> - SType; - ResetStub(); - auto service = BuildAndStartServer<SType>(); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - // Change the backup poll interval from 5s to 100ms to speed up the - // ReconnectChannel test - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/rls_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/rls_end2end_test.cc deleted file mode 100644 index d383761a29..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/rls_end2end_test.cc +++ /dev/null @@ -1,1458 +0,0 @@ -// -// Copyright 2020 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. -// - -// FIXME: add tests: -// - cache eviction via cleanup timer (based on age) -// - RLS channel is down; wait_for_ready request is sent and RLS request fails -// and goes into backoff; RLS channel comes back up before backoff timer -// fires; request is processed at that point - -#include <deque> -#include <map> -#include <thread> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_join.h" -#include "y_absl/types/optional.h" - -#include <grpcpp/channel.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/support/channel_arguments.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" -#include "src/core/lib/address_utils/parse_address.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/core/lib/uri/uri_parser.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/cpp/server/secure_server_credentials.h" -#include "src/proto/grpc/lookup/v1/rls.grpc.pb.h" -#include "src/proto/grpc/lookup/v1/rls.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/resolve_localhost_ip46.h" -#include "test/core/util/test_config.h" -#include "test/core/util/test_lb_policies.h" -#include "test/cpp/end2end/counted_service.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/test_config.h" - -using ::grpc::lookup::v1::RouteLookupRequest; -using ::grpc::lookup::v1::RouteLookupResponse; - -namespace grpc { -namespace testing { -namespace { - -const char* kServerName = "test.google.fr"; -const char* kRequestMessage = "Live long and prosper."; - -const char* kCallCredsMdKey = "call_cred_name"; -const char* kCallCredsMdValue = "call_cred_value"; - -const char* kTestKey = "test_key"; -const char* kTestValue = "test_value"; -const char* kHostKey = "host_key"; -const char* kServiceKey = "service_key"; -const char* kServiceValue = "grpc.testing.EchoTestService"; -const char* kMethodKey = "method_key"; -const char* kMethodValue = "Echo"; -const char* kConstantKey = "constant_key"; -const char* kConstantValue = "constant_value"; - -using BackendService = CountedService<TestServiceImpl>; -using RlsService = - CountedService<grpc::lookup::v1::RouteLookupService::Service>; - -class RlsServiceImpl : public RlsService { - public: - ::grpc::Status RouteLookup(::grpc::ServerContext* context, - const RouteLookupRequest* request, - RouteLookupResponse* response) override { - gpr_log(GPR_INFO, "RLS: Received request: %s", - request->DebugString().c_str()); - // RLS server should see call creds. - EXPECT_THAT(context->client_metadata(), - ::testing::Contains( - ::testing::Pair(kCallCredsMdKey, kCallCredsMdValue))); - IncreaseRequestCount(); - EXPECT_EQ(request->target_type(), "grpc"); - // See if we have a configured response for this request. - ResponseData res; - { - grpc::internal::MutexLock lock(&mu_); - auto it = responses_.find(*request); - if (it == responses_.end()) { - gpr_log(GPR_INFO, "RLS: no matching request, returning INTERNAL"); - unmatched_requests_.push_back(*request); - return Status(StatusCode::INTERNAL, "no response entry"); - } - res = it->second; - } - // Configured response found, so use it. - if (res.response_delay > 0) { - gpr_sleep_until( - grpc_timeout_milliseconds_to_deadline(res.response_delay)); - } - IncreaseResponseCount(); - *response = res.response; - gpr_log(GPR_INFO, "RLS: returning configured response: %s", - response->DebugString().c_str()); - return Status::OK; - } - - void Start() {} - - void Shutdown() {} - - void SetResponse(RouteLookupRequest request, RouteLookupResponse response, - grpc_millis response_delay = 0) { - grpc::internal::MutexLock lock(&mu_); - responses_[std::move(request)] = {std::move(response), response_delay}; - } - - void RemoveResponse(const RouteLookupRequest& request) { - grpc::internal::MutexLock lock(&mu_); - responses_.erase(request); - } - - std::vector<RouteLookupRequest> GetUnmatchedRequests() { - grpc::internal::MutexLock lock(&mu_); - return std::move(unmatched_requests_); - } - - private: - // Sorting thunk for RouteLookupRequest. - struct RlsRequestLessThan { - bool operator()(const RouteLookupRequest& req1, - const RouteLookupRequest& req2) const { - std::map<y_absl::string_view, y_absl::string_view> key_map1( - req1.key_map().begin(), req1.key_map().end()); - std::map<y_absl::string_view, y_absl::string_view> key_map2( - req2.key_map().begin(), req2.key_map().end()); - if (key_map1 < key_map2) return true; - if (req1.reason() < req2.reason()) return true; - if (req1.stale_header_data() < req2.stale_header_data()) return true; - return false; - } - }; - - struct ResponseData { - RouteLookupResponse response; - grpc_millis response_delay; - }; - - grpc::internal::Mutex mu_; - std::map<RouteLookupRequest, ResponseData, RlsRequestLessThan> responses_ - Y_ABSL_GUARDED_BY(&mu_); - std::vector<RouteLookupRequest> unmatched_requests_ Y_ABSL_GUARDED_BY(&mu_); -}; - -// Subclass of TestServiceImpl that increments a request counter for -// every call to the Echo Rpc. -class MyTestServiceImpl : public BackendService { - public: - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - // Backend should see call creds. - EXPECT_THAT(context->client_metadata(), - ::testing::Contains( - ::testing::Pair(kCallCredsMdKey, kCallCredsMdValue))); - IncreaseRequestCount(); - auto client_metadata = context->client_metadata(); - auto range = client_metadata.equal_range("X-Google-RLS-Data"); - { - grpc::internal::MutexLock lock(&mu_); - for (auto it = range.first; it != range.second; ++it) { - rls_header_data_.insert( - TString(it->second.begin(), it->second.length())); - } - } - IncreaseResponseCount(); - return TestServiceImpl::Echo(context, request, response); - } - - std::set<TString> rls_data() { - grpc::internal::MutexLock lock(&mu_); - return std::move(rls_header_data_); - } - - void Start() {} - - void Shutdown() {} - - private: - grpc::internal::Mutex mu_; - std::set<TString> rls_header_data_ Y_ABSL_GUARDED_BY(&mu_); -}; - -class FakeResolverResponseGeneratorWrapper { - public: - FakeResolverResponseGeneratorWrapper() - : response_generator_(grpc_core::MakeRefCounted< - grpc_core::FakeResolverResponseGenerator>()) {} - - void SetNextResolution(y_absl::string_view service_config_json) { - grpc_core::ExecCtx exec_ctx; - response_generator_->SetResponse(BuildFakeResults(service_config_json)); - } - - grpc_core::FakeResolverResponseGenerator* Get() const { - return response_generator_.get(); - } - - private: - static grpc_core::Resolver::Result BuildFakeResults( - y_absl::string_view service_config_json) { - grpc_core::Resolver::Result result; - result.service_config_error = GRPC_ERROR_NONE; - result.service_config = grpc_core::ServiceConfig::Create( - result.args, service_config_json, &result.service_config_error); - EXPECT_EQ(result.service_config_error, GRPC_ERROR_NONE) - << "JSON: " << service_config_json - << "Error: " << grpc_error_std_string(result.service_config_error); - EXPECT_NE(result.service_config, nullptr); - return result; - } - - grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> - response_generator_; -}; - -class RlsEnd2endTest : public ::testing::Test { - protected: - static void SetUpTestSuite() { - gpr_setenv("GRPC_EXPERIMENTAL_ENABLE_RLS_LB_POLICY", "true"); - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - grpc_init(); - grpc_core::RegisterFixedAddressLoadBalancingPolicy(); - } - - static void TearDownTestSuite() { - grpc_shutdown_blocking(); - gpr_unsetenv("GRPC_EXPERIMENTAL_ENABLE_RLS_LB_POLICY"); - } - - void SetUp() override { - bool localhost_resolves_to_ipv4 = false; - bool localhost_resolves_to_ipv6 = false; - grpc_core::LocalhostResolves(&localhost_resolves_to_ipv4, - &localhost_resolves_to_ipv6); - ipv6_only_ = !localhost_resolves_to_ipv4 && localhost_resolves_to_ipv6; - rls_server_ = y_absl::make_unique<ServerThread<RlsServiceImpl>>("rls"); - rls_server_->Start(); - resolver_response_generator_ = - y_absl::make_unique<FakeResolverResponseGeneratorWrapper>(); - ResetStub(); - } - - void TearDown() override { - ShutdownBackends(); - rls_server_->Shutdown(); - } - - void ResetStub(const char* expected_authority = kServerName) { - ChannelArguments args; - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - resolver_response_generator_->Get()); - args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_authority); - grpc_channel_credentials* channel_creds = - grpc_fake_transport_security_credentials_create(); - grpc_call_credentials* call_creds = grpc_md_only_test_credentials_create( - kCallCredsMdKey, kCallCredsMdValue, false); - auto creds = std::make_shared<SecureChannelCredentials>( - grpc_composite_channel_credentials_create(channel_creds, call_creds, - nullptr)); - call_creds->Unref(); - channel_creds->Unref(); - channel_ = ::grpc::CreateCustomChannel( - y_absl::StrCat("fake:///", kServerName).c_str(), std::move(creds), args); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - void ShutdownBackends() { - for (auto& server : backends_) { - server->Shutdown(); - } - } - - void StartBackends(size_t num_servers) { - backends_.clear(); - for (size_t i = 0; i < num_servers; ++i) { - backends_.push_back( - y_absl::make_unique<ServerThread<MyTestServiceImpl>>("backend")); - backends_.back()->Start(); - } - } - - TString TargetStringForPort(int port) { - if (ipv6_only_) return y_absl::StrCat("ipv6:[::1]:", port); - return y_absl::StrCat("ipv4:127.0.0.1:", port); - } - - static RouteLookupRequest BuildRlsRequest( - std::map<TString, TString> key, - RouteLookupRequest::Reason reason = RouteLookupRequest::REASON_MISS, - const char* stale_header_data = "") { - RouteLookupRequest request; - request.set_target_type("grpc"); - request.mutable_key_map()->insert(key.begin(), key.end()); - request.set_reason(reason); - request.set_stale_header_data(stale_header_data); - return request; - } - - static RouteLookupResponse BuildRlsResponse(std::vector<TString> targets, - const char* header_data = "") { - RouteLookupResponse response; - response.mutable_targets()->Add(targets.begin(), targets.end()); - response.set_header_data(header_data); - return response; - } - - struct RpcOptions { - int timeout_ms = 1000; - bool wait_for_ready = false; - std::vector<std::pair<TString, TString>> metadata; - - RpcOptions() {} - - RpcOptions& set_timeout_ms(int rpc_timeout_ms) { - timeout_ms = rpc_timeout_ms; - return *this; - } - - RpcOptions& set_wait_for_ready(bool rpc_wait_for_ready) { - wait_for_ready = rpc_wait_for_ready; - return *this; - } - - RpcOptions& set_metadata( - std::vector<std::pair<TString, TString>> rpc_metadata) { - metadata = std::move(rpc_metadata); - return *this; - } - - // Populates context. - void SetupRpc(ClientContext* context) const { - for (const auto& item : metadata) { - context->AddMetadata(item.first, item.second); - } - if (timeout_ms != 0) { - context->set_deadline( - grpc_timeout_milliseconds_to_deadline(timeout_ms)); - } - if (wait_for_ready) context->set_wait_for_ready(true); - } - }; - - Status SendRpc(const RpcOptions& rpc_options = RpcOptions(), - EchoResponse* response = nullptr) { - EchoResponse local_response; - if (response == nullptr) response = &local_response; - ClientContext context; - rpc_options.SetupRpc(&context); - EchoRequest request; - request.set_message(kRequestMessage); - return stub_->Echo(&context, request, response); - } - - void CheckRpcSendOk(const grpc_core::DebugLocation& location, - const RpcOptions& rpc_options = RpcOptions()) { - EchoResponse response; - Status status = SendRpc(rpc_options, &response); - ASSERT_TRUE(status.ok()) << location.file() << ":" << location.line() - << ": RPC failed: " << status.error_code() << ": " - << status.error_message(); - EXPECT_EQ(response.message(), kRequestMessage) - << location.file() << ":" << location.line(); - } - - void CheckRpcSendFailure(const grpc_core::DebugLocation& location, - const RpcOptions& rpc_options = RpcOptions()) { - Status status = SendRpc(rpc_options); - ASSERT_FALSE(status.ok()) << location.file() << ":" << location.line(); - } - - class ServiceConfigBuilder { - public: - explicit ServiceConfigBuilder(int rls_server_port) - : rls_server_port_(rls_server_port) {} - - ServiceConfigBuilder& set_lookup_service_timeout(grpc_millis timeout) { - lookup_service_timeout_ = timeout * grpc_test_slowdown_factor(); - return *this; - } - - ServiceConfigBuilder& set_default_target(TString default_target) { - default_target_ = std::move(default_target); - return *this; - } - - ServiceConfigBuilder& set_max_age(grpc_millis max_age) { - max_age_ = max_age * grpc_test_slowdown_factor(); - return *this; - } - - ServiceConfigBuilder& set_stale_age(grpc_millis stale_age) { - stale_age_ = stale_age * grpc_test_slowdown_factor(); - return *this; - } - - ServiceConfigBuilder& set_cache_size_bytes(int64_t size) { - cache_size_bytes_ = size; - return *this; - } - - ServiceConfigBuilder& AddKeyBuilder(y_absl::string_view key_builder) { - key_builders_.push_back(y_absl::StrCat("{", key_builder, "}")); - return *this; - } - - TString Build() { - // First build parts of routeLookupConfig. - std::vector<TString> route_lookup_config_parts; - route_lookup_config_parts.push_back(y_absl::StrFormat( - " \"lookupService\":\"localhost:%d\"", rls_server_port_)); - if (lookup_service_timeout_ > 0) { - route_lookup_config_parts.push_back(y_absl::StrFormat( - " \"lookupServiceTimeout\":\"%d.%09ds\"", - lookup_service_timeout_ / 1000, lookup_service_timeout_ % 1000)); - } - if (!default_target_.empty()) { - route_lookup_config_parts.push_back(y_absl::StrFormat( - " \"defaultTarget\":\"%s\"", default_target_)); - } - route_lookup_config_parts.push_back(y_absl::StrFormat( - " \"cacheSizeBytes\":%" PRId64, cache_size_bytes_)); - if (max_age_ > 0) { - route_lookup_config_parts.push_back( - y_absl::StrFormat(" \"maxAge\":\"%d.%09ds\"", max_age_ / 1000, - max_age_ % 1000)); - } - if (stale_age_ > 0) { - route_lookup_config_parts.push_back( - y_absl::StrFormat(" \"staleAge\":\"%d.%09ds\"", - stale_age_ / 1000, stale_age_ % 1000)); - } - if (!key_builders_.empty()) { - route_lookup_config_parts.push_back( - y_absl::StrFormat(" \"grpcKeybuilders\":[%s]", - y_absl::StrJoin(key_builders_, ","))); - } - // Now build parts of RLS LB policy config. - std::vector<TString> rls_config_parts; - if (!route_lookup_config_parts.empty()) { - rls_config_parts.push_back(y_absl::StrCat( - " \"routeLookupConfig\":{", - y_absl::StrJoin(route_lookup_config_parts, ","), " }")); - } - rls_config_parts.push_back( - " \"childPolicy\":[{" - " \"fixed_address_lb\":{}\n" - " }],\n" - " \"childPolicyConfigTargetFieldName\":\"address\"\n"); - // Put it all together. - return y_absl::StrCat( - "{" - " \"loadBalancingConfig\":[{" - " \"rls\":{", - y_absl::StrJoin(rls_config_parts, ","), - " }" - " }]" - "}"); - } - - private: - int rls_server_port_; - grpc_millis lookup_service_timeout_ = 0; - TString default_target_; - grpc_millis max_age_ = 0; - grpc_millis stale_age_ = 0; - int64_t cache_size_bytes_ = 10485760; - std::vector<TString> key_builders_; - }; - - ServiceConfigBuilder MakeServiceConfigBuilder() { - return ServiceConfigBuilder(rls_server_->port_); - } - - void SetNextResolution(y_absl::string_view service_config_json) { - resolver_response_generator_->SetNextResolution(service_config_json); - } - - template <typename T> - struct ServerThread { - template <typename... Args> - explicit ServerThread(const grpc::string& type, Args&&... args) - : port_(grpc_pick_unused_port_or_die()), - type_(type), - service_(std::forward<Args>(args)...) {} - - void Start() { - gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_); - GPR_ASSERT(!running_); - running_ = true; - service_.Start(); - grpc::internal::Mutex mu; - // We need to acquire the lock here in order to prevent the notify_one - // by ServerThread::Serve from firing before the wait below is hit. - grpc::internal::MutexLock lock(&mu); - grpc::internal::CondVar cond; - thread_ = y_absl::make_unique<std::thread>( - std::bind(&ServerThread::Serve, this, &mu, &cond)); - cond.Wait(&mu); - gpr_log(GPR_INFO, "%s server startup complete", type_.c_str()); - } - - void Serve(grpc::internal::Mutex* mu, grpc::internal::CondVar* cond) { - // We need to acquire the lock here in order to prevent the notify_one - // below from firing before its corresponding wait is executed. - grpc::internal::MutexLock lock(mu); - ServerBuilder builder; - auto creds = std::make_shared<SecureServerCredentials>( - grpc_fake_transport_security_server_credentials_create()); - builder.AddListeningPort(y_absl::StrCat("localhost:", port_), - std::move(creds)); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - cond->Signal(); - } - - void Shutdown() { - if (!running_) return; - gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str()); - service_.Shutdown(); - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - thread_->join(); - gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str()); - running_ = false; - } - - const int port_; - grpc::string type_; - T service_; - std::unique_ptr<Server> server_; - std::unique_ptr<std::thread> thread_; - bool running_ = false; - }; - - bool ipv6_only_; - std::vector<std::unique_ptr<ServerThread<MyTestServiceImpl>>> backends_; - std::unique_ptr<ServerThread<RlsServiceImpl>> rls_server_; - std::unique_ptr<FakeResolverResponseGeneratorWrapper> - resolver_response_generator_; - std::shared_ptr<grpc::Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; -}; - -TEST_F(RlsEnd2endTest, Basic) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - // No RLS header seen by the backend, since the RLS response didn't set any. - EXPECT_THAT(backends_[0]->service_.rls_data(), ::testing::ElementsAre()); -} - -TEST_F(RlsEnd2endTest, DuplicateHeadersAreMerged) { - const char* kTestValue2 = "test_value_2"; - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, y_absl::StrCat(kTestValue, ",", kTestValue2)}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Same header present twice in the request. Values should be merged. - CheckRpcSendOk( - DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}, {"key1", kTestValue2}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, SecondHeaderUsed) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\", \"key2\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key2", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, MultipleHeaderKeys) { - const char* kTestKey2 = "test_key_2"; - const char* kTestValue2 = "test_value_2"; - StartBackends(1); - SetNextResolution(MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat( - "\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }," - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key2\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey, kTestKey2)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({ - {kTestKey, kTestValue}, - {kTestKey2, kTestValue2}, - }), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk( - DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}, {"key2", kTestValue2}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - // No RLS header seen by the backend, since the RLS response didn't set any. - EXPECT_THAT(backends_[0]->service_.rls_data(), ::testing::ElementsAre()); -} - -TEST_F(RlsEnd2endTest, NoHeaderMatch) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Request does not have header "key1", so kTestKey will not be added. - CheckRpcSendOk(DEBUG_LOCATION); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, WildcardMethod) { - StartBackends(1); - SetNextResolution(MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, NoKeyBuilderForMethod) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"some_other_method\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, HeaderData) { - const char* kHeaderData = "header_data"; - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}, - kHeaderData)); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - EXPECT_THAT(backends_[0]->service_.rls_data(), - ::testing::ElementsAre(kHeaderData)); -} - -TEST_F(RlsEnd2endTest, ExtraKeysAndConstantKeys) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\",\"key2\",\"key3\"" - " ]" - " }" - "]," - "\"extraKeys\":{" - " \"host\":\"%s\"," - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}," - "\"constantKeys\":{" - " \"%s\":\"%s\"" - "}", - kServiceValue, kMethodValue, kTestKey, - kHostKey, kServiceKey, kMethodKey, - kConstantKey, kConstantValue)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({ - {kTestKey, kTestValue}, - {kHostKey, kServerName}, - {kServiceKey, kServiceValue}, - {kMethodKey, kMethodValue}, - {kConstantKey, kConstantValue}, - }), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, TwoCacheEntriesWithSameTarget) { - const char* kTestValue2 = "test_value2"; - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue2}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue2}})); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 2); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); -} - -TEST_F(RlsEnd2endTest, FailedRlsRequestWithoutDefaultTarget) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - // Send an RPC before we give the RLS server a response. - // The RLS request will fail, and thus so will the data plane RPC. - CheckRpcSendFailure(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_THAT( - rls_server_->service_.GetUnmatchedRequests(), - ::testing::ElementsAre( - // TODO(roth): Change this to use ::testing::ProtoEquals() - // once that becomes available in OSS. - ::testing::Property( - &RouteLookupRequest::DebugString, - BuildRlsRequest({{kTestKey, kTestValue}}).DebugString()))); - // Now give the RLS server the right response. - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Sleep long enough for backoff to elapse, then try another RPC. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(3)); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, FailedRlsRequestWithDefaultTarget) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_default_target(TargetStringForPort(backends_[0]->port_)) - .Build()); - // Don't give the RLS server a response, so the RLS request will fail. - // The data plane RPC should be sent to the default target. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_THAT( - rls_server_->service_.GetUnmatchedRequests(), - ::testing::ElementsAre( - // TODO(roth): Change this to use ::testing::ProtoEquals() - // once that becomes available in OSS. - ::testing::Property( - &RouteLookupRequest::DebugString, - BuildRlsRequest({{kTestKey, kTestValue}}).DebugString()))); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 0); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, RlsRequestTimeout) { - StartBackends(2); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_default_target(TargetStringForPort(backends_[1]->port_)) - .set_lookup_service_timeout(2000) - .Build()); - // RLS server will send a response, but it's longer than the timeout. - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}), - /*response_delay=*/3000); - // The data plane RPC should be sent to the default target. - CheckRpcSendOk(DEBUG_LOCATION, RpcOptions().set_timeout_ms(4000).set_metadata( - {{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 0); - EXPECT_EQ(backends_[1]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, UpdateConfig) { - StartBackends(2); - auto service_config_builder = - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_default_target(TargetStringForPort(backends_[0]->port_)); - SetNextResolution(service_config_builder.Build()); - // Don't give the RLS server a response, so the RLS request will fail. - // The data plane RPC should be sent to the default target. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_THAT( - rls_server_->service_.GetUnmatchedRequests(), - ::testing::ElementsAre( - // TODO(roth): Change this to use ::testing::ProtoEquals() - // once that becomes available in OSS. - ::testing::Property( - &RouteLookupRequest::DebugString, - BuildRlsRequest({{kTestKey, kTestValue}}).DebugString()))); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 0); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - EXPECT_EQ(backends_[1]->service_.request_count(), 0); - // Now update the config to point to a new default target. - service_config_builder.set_default_target( - TargetStringForPort(backends_[1]->port_)); - SetNextResolution(service_config_builder.Build()); - // Send another RPC, which should go to the new default target. - // The RLS server will *not* see another request, because the cache - // entry is still in backoff. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 0); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - EXPECT_EQ(backends_[1]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, CachedResponse) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Send two RPCs. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - // The RLS server should have seen only one request. - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); -} - -TEST_F(RlsEnd2endTest, StaleCacheEntry) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_max_age(5000) - .set_stale_age(1000) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Send one RPC. RLS server gets a request, and RPC goes to backend. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - // Update RLS server to expect stale request. - rls_server_->service_.RemoveResponse( - BuildRlsRequest({{kTestKey, kTestValue}})); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}, - RouteLookupRequest::REASON_STALE), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Wait longer than stale age. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - // Send another RPC. This should use the stale value but should - // dispatch a second RLS request. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); - // Wait for RLS server to receive the second request. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 2); -} - -TEST_F(RlsEnd2endTest, StaleCacheEntryWithHeaderData) { - const char* kHeaderData = "header_data"; - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_max_age(5000) - .set_stale_age(1000) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}, - kHeaderData)); - // Send one RPC. RLS server gets a request, and RPC goes to backend. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - // Update RLS server to expect stale request. - rls_server_->service_.RemoveResponse( - BuildRlsRequest({{kTestKey, kTestValue}})); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}, - RouteLookupRequest::REASON_STALE, kHeaderData), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}, - kHeaderData)); - // Wait longer than stale age. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - // Send another RPC. This should use the stale value but should - // dispatch a second RLS request. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); - // Wait for RLS server to receive the second request. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 2); -} - -TEST_F(RlsEnd2endTest, ExpiredCacheEntry) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .set_max_age(1000) - .set_lookup_service_timeout(1000) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - // Send one RPC. RLS server gets a request, and RPC goes to backend. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - // Remove response from RLS server so that the next RLS request fails. - rls_server_->service_.RemoveResponse( - BuildRlsRequest({{kTestKey, kTestValue}})); - // Wait for cache to be expired. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - // Send another RPC. This should trigger a second RLS request, but - // that fails, so the RPC fails. - CheckRpcSendFailure(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, CacheSizeLimit) { - const char* kTestValue2 = "test_value_2"; - StartBackends(2); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, - kTestKey)) - .set_cache_size_bytes(1) // Not even big enough for one entry. - .Build()); - // Set RLS responses for both kTestValue and kTestValue2. - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({TargetStringForPort(backends_[0]->port_)})); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue2}}), - BuildRlsResponse({TargetStringForPort(backends_[1]->port_)})); - // Send an RPC for kTestValue. - // RLS server gets a request, and RPC goes to backend. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - EXPECT_EQ(backends_[1]->service_.request_count(), 0); - // A second RPC for kTestValue should not generate another RLS - // request, because the cache entry is held by min_eviction_time. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); - EXPECT_EQ(backends_[1]->service_.request_count(), 0); - // Wait for min_eviction_time to elapse. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(6)); - // Send a request for kTestValue2. - // RLS server gets a request, and RPC goes to backend. - // This causes the entry for kTestValue to be evicted. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue2}})); - EXPECT_EQ(rls_server_->service_.request_count(), 2); - EXPECT_EQ(rls_server_->service_.response_count(), 2); - EXPECT_EQ(backends_[0]->service_.request_count(), 2); - EXPECT_EQ(backends_[1]->service_.request_count(), 1); - // Send another RPC for kTestValue. - // This should now trigger a new RLS request. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 3); - EXPECT_EQ(rls_server_->service_.response_count(), 3); - EXPECT_EQ(backends_[0]->service_.request_count(), 3); - EXPECT_EQ(backends_[1]->service_.request_count(), 1); - // Another RPC for kTestValue2 should still work due to min_eviction_time. - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue2}})); - EXPECT_EQ(rls_server_->service_.request_count(), 3); - EXPECT_EQ(rls_server_->service_.response_count(), 3); - EXPECT_EQ(backends_[0]->service_.request_count(), 3); - EXPECT_EQ(backends_[1]->service_.request_count(), 2); -} - -TEST_F(RlsEnd2endTest, MultipleTargets) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse( - // First target will report TRANSIENT_FAILURE.. - {"invalid_target", TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); -} - -TEST_F(RlsEnd2endTest, ConnectivityStateReady) { - StartBackends(1); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false)); - rls_server_->service_.SetResponse( - BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse( - // One target in TRANSIENT_FAILURE, the other in READY. - {"invalid_target", TargetStringForPort(backends_[0]->port_)})); - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(backends_[0]->service_.request_count(), 1); - EXPECT_EQ(GRPC_CHANNEL_READY, channel_->GetState(/*try_to_connect=*/false)); -} - -TEST_F(RlsEnd2endTest, ConnectivityStateIdle) { - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false)); - // RLS server not given any responses, so the request will fail. - CheckRpcSendFailure(DEBUG_LOCATION); - // No child policies, so should be IDLE. - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false)); -} - -TEST_F(RlsEnd2endTest, ConnectivityStateTransientFailure) { - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false)); - rls_server_->service_.SetResponse(BuildRlsRequest({{kTestKey, kTestValue}}), - BuildRlsResponse({"invalid_target"})); - CheckRpcSendFailure(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - EXPECT_EQ(rls_server_->service_.request_count(), 1); - EXPECT_EQ(rls_server_->service_.response_count(), 1); - EXPECT_EQ(GRPC_CHANNEL_TRANSIENT_FAILURE, - channel_->GetState(/*try_to_connect=*/false)); -} - -TEST_F(RlsEnd2endTest, RlsAuthorityDeathTest) { - GRPC_GTEST_FLAG_SET_DEATH_TEST_STYLE("threadsafe"); - ResetStub("incorrect_authority"); - SetNextResolution( - MakeServiceConfigBuilder() - .AddKeyBuilder(y_absl::StrFormat("\"names\":[{" - " \"service\":\"%s\"," - " \"method\":\"%s\"" - "}]," - "\"headers\":[" - " {" - " \"key\":\"%s\"," - " \"names\":[" - " \"key1\"" - " ]" - " }" - "]", - kServiceValue, kMethodValue, kTestKey)) - .Build()); - // Make sure that we blow up (via abort() from the security connector) when - // the authority for the RLS channel doesn't match expectations. - ASSERT_DEATH_IF_SUPPORTED( - { - CheckRpcSendOk(DEBUG_LOCATION, - RpcOptions().set_metadata({{"key1", kTestValue}})); - }, - ""); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/sdk_authz_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/sdk_authz_end2end_test.cc deleted file mode 100644 index e3e676a32a..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/sdk_authz_end2end_test.cc +++ /dev/null @@ -1,763 +0,0 @@ -// 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. - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/authorization_policy_provider.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/cpp/server/secure_server_credentials.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/core/util/tls_utils.h" -#include "test/cpp/end2end/test_service_impl.h" - -namespace grpc { -namespace testing { -namespace { - -constexpr char kMessage[] = "Hello"; - -class SdkAuthzEnd2EndTest : public ::testing::Test { - protected: - SdkAuthzEnd2EndTest() - : server_address_( - y_absl::StrCat("localhost:", grpc_pick_unused_port_or_die())), - server_creds_( - std::shared_ptr<ServerCredentials>(new SecureServerCredentials( - grpc_fake_transport_security_server_credentials_create()))), - channel_creds_( - std::shared_ptr<ChannelCredentials>(new SecureChannelCredentials( - grpc_fake_transport_security_credentials_create()))) {} - - ~SdkAuthzEnd2EndTest() override { server_->Shutdown(); } - - // Replaces existing credentials with insecure credentials. - void UseInsecureCredentials() { - server_creds_ = InsecureServerCredentials(); - channel_creds_ = InsecureChannelCredentials(); - } - - // Creates server with sdk authorization enabled when provider is not null. - void InitServer( - std::shared_ptr<experimental::AuthorizationPolicyProviderInterface> - provider) { - ServerBuilder builder; - builder.AddListeningPort(server_address_, std::move(server_creds_)); - builder.experimental().SetAuthorizationPolicyProvider(std::move(provider)); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - std::shared_ptr<experimental::AuthorizationPolicyProviderInterface> - CreateStaticAuthzPolicyProvider(const TString& policy) { - grpc::Status status; - auto provider = experimental::StaticDataAuthorizationPolicyProvider::Create( - policy, &status); - EXPECT_TRUE(status.ok()); - return provider; - } - - std::shared_ptr<experimental::AuthorizationPolicyProviderInterface> - CreateFileWatcherAuthzPolicyProvider(const TString& policy_path, - unsigned int refresh_interval_sec) { - grpc::Status status; - auto provider = - experimental::FileWatcherAuthorizationPolicyProvider::Create( - policy_path, refresh_interval_sec, &status); - EXPECT_TRUE(status.ok()); - return provider; - } - - std::shared_ptr<Channel> BuildChannel() { - ChannelArguments args; - return ::grpc::CreateCustomChannel(server_address_, channel_creds_, args); - } - - grpc::Status SendRpc(const std::shared_ptr<Channel>& channel, - ClientContext* context, - grpc::testing::EchoResponse* response = nullptr) { - auto stub = grpc::testing::EchoTestService::NewStub(channel); - grpc::testing::EchoRequest request; - request.set_message(kMessage); - return stub->Echo(context, request, response); - } - - TString server_address_; - TestServiceImpl service_; - std::unique_ptr<Server> server_; - std::shared_ptr<ServerCredentials> server_creds_; - std::shared_ptr<ChannelCredentials> channel_creds_; -}; - -TEST_F(SdkAuthzEnd2EndTest, - StaticInitAllowsRpcRequestNoMatchInDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\", \"foo2\"]" - " }," - " {" - " \"key\": \"key-bar\"," - " \"values\": [\"bar1\"]" - " }" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_clientstreamingecho\"," - " \"request\": {" - " \"paths\": [" - " \"*/ClientStreamingEcho\"" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-foo", "foo2"); - context.AddMetadata("key-bar", "bar1"); - context.AddMetadata("key-baz", "baz1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp.message(), kMessage); -} - -TEST_F(SdkAuthzEnd2EndTest, StaticInitDeniesRpcRequestNoMatchInAllowAndDeny) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_foo\"," - " \"request\": {" - " \"paths\": [" - " \"*/foo\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_bar\"," - " \"source\": {" - " \"principals\": [" - " \"bar\"" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, StaticInitDeniesRpcRequestMatchInDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_all\"" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, - StaticInitDeniesRpcRequestMatchInDenyNoMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_clientstreamingecho\"," - " \"request\": {" - " \"paths\": [" - " \"*/ClientStreamingEcho\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, StaticInitAllowsRpcRequestEmptyDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\", \"foo2\"]" - " }," - " {" - " \"key\": \"key-bar\"," - " \"values\": [\"bar1\"]" - " }" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-foo", "foo2"); - context.AddMetadata("key-bar", "bar1"); - context.AddMetadata("key-baz", "baz1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp.message(), kMessage); -} - -TEST_F(SdkAuthzEnd2EndTest, StaticInitDeniesRpcRequestEmptyDenyNoMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\"]" - " }" - " ]" - " }" - " }" - " ]" - "}"; - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-bar", "bar1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F( - SdkAuthzEnd2EndTest, - StaticInitDeniesRpcRequestWithPrincipalsFieldOnUnauthenticatedConnection) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"source\": {" - " \"principals\": [" - " \"foo\"" - " ]" - " }," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - UseInsecureCredentials(); - InitServer(CreateStaticAuthzPolicyProvider(policy)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitAllowsRpcRequestNoMatchInDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\", \"foo2\"]" - " }," - " {" - " \"key\": \"key-bar\"," - " \"values\": [\"bar1\"]" - " }" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_clientstreamingecho\"," - " \"request\": {" - " \"paths\": [" - " \"*/ClientStreamingEcho\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-foo", "foo2"); - context.AddMetadata("key-bar", "bar1"); - context.AddMetadata("key-baz", "baz1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp.message(), kMessage); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitDeniesRpcRequestNoMatchInAllowAndDeny) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_foo\"," - " \"request\": {" - " \"paths\": [" - " \"*/foo\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_bar\"," - " \"source\": {" - " \"principals\": [" - " \"bar\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitDeniesRpcRequestMatchInDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_all\"" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitDeniesRpcRequestMatchInDenyNoMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_clientstreamingecho\"," - " \"request\": {" - " \"paths\": [" - " \"*/ClientStreamingEcho\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitAllowsRpcRequestEmptyDenyMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\", \"foo2\"]" - " }," - " {" - " \"key\": \"key-bar\"," - " \"values\": [\"bar1\"]" - " }" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-foo", "foo2"); - context.AddMetadata("key-bar", "bar1"); - context.AddMetadata("key-baz", "baz1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp.message(), kMessage); -} - -TEST_F(SdkAuthzEnd2EndTest, - FileWatcherInitDeniesRpcRequestEmptyDenyNoMatchInAllow) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]," - " \"headers\": [" - " {" - " \"key\": \"key-foo\"," - " \"values\": [\"foo1\"]" - " }" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 5)); - auto channel = BuildChannel(); - ClientContext context; - context.AddMetadata("key-bar", "bar1"); - grpc::testing::EchoResponse resp; - grpc::Status status = SendRpc(channel, &context, &resp); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, FileWatcherValidPolicyRefresh) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 1)); - auto channel = BuildChannel(); - ClientContext context1; - grpc::testing::EchoResponse resp1; - grpc::Status status = SendRpc(channel, &context1, &resp1); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp1.message(), kMessage); - // Replace the existing policy with a new authorization policy. - policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_foo\"," - " \"request\": {" - " \"paths\": [" - " \"*/foo\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - tmp_policy.RewriteFile(policy); - // Wait 2 seconds for the provider's refresh thread to read the updated files. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - ClientContext context2; - grpc::testing::EchoResponse resp2; - status = SendRpc(channel, &context2, &resp2); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp2.message().empty()); -} - -TEST_F(SdkAuthzEnd2EndTest, FileWatcherInvalidPolicyRefreshSkipsReload) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 1)); - auto channel = BuildChannel(); - ClientContext context1; - grpc::testing::EchoResponse resp1; - grpc::Status status = SendRpc(channel, &context1, &resp1); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp1.message(), kMessage); - // Replaces existing policy with an invalid authorization policy. - policy = "{}"; - tmp_policy.RewriteFile(policy); - // Wait 2 seconds for the provider's refresh thread to read the updated files. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - ClientContext context2; - grpc::testing::EchoResponse resp2; - status = SendRpc(channel, &context2, &resp2); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp2.message(), kMessage); -} - -TEST_F(SdkAuthzEnd2EndTest, FileWatcherRecoversFromFailure) { - TString policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - grpc_core::testing::TmpFile tmp_policy(policy); - InitServer(CreateFileWatcherAuthzPolicyProvider(tmp_policy.name(), 1)); - auto channel = BuildChannel(); - ClientContext context1; - grpc::testing::EchoResponse resp1; - grpc::Status status = SendRpc(channel, &context1, &resp1); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp1.message(), kMessage); - // Replaces existing policy with an invalid authorization policy. - policy = "{}"; - tmp_policy.RewriteFile(policy); - // Wait 2 seconds for the provider's refresh thread to read the updated files. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - ClientContext context2; - grpc::testing::EchoResponse resp2; - status = SendRpc(channel, &context2, &resp2); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(resp2.message(), kMessage); - // Replace the existing invalid policy with a valid authorization policy. - policy = - "{" - " \"name\": \"authz\"," - " \"allow_rules\": [" - " {" - " \"name\": \"allow_foo\"," - " \"request\": {" - " \"paths\": [" - " \"*/foo\"" - " ]" - " }" - " }" - " ]," - " \"deny_rules\": [" - " {" - " \"name\": \"deny_echo\"," - " \"request\": {" - " \"paths\": [" - " \"*/Echo\"" - " ]" - " }" - " }" - " ]" - "}"; - tmp_policy.RewriteFile(policy); - // Wait 2 seconds for the provider's refresh thread to read the updated files. - gpr_sleep_until(grpc_timeout_seconds_to_deadline(2)); - ClientContext context3; - grpc::testing::EchoResponse resp3; - status = SendRpc(channel, &context3, &resp3); - EXPECT_EQ(status.error_code(), grpc::StatusCode::PERMISSION_DENIED); - EXPECT_EQ(status.error_message(), "Unauthorized RPC request rejected."); - EXPECT_TRUE(resp3.message().empty()); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - const auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/server_builder_plugin_test.cc b/contrib/libs/grpc/test/cpp/end2end/server_builder_plugin_test.cc deleted file mode 100644 index 56c32b65da..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/server_builder_plugin_test.cc +++ /dev/null @@ -1,267 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/impl/server_builder_option.h> -#include <grpcpp/impl/server_builder_plugin.h> -#include <grpcpp/impl/server_initializer.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" - -#define PLUGIN_NAME "TestServerBuilderPlugin" - -namespace grpc { -namespace testing { - -class TestServerBuilderPlugin : public ServerBuilderPlugin { - public: - TestServerBuilderPlugin() : service_(new TestServiceImpl()) { - init_server_is_called_ = false; - finish_is_called_ = false; - change_arguments_is_called_ = false; - register_service_ = false; - } - - TString name() override { return PLUGIN_NAME; } - - void InitServer(ServerInitializer* si) override { - init_server_is_called_ = true; - if (register_service_) { - si->RegisterService(service_); - } - } - - void Finish(ServerInitializer* /*si*/) override { finish_is_called_ = true; } - - void ChangeArguments(const TString& /*name*/, void* /*value*/) override { - change_arguments_is_called_ = true; - } - - bool has_async_methods() const override { - if (register_service_) { - return service_->has_async_methods(); - } - return false; - } - - bool has_sync_methods() const override { - if (register_service_) { - return service_->has_synchronous_methods(); - } - return false; - } - - void SetRegisterService() { register_service_ = true; } - - bool init_server_is_called() { return init_server_is_called_; } - bool finish_is_called() { return finish_is_called_; } - bool change_arguments_is_called() { return change_arguments_is_called_; } - - private: - bool init_server_is_called_; - bool finish_is_called_; - bool change_arguments_is_called_; - bool register_service_; - std::shared_ptr<TestServiceImpl> service_; -}; - -class InsertPluginServerBuilderOption : public ServerBuilderOption { - public: - InsertPluginServerBuilderOption() { register_service_ = false; } - - void UpdateArguments(ChannelArguments* /*arg*/) override {} - - void UpdatePlugins( - std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) override { - plugins->clear(); - - std::unique_ptr<TestServerBuilderPlugin> plugin( - new TestServerBuilderPlugin()); - if (register_service_) plugin->SetRegisterService(); - plugins->emplace_back(std::move(plugin)); - } - - void SetRegisterService() { register_service_ = true; } - - private: - bool register_service_; -}; - -std::unique_ptr<ServerBuilderPlugin> CreateTestServerBuilderPlugin() { - return std::unique_ptr<ServerBuilderPlugin>(new TestServerBuilderPlugin()); -} - -// Force AddServerBuilderPlugin() to be called at static initialization time. -struct StaticTestPluginInitializer { - StaticTestPluginInitializer() { - ::grpc::ServerBuilder::InternalAddPluginFactory( - &CreateTestServerBuilderPlugin); - } -} static_plugin_initializer_test_; - -// When the param boolean is true, the ServerBuilder plugin will be added at the -// time of static initialization. When it's false, the ServerBuilder plugin will -// be added using ServerBuilder::SetOption(). -class ServerBuilderPluginTest : public ::testing::TestWithParam<bool> { - public: - ServerBuilderPluginTest() {} - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - builder_ = y_absl::make_unique<ServerBuilder>(); - } - - void InsertPlugin() { - if (GetParam()) { - // Add ServerBuilder plugin in static initialization - CheckPresent(); - } else { - // Add ServerBuilder plugin using ServerBuilder::SetOption() - builder_->SetOption(std::unique_ptr<ServerBuilderOption>( - new InsertPluginServerBuilderOption())); - } - } - - void InsertPluginWithTestService() { - if (GetParam()) { - // Add ServerBuilder plugin in static initialization - auto plugin = CheckPresent(); - EXPECT_TRUE(plugin); - plugin->SetRegisterService(); - } else { - // Add ServerBuilder plugin using ServerBuilder::SetOption() - std::unique_ptr<InsertPluginServerBuilderOption> option( - new InsertPluginServerBuilderOption()); - option->SetRegisterService(); - builder_->SetOption(std::move(option)); - } - } - - void StartServer() { - TString server_address = "localhost:" + to_string(port_); - builder_->AddListeningPort(server_address, InsecureServerCredentials()); - // we run some tests without a service, and for those we need to supply a - // frequently polled completion queue - cq_ = builder_->AddCompletionQueue(); - cq_thread_ = new std::thread(&ServerBuilderPluginTest::RunCQ, this); - server_ = builder_->BuildAndStart(); - EXPECT_TRUE(CheckPresent()); - } - - void ResetStub() { - string target = "dns:localhost:" + to_string(port_); - channel_ = grpc::CreateChannel(target, InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - void TearDown() override { - auto plugin = CheckPresent(); - EXPECT_TRUE(plugin); - EXPECT_TRUE(plugin->init_server_is_called()); - EXPECT_TRUE(plugin->finish_is_called()); - server_->Shutdown(); - cq_->Shutdown(); - cq_thread_->join(); - delete cq_thread_; - } - - string to_string(const int number) { - std::stringstream strs; - strs << number; - return strs.str(); - } - - protected: - std::shared_ptr<Channel> channel_; - std::unique_ptr<ServerBuilder> builder_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<ServerCompletionQueue> cq_; - std::unique_ptr<Server> server_; - std::thread* cq_thread_; - TestServiceImpl service_; - int port_; - - private: - TestServerBuilderPlugin* CheckPresent() { - auto it = builder_->plugins_.begin(); - for (; it != builder_->plugins_.end(); it++) { - if ((*it)->name() == PLUGIN_NAME) break; - } - if (it != builder_->plugins_.end()) { - return static_cast<TestServerBuilderPlugin*>(it->get()); - } else { - return nullptr; - } - } - - void RunCQ() { - void* tag; - bool ok; - while (cq_->Next(&tag, &ok)) { - } - } -}; - -TEST_P(ServerBuilderPluginTest, PluginWithoutServiceTest) { - InsertPlugin(); - StartServer(); -} - -TEST_P(ServerBuilderPluginTest, PluginWithServiceTest) { - InsertPluginWithTestService(); - StartServer(); - ResetStub(); - - EchoRequest request; - EchoResponse response; - request.set_message("Hello hello hello hello"); - ClientContext context; - context.set_compression_algorithm(GRPC_COMPRESS_GZIP); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); -} - -INSTANTIATE_TEST_SUITE_P(ServerBuilderPluginTest, ServerBuilderPluginTest, - ::testing::Values(false, true)); - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/server_crash_test.cc b/contrib/libs/grpc/test/cpp/end2end/server_crash_test.cc deleted file mode 100644 index 9ac41f9b63..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/server_crash_test.cc +++ /dev/null @@ -1,162 +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. - * - */ - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/subprocess.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -static TString g_root; - -namespace grpc { -namespace testing { - -namespace { - -class ServiceImpl final : public ::grpc::testing::EchoTestService::Service { - public: - ServiceImpl() : bidi_stream_count_(0), response_stream_count_(0) {} - - Status BidiStream( - ServerContext* /*context*/, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - bidi_stream_count_++; - EchoRequest request; - EchoResponse response; - while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); - response.set_message(request.message()); - stream->Write(response); - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(1, GPR_TIMESPAN))); - } - return Status::OK; - } - - Status ResponseStream(ServerContext* /*context*/, - const EchoRequest* /*request*/, - ServerWriter<EchoResponse>* writer) override { - EchoResponse response; - response_stream_count_++; - for (int i = 0;; i++) { - std::ostringstream msg; - msg << "Hello " << i; - response.set_message(msg.str()); - if (!writer->Write(response)) break; - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(1, GPR_TIMESPAN))); - } - return Status::OK; - } - - int bidi_stream_count() { return bidi_stream_count_; } - - int response_stream_count() { return response_stream_count_; } - - private: - int bidi_stream_count_; - int response_stream_count_; -}; - -class CrashTest : public ::testing::Test { - protected: - CrashTest() {} - - std::unique_ptr<Server> CreateServerAndClient(const TString& mode) { - auto port = grpc_pick_unused_port_or_die(); - std::ostringstream addr_stream; - addr_stream << "localhost:" << port; - auto addr = addr_stream.str(); - client_ = y_absl::make_unique<SubProcess>( - std::vector<TString>({g_root + "/server_crash_test_client", - "--address=" + addr, "--mode=" + mode})); - GPR_ASSERT(client_); - - ServerBuilder builder; - builder.AddListeningPort(addr, grpc::InsecureServerCredentials()); - builder.RegisterService(&service_); - return builder.BuildAndStart(); - } - - void KillClient() { client_.reset(); } - - bool HadOneBidiStream() { return service_.bidi_stream_count() == 1; } - - bool HadOneResponseStream() { return service_.response_stream_count() == 1; } - - private: - std::unique_ptr<SubProcess> client_; - ServiceImpl service_; -}; - -TEST_F(CrashTest, ResponseStream) { - auto server = CreateServerAndClient("response"); - - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(60, GPR_TIMESPAN))); - KillClient(); - server->Shutdown(); - GPR_ASSERT(HadOneResponseStream()); -} - -TEST_F(CrashTest, BidiStream) { - auto server = CreateServerAndClient("bidi"); - - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(60, GPR_TIMESPAN))); - KillClient(); - server->Shutdown(); - GPR_ASSERT(HadOneBidiStream()); -} - -} // namespace - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - TString me = argv[0]; - auto lslash = me.rfind('/'); - if (lslash != TString::npos) { - g_root = me.substr(0, lslash); - } else { - g_root = "."; - } - - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/server_crash_test_client.cc b/contrib/libs/grpc/test/cpp/end2end/server_crash_test_client.cc deleted file mode 100644 index 8ecdaf56bb..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/server_crash_test_client.cc +++ /dev/null @@ -1,72 +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. - * - */ - -#include <iostream> -#include <memory> -#include <sstream> -#include <util/generic/string.h> - -#include "y_absl/flags/flag.h" - -#include <grpc/support/log.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/cpp/util/test_config.h" - -Y_ABSL_FLAG(TString, address, "", "Address to connect to"); -Y_ABSL_FLAG(TString, mode, "", "Test mode to use"); - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -int main(int argc, char** argv) { - grpc::testing::InitTest(&argc, &argv, true); - auto stub = grpc::testing::EchoTestService::NewStub(grpc::CreateChannel( - y_absl::GetFlag(FLAGS_address), grpc::InsecureChannelCredentials())); - - EchoRequest request; - EchoResponse response; - grpc::ClientContext context; - context.set_wait_for_ready(true); - - if (y_absl::GetFlag(FLAGS_mode) == "bidi") { - auto stream = stub->BidiStream(&context); - for (int i = 0;; i++) { - std::ostringstream msg; - msg << "Hello " << i; - request.set_message(msg.str()); - GPR_ASSERT(stream->Write(request)); - GPR_ASSERT(stream->Read(&response)); - GPR_ASSERT(response.message() == request.message()); - } - } else if (y_absl::GetFlag(FLAGS_mode) == "response") { - EchoRequest request; - request.set_message("Hello"); - auto stream = stub->ResponseStream(&context, request); - for (;;) { - GPR_ASSERT(stream->Read(&response)); - } - } else { - gpr_log(GPR_ERROR, "invalid test mode '%s'", - y_absl::GetFlag(FLAGS_mode).c_str()); - return 1; - } -} diff --git a/contrib/libs/grpc/test/cpp/end2end/server_early_return_test.cc b/contrib/libs/grpc/test/cpp/end2end/server_early_return_test.cc deleted file mode 100644 index b33c708295..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/server_early_return_test.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/string_ref_helper.h" - -namespace grpc { -namespace testing { -namespace { - -const char kServerReturnStatusCode[] = "server_return_status_code"; -const char kServerDelayBeforeReturnUs[] = "server_delay_before_return_us"; -const char kServerReturnAfterNReads[] = "server_return_after_n_reads"; - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - // Unused methods are not implemented. - - Status RequestStream(ServerContext* context, - ServerReader<EchoRequest>* reader, - EchoResponse* response) override { - int server_return_status_code = - GetIntValueFromMetadata(context, kServerReturnStatusCode, 0); - int server_delay_before_return_us = - GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0); - int server_return_after_n_reads = - GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0); - - EchoRequest request; - while (server_return_after_n_reads--) { - EXPECT_TRUE(reader->Read(&request)); - } - - response->set_message("response msg"); - - gpr_sleep_until(gpr_time_add( - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN))); - - return Status(static_cast<StatusCode>(server_return_status_code), ""); - } - - Status BidiStream( - ServerContext* context, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - int server_return_status_code = - GetIntValueFromMetadata(context, kServerReturnStatusCode, 0); - int server_delay_before_return_us = - GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0); - int server_return_after_n_reads = - GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0); - - EchoRequest request; - EchoResponse response; - while (server_return_after_n_reads--) { - EXPECT_TRUE(stream->Read(&request)); - response.set_message(request.message()); - EXPECT_TRUE(stream->Write(response)); - } - - gpr_sleep_until(gpr_time_add( - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN))); - - return Status(static_cast<StatusCode>(server_return_status_code), ""); - } - - int GetIntValueFromMetadata(ServerContext* context, const char* key, - int default_value) { - auto metadata = context->client_metadata(); - if (metadata.find(key) != metadata.end()) { - std::istringstream iss(ToString(metadata.find(key)->second)); - iss >> default_value; - } - return default_value; - } -}; - -class ServerEarlyReturnTest : public ::testing::Test { - protected: - ServerEarlyReturnTest() : picked_port_(0) {} - - void SetUp() override { - int port = grpc_pick_unused_port_or_die(); - picked_port_ = port; - server_address_ << "localhost:" << port; - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - - channel_ = grpc::CreateChannel(server_address_.str(), - InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - void TearDown() override { - server_->Shutdown(); - if (picked_port_ > 0) { - grpc_recycle_unused_port(picked_port_); - } - } - - // Client sends 20 requests and the server returns after reading 10 requests. - // If return_cancel is true, server returns CANCELLED status. Otherwise it - // returns OK. - void DoBidiStream(bool return_cancelled) { - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.AddMetadata(kServerReturnAfterNReads, "10"); - if (return_cancelled) { - // "1" means CANCELLED - context.AddMetadata(kServerReturnStatusCode, "1"); - } - context.AddMetadata(kServerDelayBeforeReturnUs, "10000"); - - auto stream = stub_->BidiStream(&context); - - for (int i = 0; i < 20; i++) { - request.set_message(TString("hello") + ToString(i)); - bool write_ok = stream->Write(request); - bool read_ok = stream->Read(&response); - if (i < 10) { - EXPECT_TRUE(write_ok); - EXPECT_TRUE(read_ok); - EXPECT_EQ(response.message(), request.message()); - } else { - EXPECT_FALSE(read_ok); - } - } - - stream->WritesDone(); - EXPECT_FALSE(stream->Read(&response)); - - Status s = stream->Finish(); - if (return_cancelled) { - EXPECT_EQ(s.error_code(), StatusCode::CANCELLED); - } else { - EXPECT_TRUE(s.ok()); - } - } - - void DoRequestStream(bool return_cancelled) { - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.AddMetadata(kServerReturnAfterNReads, "10"); - if (return_cancelled) { - // "1" means CANCELLED - context.AddMetadata(kServerReturnStatusCode, "1"); - } - context.AddMetadata(kServerDelayBeforeReturnUs, "10000"); - - auto stream = stub_->RequestStream(&context, &response); - for (int i = 0; i < 20; i++) { - request.set_message(TString("hello") + ToString(i)); - bool written = stream->Write(request); - if (i < 10) { - EXPECT_TRUE(written); - } - } - stream->WritesDone(); - Status s = stream->Finish(); - if (return_cancelled) { - EXPECT_EQ(s.error_code(), StatusCode::CANCELLED); - } else { - EXPECT_TRUE(s.ok()); - } - } - - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - TestServiceImpl service_; - int picked_port_; -}; - -TEST_F(ServerEarlyReturnTest, BidiStreamEarlyOk) { DoBidiStream(false); } - -TEST_F(ServerEarlyReturnTest, BidiStreamEarlyCancel) { DoBidiStream(true); } - -TEST_F(ServerEarlyReturnTest, RequestStreamEarlyOK) { DoRequestStream(false); } -TEST_F(ServerEarlyReturnTest, RequestStreamEarlyCancel) { - DoRequestStream(true); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/server_load_reporting_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/server_load_reporting_end2end_test.cc deleted file mode 100644 index e97b51f21e..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/server_load_reporting_end2end_test.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/support/port_platform.h> - -#include <thread> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include <grpc++/grpc++.h> -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpcpp/ext/server_load_reporting.h> -#include <grpcpp/server_builder.h> - -#include "src/proto/grpc/lb/v1/load_reporter.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -namespace grpc { -namespace testing { -namespace { - -constexpr double kMetricValue = 3.1415; -constexpr char kMetricName[] = "METRIC_PI"; - -// Different messages result in different response statuses. For simplicity in -// computing request bytes, the message sizes should be the same. -const char kOkMessage[] = "hello"; -const char kServerErrorMessage[] = "sverr"; -const char kClientErrorMessage[] = "clerr"; - -class EchoTestServiceImpl : public EchoTestService::Service { - public: - ~EchoTestServiceImpl() override {} - - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - if (request->message() == kServerErrorMessage) { - return Status(StatusCode::UNKNOWN, "Server error requested"); - } - if (request->message() == kClientErrorMessage) { - return Status(StatusCode::FAILED_PRECONDITION, "Client error requested"); - } - response->set_message(request->message()); - ::grpc::load_reporter::experimental::AddLoadReportingCost( - context, kMetricName, kMetricValue); - return Status::OK; - } -}; - -class ServerLoadReportingEnd2endTest : public ::testing::Test { - protected: - void SetUp() override { - server_address_ = - "localhost:" + ToString(grpc_pick_unused_port_or_die()); - server_ = - ServerBuilder() - .AddListeningPort(server_address_, InsecureServerCredentials()) - .RegisterService(&echo_service_) - .SetOption(std::unique_ptr<::grpc::ServerBuilderOption>( - new ::grpc::load_reporter::experimental:: - LoadReportingServiceServerBuilderOption())) - .BuildAndStart(); - server_thread_ = - std::thread(&ServerLoadReportingEnd2endTest::RunServerLoop, this); - } - - void RunServerLoop() { server_->Wait(); } - - void TearDown() override { - server_->Shutdown(); - server_thread_.join(); - } - - void ClientMakeEchoCalls(const TString& lb_id, const TString& lb_tag, - const TString& message, size_t num_requests) { - auto stub = EchoTestService::NewStub( - grpc::CreateChannel(server_address_, InsecureChannelCredentials())); - TString lb_token = lb_id + lb_tag; - for (size_t i = 0; i < num_requests; ++i) { - ClientContext ctx; - if (!lb_token.empty()) ctx.AddMetadata(GRPC_LB_TOKEN_MD_KEY, lb_token); - EchoRequest request; - EchoResponse response; - request.set_message(message); - Status status = stub->Echo(&ctx, request, &response); - if (message == kOkMessage) { - ASSERT_EQ(status.error_code(), StatusCode::OK); - ASSERT_EQ(request.message(), response.message()); - } else if (message == kServerErrorMessage) { - ASSERT_EQ(status.error_code(), StatusCode::UNKNOWN); - } else if (message == kClientErrorMessage) { - ASSERT_EQ(status.error_code(), StatusCode::FAILED_PRECONDITION); - } - } - } - - TString server_address_; - std::unique_ptr<Server> server_; - std::thread server_thread_; - EchoTestServiceImpl echo_service_; -}; - -TEST_F(ServerLoadReportingEnd2endTest, NoCall) {} - -TEST_F(ServerLoadReportingEnd2endTest, BasicReport) { - auto channel = - grpc::CreateChannel(server_address_, InsecureChannelCredentials()); - auto stub = ::grpc::lb::v1::LoadReporter::NewStub(channel); - ClientContext ctx; - auto stream = stub->ReportLoad(&ctx); - ::grpc::lb::v1::LoadReportRequest request; - request.mutable_initial_request()->set_load_balanced_hostname( - server_address_); - request.mutable_initial_request()->set_load_key("LOAD_KEY"); - request.mutable_initial_request() - ->mutable_load_report_interval() - ->set_seconds(5); - stream->Write(request); - gpr_log(GPR_INFO, "Initial request sent."); - ::grpc::lb::v1::LoadReportResponse response; - stream->Read(&response); - const TString& lb_id = response.initial_response().load_balancer_id(); - gpr_log(GPR_INFO, "Initial response received (lb_id: %s).", lb_id.c_str()); - ClientMakeEchoCalls(lb_id, "LB_TAG", kOkMessage, 1); - while (true) { - stream->Read(&response); - if (!response.load().empty()) { - ASSERT_EQ(response.load().size(), 3); - for (const auto& load : response.load()) { - if (load.in_progress_report_case()) { - // The special load record that reports the number of in-progress - // calls. - ASSERT_EQ(load.num_calls_in_progress(), 1); - } else if (load.orphaned_load_case()) { - // The call from the balancer doesn't have any valid LB token. - ASSERT_EQ(load.orphaned_load_case(), load.kLoadKeyUnknown); - ASSERT_EQ(load.num_calls_started(), 1); - ASSERT_EQ(load.num_calls_finished_without_error(), 0); - ASSERT_EQ(load.num_calls_finished_with_error(), 0); - } else { - // This corresponds to the calls from the client. - ASSERT_EQ(load.num_calls_started(), 1); - ASSERT_EQ(load.num_calls_finished_without_error(), 1); - ASSERT_EQ(load.num_calls_finished_with_error(), 0); - ASSERT_GE(load.total_bytes_received(), sizeof(kOkMessage)); - ASSERT_GE(load.total_bytes_sent(), sizeof(kOkMessage)); - ASSERT_EQ(load.metric_data().size(), 1); - ASSERT_EQ(load.metric_data().Get(0).metric_name(), kMetricName); - ASSERT_EQ(load.metric_data().Get(0).num_calls_finished_with_metric(), - 1); - ASSERT_EQ(load.metric_data().Get(0).total_metric_value(), - kMetricValue); - } - } - break; - } - } - stream->WritesDone(); - ASSERT_EQ(stream->Finish().error_code(), StatusCode::CANCELLED); -} - -// TODO(juanlishen): Add more tests. - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc b/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc deleted file mode 100644 index b974befd49..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/service_config_end2end_test.cc +++ /dev/null @@ -1,621 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <algorithm> -#include <memory> -#include <mutex> -#include <random> -#include <set> -#include <util/generic/string.h> -#include <thread> - -#include <gmock/gmock.h> -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" -#include "y_absl/strings/str_cat.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/health_check_service_interface.h> -#include <grpcpp/impl/codegen/sync.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/support/validate_service_config.h> - -#include "src/core/ext/filters/client_channel/backup_poller.h" -#include "src/core/ext/filters/client_channel/global_subchannel_pool.h" -#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" -#include "src/core/ext/filters/client_channel/server_address.h" -#include "src/core/lib/address_utils/parse_address.h" -#include "src/core/lib/backoff/backoff.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/debug_location.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/tcp_client.h" -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/cpp/client/secure_credentials.h" -#include "src/cpp/server/secure_server_credentials.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/resolve_localhost_ip46.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { -namespace { - -// Subclass of TestServiceImpl that increments a request counter for -// every call to the Echo RPC. -class MyTestServiceImpl : public TestServiceImpl { - public: - MyTestServiceImpl() : request_count_(0) {} - - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - { - grpc::internal::MutexLock lock(&mu_); - ++request_count_; - } - AddClient(context->peer()); - return TestServiceImpl::Echo(context, request, response); - } - - int request_count() { - grpc::internal::MutexLock lock(&mu_); - return request_count_; - } - - void ResetCounters() { - grpc::internal::MutexLock lock(&mu_); - request_count_ = 0; - } - - std::set<TString> clients() { - grpc::internal::MutexLock lock(&clients_mu_); - return clients_; - } - - private: - void AddClient(const TString& client) { - grpc::internal::MutexLock lock(&clients_mu_); - clients_.insert(client); - } - - grpc::internal::Mutex mu_; - int request_count_; - grpc::internal::Mutex clients_mu_; - std::set<TString> clients_; -}; - -class ServiceConfigEnd2endTest : public ::testing::Test { - protected: - ServiceConfigEnd2endTest() - : server_host_("localhost"), - kRequestMessage_("Live long and prosper."), - creds_(new SecureChannelCredentials( - grpc_fake_transport_security_credentials_create())) {} - - static void SetUpTestCase() { - // Make the backup poller poll very frequently in order to pick up - // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); - } - - void SetUp() override { - grpc_init(); - response_generator_ = - grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); - bool localhost_resolves_to_ipv4 = false; - bool localhost_resolves_to_ipv6 = false; - grpc_core::LocalhostResolves(&localhost_resolves_to_ipv4, - &localhost_resolves_to_ipv6); - ipv6_only_ = !localhost_resolves_to_ipv4 && localhost_resolves_to_ipv6; - } - - void TearDown() override { - for (size_t i = 0; i < servers_.size(); ++i) { - servers_[i]->Shutdown(); - } - // Explicitly destroy all the members so that we can make sure grpc_shutdown - // has finished by the end of this function, and thus all the registered - // LB policy factories are removed. - stub_.reset(); - servers_.clear(); - creds_.reset(); - grpc_shutdown(); - } - - void CreateServers(size_t num_servers, - std::vector<int> ports = std::vector<int>()) { - servers_.clear(); - for (size_t i = 0; i < num_servers; ++i) { - int port = 0; - if (ports.size() == num_servers) port = ports[i]; - servers_.emplace_back(new ServerData(port)); - } - } - - void StartServer(size_t index) { servers_[index]->Start(server_host_); } - - void StartServers(size_t num_servers, - std::vector<int> ports = std::vector<int>()) { - CreateServers(num_servers, std::move(ports)); - for (size_t i = 0; i < num_servers; ++i) { - StartServer(i); - } - } - - grpc_core::Resolver::Result BuildFakeResults(const std::vector<int>& ports) { - grpc_core::Resolver::Result result; - for (const int& port : ports) { - TString lb_uri_str = - y_absl::StrCat(ipv6_only_ ? "ipv6:[::1]:" : "ipv4:127.0.0.1:", port); - y_absl::StatusOr<grpc_core::URI> lb_uri = grpc_core::URI::Parse(lb_uri_str); - GPR_ASSERT(lb_uri.ok()); - grpc_resolved_address address; - GPR_ASSERT(grpc_parse_uri(*lb_uri, &address)); - result.addresses.emplace_back(address.addr, address.len, - nullptr /* args */); - } - return result; - } - - void SetNextResolutionNoServiceConfig(const std::vector<int>& ports) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = BuildFakeResults(ports); - response_generator_->SetResponse(result); - } - - void SetNextResolutionValidServiceConfig(const std::vector<int>& ports) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = BuildFakeResults(ports); - result.service_config = grpc_core::ServiceConfig::Create( - nullptr, "{}", &result.service_config_error); - response_generator_->SetResponse(result); - } - - void SetNextResolutionInvalidServiceConfig(const std::vector<int>& ports) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = BuildFakeResults(ports); - result.service_config = grpc_core::ServiceConfig::Create( - nullptr, "{", &result.service_config_error); - response_generator_->SetResponse(result); - } - - void SetNextResolutionWithServiceConfig(const std::vector<int>& ports, - const char* svc_cfg) { - grpc_core::ExecCtx exec_ctx; - grpc_core::Resolver::Result result = BuildFakeResults(ports); - result.service_config = grpc_core::ServiceConfig::Create( - nullptr, svc_cfg, &result.service_config_error); - response_generator_->SetResponse(result); - } - - std::vector<int> GetServersPorts(size_t start_index = 0) { - std::vector<int> ports; - for (size_t i = start_index; i < servers_.size(); ++i) { - ports.push_back(servers_[i]->port_); - } - return ports; - } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> BuildStub( - const std::shared_ptr<Channel>& channel) { - return grpc::testing::EchoTestService::NewStub(channel); - } - - std::shared_ptr<Channel> BuildChannel() { - ChannelArguments args; - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_.get()); - return ::grpc::CreateCustomChannel("fake:///", creds_, args); - } - - std::shared_ptr<Channel> BuildChannelWithDefaultServiceConfig() { - ChannelArguments args; - EXPECT_THAT(grpc::experimental::ValidateServiceConfigJSON( - ValidDefaultServiceConfig()), - ::testing::StrEq("")); - args.SetServiceConfigJSON(ValidDefaultServiceConfig()); - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_.get()); - return ::grpc::CreateCustomChannel("fake:///", creds_, args); - } - - std::shared_ptr<Channel> BuildChannelWithInvalidDefaultServiceConfig() { - ChannelArguments args; - EXPECT_THAT(grpc::experimental::ValidateServiceConfigJSON( - InvalidDefaultServiceConfig()), - ::testing::HasSubstr("JSON parse error")); - args.SetServiceConfigJSON(InvalidDefaultServiceConfig()); - args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_.get()); - return ::grpc::CreateCustomChannel("fake:///", creds_, args); - } - - bool SendRpc( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - EchoResponse* response = nullptr, int timeout_ms = 1000, - Status* result = nullptr, bool wait_for_ready = false) { - const bool local_response = (response == nullptr); - if (local_response) response = new EchoResponse; - EchoRequest request; - request.set_message(kRequestMessage_); - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); - if (wait_for_ready) context.set_wait_for_ready(true); - Status status = stub->Echo(&context, request, response); - if (result != nullptr) *result = status; - if (local_response) delete response; - return status.ok(); - } - - void CheckRpcSendOk( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - const grpc_core::DebugLocation& location, bool wait_for_ready = false) { - EchoResponse response; - Status status; - const bool success = - SendRpc(stub, &response, 2000, &status, wait_for_ready); - ASSERT_TRUE(success) << "From " << location.file() << ":" << location.line() - << "\n" - << "Error: " << status.error_message() << " " - << status.error_details(); - ASSERT_EQ(response.message(), kRequestMessage_) - << "From " << location.file() << ":" << location.line(); - if (!success) abort(); - } - - void CheckRpcSendFailure( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub) { - const bool success = SendRpc(stub); - EXPECT_FALSE(success); - } - - struct ServerData { - const int port_; - std::unique_ptr<Server> server_; - MyTestServiceImpl service_; - std::unique_ptr<std::thread> thread_; - - grpc::internal::Mutex mu_; - grpc::internal::CondVar cond_; - bool server_ready_ Y_ABSL_GUARDED_BY(mu_) = false; - bool started_ Y_ABSL_GUARDED_BY(mu_) = false; - - explicit ServerData(int port = 0) - : port_(port > 0 ? port : grpc_pick_unused_port_or_die()) {} - - void Start(const TString& server_host) { - gpr_log(GPR_INFO, "starting server on port %d", port_); - grpc::internal::MutexLock lock(&mu_); - started_ = true; - thread_ = y_absl::make_unique<std::thread>( - std::bind(&ServerData::Serve, this, server_host)); - while (!server_ready_) { - cond_.Wait(&mu_); - } - server_ready_ = false; - gpr_log(GPR_INFO, "server startup complete"); - } - - void Serve(const TString& server_host) { - std::ostringstream server_address; - server_address << server_host << ":" << port_; - ServerBuilder builder; - std::shared_ptr<ServerCredentials> creds(new SecureServerCredentials( - grpc_fake_transport_security_server_credentials_create())); - builder.AddListeningPort(server_address.str(), std::move(creds)); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - grpc::internal::MutexLock lock(&mu_); - server_ready_ = true; - cond_.Signal(); - } - - void Shutdown() { - grpc::internal::MutexLock lock(&mu_); - if (!started_) return; - server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); - thread_->join(); - started_ = false; - } - - void SetServingStatus(const TString& service, bool serving) { - server_->GetHealthCheckService()->SetServingStatus(service, serving); - } - }; - - void ResetCounters() { - for (const auto& server : servers_) server->service_.ResetCounters(); - } - - void WaitForServer( - const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, - size_t server_idx, const grpc_core::DebugLocation& location, - bool ignore_failure = false) { - do { - if (ignore_failure) { - SendRpc(stub); - } else { - CheckRpcSendOk(stub, location, true); - } - } while (servers_[server_idx]->service_.request_count() == 0); - ResetCounters(); - } - - bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(false /* try_to_connect */)) == - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - bool WaitForChannelReady(Channel* channel, int timeout_seconds = 5) { - const gpr_timespec deadline = - grpc_timeout_seconds_to_deadline(timeout_seconds); - grpc_connectivity_state state; - while ((state = channel->GetState(true /* try_to_connect */)) != - GRPC_CHANNEL_READY) { - if (!channel->WaitForStateChange(state, deadline)) return false; - } - return true; - } - - bool SeenAllServers() { - for (const auto& server : servers_) { - if (server->service_.request_count() == 0) return false; - } - return true; - } - - // Updates \a connection_order by appending to it the index of the newly - // connected server. Must be called after every single RPC. - void UpdateConnectionOrder( - const std::vector<std::unique_ptr<ServerData>>& servers, - std::vector<int>* connection_order) { - for (size_t i = 0; i < servers.size(); ++i) { - if (servers[i]->service_.request_count() == 1) { - // Was the server index known? If not, update connection_order. - const auto it = - std::find(connection_order->begin(), connection_order->end(), i); - if (it == connection_order->end()) { - connection_order->push_back(i); - return; - } - } - } - } - - const char* ValidServiceConfigV1() { return "{\"version\": \"1\"}"; } - - const char* ValidServiceConfigV2() { return "{\"version\": \"2\"}"; } - - const char* ValidDefaultServiceConfig() { - return "{\"version\": \"valid_default\"}"; - } - - const char* InvalidDefaultServiceConfig() { - return "{\"version\": \"invalid_default\""; - } - - bool ipv6_only_ = false; - const TString server_host_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::vector<std::unique_ptr<ServerData>> servers_; - grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> - response_generator_; - const TString kRequestMessage_; - std::shared_ptr<ChannelCredentials> creds_; -}; - -TEST_F(ServiceConfigEnd2endTest, NoServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ("{}", channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, NoServiceConfigWithDefaultConfigTest) { - StartServers(1); - auto channel = BuildChannelWithDefaultServiceConfig(); - auto stub = BuildStub(channel); - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidDefaultServiceConfig(), - channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, InvalidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); -} - -TEST_F(ServiceConfigEnd2endTest, ValidServiceConfigUpdatesTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV2()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV2(), channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - NoServiceConfigUpdateAfterValidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ("{}", channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - NoServiceConfigUpdateAfterValidServiceConfigWithDefaultConfigTest) { - StartServers(1); - auto channel = BuildChannelWithDefaultServiceConfig(); - auto stub = BuildStub(channel); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidDefaultServiceConfig(), - channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - InvalidServiceConfigUpdateAfterValidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - InvalidServiceConfigUpdateAfterValidServiceConfigWithDefaultConfigTest) { - StartServers(1); - auto channel = BuildChannelWithDefaultServiceConfig(); - auto stub = BuildStub(channel); - SetNextResolutionWithServiceConfig(GetServersPorts(), ValidServiceConfigV1()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ(ValidServiceConfigV1(), channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - ValidServiceConfigAfterInvalidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); - SetNextResolutionValidServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); -} - -TEST_F(ServiceConfigEnd2endTest, NoServiceConfigAfterInvalidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendOk(stub, DEBUG_LOCATION); - EXPECT_STREQ("{}", channel->GetServiceConfigJSON().c_str()); -} - -TEST_F(ServiceConfigEnd2endTest, - AnotherInvalidServiceConfigAfterInvalidServiceConfigTest) { - StartServers(1); - auto channel = BuildChannel(); - auto stub = BuildStub(channel); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); -} - -TEST_F(ServiceConfigEnd2endTest, InvalidDefaultServiceConfigTest) { - StartServers(1); - auto channel = BuildChannelWithInvalidDefaultServiceConfig(); - auto stub = BuildStub(channel); - // An invalid default service config results in a lame channel which fails all - // RPCs - CheckRpcSendFailure(stub); -} - -TEST_F(ServiceConfigEnd2endTest, - InvalidDefaultServiceConfigTestWithValidServiceConfig) { - StartServers(1); - auto channel = BuildChannelWithInvalidDefaultServiceConfig(); - auto stub = BuildStub(channel); - CheckRpcSendFailure(stub); - // An invalid default service config results in a lame channel which fails all - // RPCs - SetNextResolutionValidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); -} - -TEST_F(ServiceConfigEnd2endTest, - InvalidDefaultServiceConfigTestWithInvalidServiceConfig) { - StartServers(1); - auto channel = BuildChannelWithInvalidDefaultServiceConfig(); - auto stub = BuildStub(channel); - CheckRpcSendFailure(stub); - // An invalid default service config results in a lame channel which fails all - // RPCs - SetNextResolutionInvalidServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); -} - -TEST_F(ServiceConfigEnd2endTest, - InvalidDefaultServiceConfigTestWithNoServiceConfig) { - StartServers(1); - auto channel = BuildChannelWithInvalidDefaultServiceConfig(); - auto stub = BuildStub(channel); - CheckRpcSendFailure(stub); - // An invalid default service config results in a lame channel which fails all - // RPCs - SetNextResolutionNoServiceConfig(GetServersPorts()); - CheckRpcSendFailure(stub); -} - -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - grpc::testing::TestEnvironment env(argc, argv); - const auto result = RUN_ALL_TESTS(); - return result; -} diff --git a/contrib/libs/grpc/test/cpp/end2end/shutdown_test.cc b/contrib/libs/grpc/test/cpp/end2end/shutdown_test.cc deleted file mode 100644 index 01d32fc3bf..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/shutdown_test.cc +++ /dev/null @@ -1,170 +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. - * - */ - -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/sync.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/test_credentials_provider.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - explicit TestServiceImpl(gpr_event* ev) : ev_(ev) {} - - Status Echo(ServerContext* context, const EchoRequest* /*request*/, - EchoResponse* /*response*/) override { - gpr_event_set(ev_, reinterpret_cast<void*>(1)); - while (!context->IsCancelled()) { - } - return Status::OK; - } - - private: - gpr_event* ev_; -}; - -class ShutdownTest : public ::testing::TestWithParam<string> { - public: - ShutdownTest() : shutdown_(false), service_(&ev_) { gpr_event_init(&ev_); } - - void SetUp() override { - port_ = grpc_pick_unused_port_or_die(); - server_ = SetUpServer(port_); - } - - std::unique_ptr<Server> SetUpServer(const int port) { - TString server_address = "localhost:" + to_string(port); - - ServerBuilder builder; - auto server_creds = - GetCredentialsProvider()->GetServerCredentials(GetParam()); - builder.AddListeningPort(server_address, server_creds); - builder.RegisterService(&service_); - std::unique_ptr<Server> server = builder.BuildAndStart(); - return server; - } - - void TearDown() override { GPR_ASSERT(shutdown_); } - - void ResetStub() { - string target = "dns:localhost:" + to_string(port_); - ChannelArguments args; - auto channel_creds = - GetCredentialsProvider()->GetChannelCredentials(GetParam(), &args); - channel_ = ::grpc::CreateCustomChannel(target, channel_creds, args); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - string to_string(const int number) { - std::stringstream strs; - strs << number; - return strs.str(); - } - - void SendRequest() { - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - ClientContext context; - GPR_ASSERT(!shutdown_); - Status s = stub_->Echo(&context, request, &response); - GPR_ASSERT(shutdown_); - } - - protected: - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - bool shutdown_; - int port_; - gpr_event ev_; - TestServiceImpl service_; -}; - -std::vector<string> GetAllCredentialsTypeList() { - std::vector<TString> credentials_types; - if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType, - nullptr) != nullptr) { - credentials_types.push_back(kInsecureCredentialsType); - } - auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList(); - for (auto sec = sec_list.begin(); sec != sec_list.end(); sec++) { - credentials_types.push_back(*sec); - } - GPR_ASSERT(!credentials_types.empty()); - - TString credentials_type_list("credentials types:"); - for (const string& type : credentials_types) { - credentials_type_list.append(" " + type); - } - gpr_log(GPR_INFO, "%s", credentials_type_list.c_str()); - return credentials_types; -} - -INSTANTIATE_TEST_SUITE_P(End2EndShutdown, ShutdownTest, - ::testing::ValuesIn(GetAllCredentialsTypeList())); - -// TODO(ctiller): leaked objects in this test -TEST_P(ShutdownTest, ShutdownTest) { - ResetStub(); - - // send the request in a background thread - std::thread thr(std::bind(&ShutdownTest::SendRequest, this)); - - // wait for the server to get the event - gpr_event_wait(&ev_, gpr_inf_future(GPR_CLOCK_MONOTONIC)); - - shutdown_ = true; - - // shutdown should trigger cancellation causing everything to shutdown - auto deadline = - std::chrono::system_clock::now() + std::chrono::microseconds(100); - server_->Shutdown(deadline); - EXPECT_GE(std::chrono::system_clock::now(), deadline); - - thr.join(); -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/streaming_throughput_test.cc b/contrib/libs/grpc/test/cpp/end2end/streaming_throughput_test.cc deleted file mode 100644 index 41721957e5..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/streaming_throughput_test.cc +++ /dev/null @@ -1,193 +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. - * - */ - -#include <time.h> - -#include <mutex> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/atm.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -const char* kLargeString = - "(" - "To be, or not to be- that is the question:" - "Whether 'tis nobler in the mind to suffer" - "The slings and arrows of outrageous fortune" - "Or to take arms against a sea of troubles," - "And by opposing end them. To die- to sleep-" - "No more; and by a sleep to say we end" - "The heartache, and the thousand natural shock" - "That flesh is heir to. 'Tis a consummation" - "Devoutly to be wish'd. To die- to sleep." - "To sleep- perchance to dream: ay, there's the rub!" - "For in that sleep of death what dreams may come" - "When we have shuffled off this mortal coil," - "Must give us pause. There's the respect" - "That makes calamity of so long life." - "For who would bear the whips and scorns of time," - "Th' oppressor's wrong, the proud man's contumely," - "The pangs of despis'd love, the law's delay," - "The insolence of office, and the spurns" - "That patient merit of th' unworthy takes," - "When he himself might his quietus make" - "With a bare bodkin? Who would these fardels bear," - "To grunt and sweat under a weary life," - "But that the dread of something after death-" - "The undiscover'd country, from whose bourn" - "No traveller returns- puzzles the will," - "And makes us rather bear those ills we have" - "Than fly to others that we know not of?" - "Thus conscience does make cowards of us all," - "And thus the native hue of resolution" - "Is sicklied o'er with the pale cast of thought," - "And enterprises of great pith and moment" - "With this regard their currents turn awry" - "And lose the name of action.- Soft you now!" - "The fair Ophelia!- Nymph, in thy orisons" - "Be all my sins rememb'red."; - -namespace grpc { -namespace testing { - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - static void BidiStream_Sender( - ServerReaderWriter<EchoResponse, EchoRequest>* stream, - gpr_atm* should_exit) { - EchoResponse response; - response.set_message(kLargeString); - while (gpr_atm_acq_load(should_exit) == static_cast<gpr_atm>(0)) { - struct timespec tv = {0, 1000000}; // 1 ms - struct timespec rem; - // TODO (vpai): Mark this blocking - while (nanosleep(&tv, &rem) != 0) { - tv = rem; - }; - - stream->Write(response); - } - } - - // Only implement the one method we will be calling for brevity. - Status BidiStream( - ServerContext* /*context*/, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - EchoRequest request; - gpr_atm should_exit; - gpr_atm_rel_store(&should_exit, static_cast<gpr_atm>(0)); - - std::thread sender( - std::bind(&TestServiceImpl::BidiStream_Sender, stream, &should_exit)); - - while (stream->Read(&request)) { - struct timespec tv = {0, 3000000}; // 3 ms - struct timespec rem; - // TODO (vpai): Mark this blocking - while (nanosleep(&tv, &rem) != 0) { - tv = rem; - }; - } - gpr_atm_rel_store(&should_exit, static_cast<gpr_atm>(1)); - sender.join(); - return Status::OK; - } -}; - -class End2endTest : public ::testing::Test { - protected: - void SetUp() override { - int port = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port; - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - void TearDown() override { server_->Shutdown(); } - - void ResetStub() { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - TestServiceImpl service_; -}; - -static void Drainer(ClientReaderWriter<EchoRequest, EchoResponse>* reader) { - EchoResponse response; - while (reader->Read(&response)) { - // Just drain out the responses as fast as possible. - } -} - -TEST_F(End2endTest, StreamingThroughput) { - ResetStub(); - grpc::ClientContext context; - auto stream = stub_->BidiStream(&context); - - auto reader = stream.get(); - std::thread receiver(std::bind(Drainer, reader)); - - for (int i = 0; i < 10000; i++) { - EchoRequest request; - request.set_message(kLargeString); - ASSERT_TRUE(stream->Write(request)); - if (i % 1000 == 0) { - gpr_log(GPR_INFO, "Send count = %d", i); - } - } - stream->WritesDone(); - receiver.join(); -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/thread/ya.make_ b/contrib/libs/grpc/test/cpp/end2end/thread/ya.make_ deleted file mode 100644 index afabda1c8f..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/thread/ya.make_ +++ /dev/null @@ -1,31 +0,0 @@ -GTEST_UGLY() - -OWNER( - dvshkurko - g:ymake -) - -ADDINCL( - ${ARCADIA_ROOT}/contrib/libs/grpc -) - -PEERDIR( - contrib/libs/grpc/src/proto/grpc/core - contrib/libs/grpc/src/proto/grpc/testing - contrib/libs/grpc/src/proto/grpc/testing/duplicate - contrib/libs/grpc/test/core/util - contrib/libs/grpc/test/cpp/end2end - contrib/libs/grpc/test/cpp/util -) - -NO_COMPILER_WARNINGS() - -SRCDIR( - contrib/libs/grpc/test/cpp/end2end -) - -SRCS( - thread_stress_test.cc -) - -END() diff --git a/contrib/libs/grpc/test/cpp/end2end/thread_stress_test.cc b/contrib/libs/grpc/test/cpp/end2end/thread_stress_test.cc deleted file mode 100644 index 15740cc2ce..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/thread_stress_test.cc +++ /dev/null @@ -1,440 +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. - * - */ - -#include <cinttypes> -#include <mutex> -#include <thread> - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/impl/codegen/sync.h> -#include <grpcpp/resource_quota.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/surface/api_trace.h" -#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -const int kNumThreads = 100; // Number of threads -const int kNumAsyncSendThreads = 2; -const int kNumAsyncReceiveThreads = 50; -const int kNumAsyncServerThreads = 50; -const int kNumRpcs = 1000; // Number of RPCs per thread - -namespace grpc { -namespace testing { - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - TestServiceImpl() {} - - Status Echo(ServerContext* /*context*/, const EchoRequest* request, - EchoResponse* response) override { - response->set_message(request->message()); - return Status::OK; - } -}; - -template <class Service> -class CommonStressTest { - public: - CommonStressTest() : kMaxMessageSize_(8192) { -#if TARGET_OS_IPHONE - // Workaround Apple CFStream bug - gpr_setenv("grpc_cfstream", "0"); -#endif - } - virtual ~CommonStressTest() {} - virtual void SetUp() = 0; - virtual void TearDown() = 0; - virtual void ResetStub() = 0; - virtual bool AllowExhaustion() = 0; - grpc::testing::EchoTestService::Stub* GetStub() { return stub_.get(); } - - protected: - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - - virtual void SetUpStart(ServerBuilder* builder, Service* service) = 0; - void SetUpStartCommon(ServerBuilder* builder, Service* service) { - builder->RegisterService(service); - builder->SetMaxMessageSize( - kMaxMessageSize_); // For testing max message size. - } - void SetUpEnd(ServerBuilder* builder) { server_ = builder->BuildAndStart(); } - void TearDownStart() { server_->Shutdown(); } - void TearDownEnd() {} - - private: - const int kMaxMessageSize_; -}; - -template <class Service> -class CommonStressTestInsecure : public CommonStressTest<Service> { - public: - void ResetStub() override { - std::shared_ptr<Channel> channel = grpc::CreateChannel( - server_address_.str(), InsecureChannelCredentials()); - this->stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - bool AllowExhaustion() override { return false; } - - protected: - void SetUpStart(ServerBuilder* builder, Service* service) override { - int port = 5003; // grpc_pick_unused_port_or_die(); - this->server_address_ << "localhost:" << port; - // Setup server - builder->AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - this->SetUpStartCommon(builder, service); - } - - private: - std::ostringstream server_address_; -}; - -template <class Service, bool allow_resource_exhaustion> -class CommonStressTestInproc : public CommonStressTest<Service> { - public: - void ResetStub() override { - ChannelArguments args; - std::shared_ptr<Channel> channel = this->server_->InProcessChannel(args); - this->stub_ = grpc::testing::EchoTestService::NewStub(channel); - } - bool AllowExhaustion() override { return allow_resource_exhaustion; } - - protected: - void SetUpStart(ServerBuilder* builder, Service* service) override { - this->SetUpStartCommon(builder, service); - } -}; - -template <class BaseClass> -class CommonStressTestSyncServer : public BaseClass { - public: - void SetUp() override { - ServerBuilder builder; - this->SetUpStart(&builder, &service_); - this->SetUpEnd(&builder); - } - void TearDown() override { - this->TearDownStart(); - this->TearDownEnd(); - } - - private: - TestServiceImpl service_; -}; - -template <class BaseClass> -class CommonStressTestSyncServerLowThreadCount : public BaseClass { - public: - void SetUp() override { - ServerBuilder builder; - ResourceQuota quota; - this->SetUpStart(&builder, &service_); - quota.SetMaxThreads(4); - builder.SetResourceQuota(quota); - this->SetUpEnd(&builder); - } - void TearDown() override { - this->TearDownStart(); - this->TearDownEnd(); - } - - private: - TestServiceImpl service_; -}; - -template <class BaseClass> -class CommonStressTestAsyncServer : public BaseClass { - public: - CommonStressTestAsyncServer() : contexts_(kNumAsyncServerThreads * 100) {} - void SetUp() override { - shutting_down_ = false; - ServerBuilder builder; - this->SetUpStart(&builder, &service_); - cq_ = builder.AddCompletionQueue(); - this->SetUpEnd(&builder); - for (int i = 0; i < kNumAsyncServerThreads * 100; i++) { - RefreshContext(i); - } - for (int i = 0; i < kNumAsyncServerThreads; i++) { - server_threads_.emplace_back(&CommonStressTestAsyncServer::ProcessRpcs, - this); - } - } - void TearDown() override { - { - grpc::internal::MutexLock l(&mu_); - this->TearDownStart(); - shutting_down_ = true; - cq_->Shutdown(); - } - - for (int i = 0; i < kNumAsyncServerThreads; i++) { - server_threads_[i].join(); - } - - void* ignored_tag; - bool ignored_ok; - while (cq_->Next(&ignored_tag, &ignored_ok)) { - } - this->TearDownEnd(); - } - - private: - void ProcessRpcs() { - void* tag; - bool ok; - while (cq_->Next(&tag, &ok)) { - if (ok) { - int i = static_cast<int>(reinterpret_cast<intptr_t>(tag)); - switch (contexts_[i].state) { - case Context::READY: { - contexts_[i].state = Context::DONE; - EchoResponse send_response; - send_response.set_message(contexts_[i].recv_request.message()); - contexts_[i].response_writer->Finish(send_response, Status::OK, - tag); - break; - } - case Context::DONE: - RefreshContext(i); - break; - } - } - } - } - void RefreshContext(int i) { - grpc::internal::MutexLock l(&mu_); - if (!shutting_down_) { - contexts_[i].state = Context::READY; - contexts_[i].srv_ctx.reset(new ServerContext); - contexts_[i].response_writer.reset( - new grpc::ServerAsyncResponseWriter<EchoResponse>( - contexts_[i].srv_ctx.get())); - service_.RequestEcho(contexts_[i].srv_ctx.get(), - &contexts_[i].recv_request, - contexts_[i].response_writer.get(), cq_.get(), - cq_.get(), reinterpret_cast<void*>(i)); - } - } - struct Context { - std::unique_ptr<ServerContext> srv_ctx; - std::unique_ptr<grpc::ServerAsyncResponseWriter<EchoResponse>> - response_writer; - EchoRequest recv_request; - enum { READY, DONE } state; - }; - std::vector<Context> contexts_; - ::grpc::testing::EchoTestService::AsyncService service_; - std::unique_ptr<ServerCompletionQueue> cq_; - bool shutting_down_; - grpc::internal::Mutex mu_; - std::vector<std::thread> server_threads_; -}; - -template <class Common> -class End2endTest : public ::testing::Test { - protected: - End2endTest() {} - void SetUp() override { common_.SetUp(); } - void TearDown() override { common_.TearDown(); } - void ResetStub() { common_.ResetStub(); } - - Common common_; -}; - -static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs, - bool allow_exhaustion, gpr_atm* errors) { - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - for (int i = 0; i < num_rpcs; ++i) { - ClientContext context; - Status s = stub->Echo(&context, request, &response); - EXPECT_TRUE(s.ok() || (allow_exhaustion && - s.error_code() == StatusCode::RESOURCE_EXHAUSTED)); - if (!s.ok()) { - if (!(allow_exhaustion && - s.error_code() == StatusCode::RESOURCE_EXHAUSTED)) { - gpr_log(GPR_ERROR, "RPC error: %d: %s", s.error_code(), - s.error_message().c_str()); - } - gpr_atm_no_barrier_fetch_add(errors, static_cast<gpr_atm>(1)); - } else { - EXPECT_EQ(response.message(), request.message()); - } - } -} - -typedef ::testing::Types< - CommonStressTestSyncServer<CommonStressTestInsecure<TestServiceImpl>>, - CommonStressTestSyncServer<CommonStressTestInproc<TestServiceImpl, false>>, - CommonStressTestSyncServerLowThreadCount< - CommonStressTestInproc<TestServiceImpl, true>>, - CommonStressTestAsyncServer< - CommonStressTestInsecure<grpc::testing::EchoTestService::AsyncService>>, - CommonStressTestAsyncServer<CommonStressTestInproc< - grpc::testing::EchoTestService::AsyncService, false>>> - CommonTypes; -TYPED_TEST_SUITE(End2endTest, CommonTypes); -TYPED_TEST(End2endTest, ThreadStress) { - this->common_.ResetStub(); - std::vector<std::thread> threads; - gpr_atm errors; - gpr_atm_rel_store(&errors, static_cast<gpr_atm>(0)); - threads.reserve(kNumThreads); - for (int i = 0; i < kNumThreads; ++i) { - threads.emplace_back(SendRpc, this->common_.GetStub(), kNumRpcs, - this->common_.AllowExhaustion(), &errors); - } - for (int i = 0; i < kNumThreads; ++i) { - threads[i].join(); - } - uint64_t error_cnt = static_cast<uint64_t>(gpr_atm_no_barrier_load(&errors)); - if (error_cnt != 0) { - gpr_log(GPR_INFO, "RPC error count: %" PRIu64, error_cnt); - } - // If this test allows resource exhaustion, expect that it actually sees some - if (this->common_.AllowExhaustion()) { - EXPECT_GT(error_cnt, static_cast<uint64_t>(0)); - } -} - -template <class Common> -class AsyncClientEnd2endTest : public ::testing::Test { - protected: - AsyncClientEnd2endTest() : rpcs_outstanding_(0) {} - - void SetUp() override { common_.SetUp(); } - void TearDown() override { - void* ignored_tag; - bool ignored_ok; - while (cq_.Next(&ignored_tag, &ignored_ok)) { - } - common_.TearDown(); - } - - void Wait() { - grpc::internal::MutexLock l(&mu_); - while (rpcs_outstanding_ != 0) { - cv_.Wait(&mu_); - } - - cq_.Shutdown(); - } - - struct AsyncClientCall { - EchoResponse response; - ClientContext context; - Status status; - std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader; - }; - - void AsyncSendRpc(int num_rpcs) { - for (int i = 0; i < num_rpcs; ++i) { - AsyncClientCall* call = new AsyncClientCall; - EchoRequest request; - request.set_message(TString("Hello: " + grpc::to_string(i)).c_str()); - call->response_reader = - common_.GetStub()->AsyncEcho(&call->context, request, &cq_); - call->response_reader->Finish(&call->response, &call->status, call); - - grpc::internal::MutexLock l(&mu_); - rpcs_outstanding_++; - } - } - - void AsyncCompleteRpc() { - while (true) { - void* got_tag; - bool ok = false; - if (!cq_.Next(&got_tag, &ok)) break; - AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag); - if (!ok) { - gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code()); - } - delete call; - - bool notify; - { - grpc::internal::MutexLock l(&mu_); - rpcs_outstanding_--; - notify = (rpcs_outstanding_ == 0); - } - if (notify) { - cv_.Signal(); - } - } - } - - Common common_; - CompletionQueue cq_; - grpc::internal::Mutex mu_; - grpc::internal::CondVar cv_; - int rpcs_outstanding_; -}; - -TYPED_TEST_SUITE(AsyncClientEnd2endTest, CommonTypes); -TYPED_TEST(AsyncClientEnd2endTest, ThreadStress) { - this->common_.ResetStub(); - std::vector<std::thread> send_threads, completion_threads; - for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { - completion_threads.emplace_back( - &AsyncClientEnd2endTest_ThreadStress_Test<TypeParam>::AsyncCompleteRpc, - this); - } - for (int i = 0; i < kNumAsyncSendThreads; ++i) { - send_threads.emplace_back( - &AsyncClientEnd2endTest_ThreadStress_Test<TypeParam>::AsyncSendRpc, - this, kNumRpcs); - } - for (int i = 0; i < kNumAsyncSendThreads; ++i) { - send_threads[i].join(); - } - - this->Wait(); - for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { - completion_threads[i].join(); - } -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/end2end/time_change_test.cc b/contrib/libs/grpc/test/cpp/end2end/time_change_test.cc deleted file mode 100644 index c058b62d61..0000000000 --- a/contrib/libs/grpc/test/cpp/end2end/time_change_test.cc +++ /dev/null @@ -1,371 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <sys/time.h> - -#include <thread> - -#include <gtest/gtest.h> - -#include "y_absl/memory/memory.h" - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/iomgr/timer.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/end2end/test_service_impl.h" -#include "test/cpp/util/subprocess.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -static TString g_root; - -static gpr_mu g_mu; -extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); -gpr_timespec (*gpr_now_impl_orig)(gpr_clock_type clock_type) = gpr_now_impl; -static int g_time_shift_sec = 0; -static int g_time_shift_nsec = 0; -static gpr_timespec now_impl(gpr_clock_type clock) { - auto ts = gpr_now_impl_orig(clock); - // We only manipulate the realtime clock to simulate changes in wall-clock - // time - if (clock != GPR_CLOCK_REALTIME) { - return ts; - } - GPR_ASSERT(ts.tv_nsec >= 0); - GPR_ASSERT(ts.tv_nsec < GPR_NS_PER_SEC); - gpr_mu_lock(&g_mu); - ts.tv_sec += g_time_shift_sec; - ts.tv_nsec += g_time_shift_nsec; - gpr_mu_unlock(&g_mu); - if (ts.tv_nsec >= GPR_NS_PER_SEC) { - ts.tv_nsec -= GPR_NS_PER_SEC; - ++ts.tv_sec; - } else if (ts.tv_nsec < 0) { - --ts.tv_sec; - ts.tv_nsec = GPR_NS_PER_SEC + ts.tv_nsec; - } - return ts; -} - -// offset the value returned by gpr_now(GPR_CLOCK_REALTIME) by msecs -// milliseconds -static void set_now_offset(int msecs) { - gpr_mu_lock(&g_mu); - g_time_shift_sec = msecs / 1000; - g_time_shift_nsec = (msecs % 1000) * 1e6; - gpr_mu_unlock(&g_mu); -} - -// restore the original implementation of gpr_now() -static void reset_now_offset() { - gpr_mu_lock(&g_mu); - g_time_shift_sec = 0; - g_time_shift_nsec = 0; - gpr_mu_unlock(&g_mu); -} - -namespace grpc { -namespace testing { - -namespace { - -// gpr_now() is called with invalid clock_type -TEST(TimespecTest, GprNowInvalidClockType) { - // initialize to some junk value - gpr_clock_type invalid_clock_type = static_cast<gpr_clock_type>(32641); - EXPECT_DEATH(gpr_now(invalid_clock_type), ".*"); -} - -// Add timespan with negative nanoseconds -TEST(TimespecTest, GprTimeAddNegativeNs) { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec bad_ts = {1, -1000, GPR_TIMESPAN}; - EXPECT_DEATH(gpr_time_add(now, bad_ts), ".*"); -} - -// Subtract timespan with negative nanoseconds -TEST(TimespecTest, GprTimeSubNegativeNs) { - // Nanoseconds must always be positive. Negative timestamps are represented by - // (negative seconds, positive nanoseconds) - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec bad_ts = {1, -1000, GPR_TIMESPAN}; - EXPECT_DEATH(gpr_time_sub(now, bad_ts), ".*"); -} - -// Add negative milliseconds to gpr_timespec -TEST(TimespecTest, GrpcNegativeMillisToTimespec) { - // -1500 milliseconds converts to timespec (-2 secs, 5 * 10^8 nsec) - gpr_timespec ts = grpc_millis_to_timespec(-1500, GPR_CLOCK_MONOTONIC); - GPR_ASSERT(ts.tv_sec = -2); - GPR_ASSERT(ts.tv_nsec = 5e8); - GPR_ASSERT(ts.clock_type == GPR_CLOCK_MONOTONIC); -} - -class TimeChangeTest : public ::testing::Test { - protected: - TimeChangeTest() {} - - static void SetUpTestCase() { - auto port = grpc_pick_unused_port_or_die(); - std::ostringstream addr_stream; - addr_stream << "localhost:" << port; - server_address_ = addr_stream.str(); - server_ = y_absl::make_unique<SubProcess>(std::vector<TString>({ - g_root + "/client_crash_test_server", - "--address=" + server_address_, - })); - GPR_ASSERT(server_); - // connect to server and make sure it's reachable. - auto channel = - grpc::CreateChannel(server_address_, InsecureChannelCredentials()); - GPR_ASSERT(channel); - EXPECT_TRUE(channel->WaitForConnected( - grpc_timeout_milliseconds_to_deadline(30000))); - } - - static void TearDownTestCase() { server_.reset(); } - - void SetUp() override { - channel_ = - grpc::CreateChannel(server_address_, InsecureChannelCredentials()); - GPR_ASSERT(channel_); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - void TearDown() override { reset_now_offset(); } - - std::unique_ptr<grpc::testing::EchoTestService::Stub> CreateStub() { - return grpc::testing::EchoTestService::NewStub(channel_); - } - - std::shared_ptr<Channel> GetChannel() { return channel_; } - // time jump offsets in milliseconds - const int TIME_OFFSET1 = 20123; - const int TIME_OFFSET2 = 5678; - - private: - static TString server_address_; - static std::unique_ptr<SubProcess> server_; - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; -}; -TString TimeChangeTest::server_address_; -std::unique_ptr<SubProcess> TimeChangeTest::server_; - -// Wall-clock time jumps forward on client before bidi stream is created -TEST_F(TimeChangeTest, TimeJumpForwardBeforeStreamCreated) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "1"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - - // time jumps forward by TIME_OFFSET1 milliseconds - set_now_offset(TIME_OFFSET1); - auto stream = stub->BidiStream(&context); - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - -// Wall-clock time jumps back on client before bidi stream is created -TEST_F(TimeChangeTest, TimeJumpBackBeforeStreamCreated) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "1"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - - // time jumps back by TIME_OFFSET1 milliseconds - set_now_offset(-TIME_OFFSET1); - auto stream = stub->BidiStream(&context); - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - EXPECT_EQ(request.message(), response.message()); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - -// Wall-clock time jumps forward on client while call is in progress -TEST_F(TimeChangeTest, TimeJumpForwardAfterStreamCreated) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "2"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - - // time jumps forward by TIME_OFFSET1 milliseconds. - set_now_offset(TIME_OFFSET1); - - request.set_message("World"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - -// Wall-clock time jumps back on client while call is in progress -TEST_F(TimeChangeTest, TimeJumpBackAfterStreamCreated) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "2"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->Read(&response)); - - // time jumps back TIME_OFFSET1 milliseconds. - set_now_offset(-TIME_OFFSET1); - - request.set_message("World"); - EXPECT_TRUE(stream->Write(request)); - EXPECT_TRUE(stream->WritesDone()); - EXPECT_TRUE(stream->Read(&response)); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - -// Wall-clock time jumps forward and backwards during call -TEST_F(TimeChangeTest, TimeJumpForwardAndBackDuringCall) { - EchoRequest request; - EchoResponse response; - ClientContext context; - context.set_deadline(grpc_timeout_milliseconds_to_deadline(5000)); - context.AddMetadata(kServerResponseStreamsToSend, "2"); - - auto channel = GetChannel(); - GPR_ASSERT(channel); - - EXPECT_TRUE( - channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(5000))); - auto stub = CreateStub(); - auto stream = stub->BidiStream(&context); - - request.set_message("Hello"); - EXPECT_TRUE(stream->Write(request)); - - // time jumps back by TIME_OFFSET2 milliseconds - set_now_offset(-TIME_OFFSET2); - - EXPECT_TRUE(stream->Read(&response)); - request.set_message("World"); - - // time jumps forward by TIME_OFFSET milliseconds - set_now_offset(TIME_OFFSET1); - - EXPECT_TRUE(stream->Write(request)); - - // time jumps back by TIME_OFFSET2 milliseconds - set_now_offset(-TIME_OFFSET2); - - EXPECT_TRUE(stream->WritesDone()); - - // time jumps back by TIME_OFFSET2 milliseconds - set_now_offset(-TIME_OFFSET2); - - EXPECT_TRUE(stream->Read(&response)); - - // time jumps back by TIME_OFFSET2 milliseconds - set_now_offset(-TIME_OFFSET2); - - auto status = stream->Finish(); - EXPECT_TRUE(status.ok()); -} - -} // namespace - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - TString me = argv[0]; - // get index of last slash in path to test binary - auto lslash = me.rfind('/'); - // set g_root = path to directory containing test binary - if (lslash != TString::npos) { - g_root = me.substr(0, lslash); - } else { - g_root = "."; - } - - gpr_mu_init(&g_mu); - gpr_now_impl = now_impl; - - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - auto ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/util/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/test/cpp/util/.yandex_meta/licenses.list.txt deleted file mode 100644 index c498b515e1..0000000000 --- a/contrib/libs/grpc/test/cpp/util/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,50 +0,0 @@ -====================Apache-2.0==================== - * 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. - - -====================Apache-2.0==================== -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2015-2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2017 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2018 gRPC authors. - - -====================COPYRIGHT==================== -// Copyright 2021 gRPC authors. diff --git a/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc b/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc deleted file mode 100644 index ab18b5ecc6..0000000000 --- a/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc +++ /dev/null @@ -1,163 +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. - * - */ - -#include <cstring> -#include <vector> - -#include <gtest/gtest.h> - -#include <grpc++/support/byte_buffer.h> -#include <grpc/grpc.h> -#include <grpc/slice.h> -#include <grpcpp/impl/grpc_library.h> -#include <grpcpp/support/slice.h> - -#include "test/core/util/test_config.h" - -namespace grpc { - -static internal::GrpcLibraryInitializer g_gli_initializer; - -namespace { - -const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world"; - -class ByteBufferTest : public ::testing::Test { - protected: - static void SetUpTestCase() { grpc_init(); } - - static void TearDownTestCase() { grpc_shutdown(); } -}; - -TEST_F(ByteBufferTest, CopyCtor) { - ByteBuffer buffer1; - EXPECT_FALSE(buffer1.Valid()); - const ByteBuffer& buffer2 = buffer1; - EXPECT_FALSE(buffer2.Valid()); -} - -TEST_F(ByteBufferTest, CreateFromSingleSlice) { - Slice s(kContent1); - ByteBuffer buffer(&s, 1); - EXPECT_EQ(strlen(kContent1), buffer.Length()); -} - -TEST_F(ByteBufferTest, CreateFromVector) { - std::vector<Slice> slices; - slices.emplace_back(kContent1); - slices.emplace_back(kContent2); - ByteBuffer buffer(&slices[0], 2); - EXPECT_EQ(strlen(kContent1) + strlen(kContent2), buffer.Length()); -} - -TEST_F(ByteBufferTest, Clear) { - Slice s(kContent1); - ByteBuffer buffer(&s, 1); - buffer.Clear(); - EXPECT_EQ(static_cast<size_t>(0), buffer.Length()); -} - -TEST_F(ByteBufferTest, Length) { - std::vector<Slice> slices; - slices.emplace_back(kContent1); - slices.emplace_back(kContent2); - ByteBuffer buffer(&slices[0], 2); - EXPECT_EQ(strlen(kContent1) + strlen(kContent2), buffer.Length()); -} - -bool SliceEqual(const Slice& a, grpc_slice b) { - if (a.size() != GRPC_SLICE_LENGTH(b)) { - return false; - } - for (size_t i = 0; i < a.size(); i++) { - if (a.begin()[i] != GRPC_SLICE_START_PTR(b)[i]) { - return false; - } - } - return true; -} - -TEST_F(ByteBufferTest, Dump) { - grpc_slice hello = grpc_slice_from_copied_string(kContent1); - grpc_slice world = grpc_slice_from_copied_string(kContent2); - std::vector<Slice> slices; - slices.push_back(Slice(hello, Slice::STEAL_REF)); - slices.push_back(Slice(world, Slice::STEAL_REF)); - ByteBuffer buffer(&slices[0], 2); - slices.clear(); - (void)buffer.Dump(&slices); - EXPECT_TRUE(SliceEqual(slices[0], hello)); - EXPECT_TRUE(SliceEqual(slices[1], world)); -} - -TEST_F(ByteBufferTest, SerializationMakesCopy) { - grpc_slice hello = grpc_slice_from_copied_string(kContent1); - grpc_slice world = grpc_slice_from_copied_string(kContent2); - std::vector<Slice> slices; - slices.push_back(Slice(hello, Slice::STEAL_REF)); - slices.push_back(Slice(world, Slice::STEAL_REF)); - ByteBuffer send_buffer; - bool owned = false; - ByteBuffer buffer(&slices[0], 2); - slices.clear(); - auto status = SerializationTraits<ByteBuffer, void>::Serialize( - buffer, &send_buffer, &owned); - EXPECT_TRUE(status.ok()); - EXPECT_TRUE(owned); - EXPECT_TRUE(send_buffer.Valid()); -} - -TEST_F(ByteBufferTest, TrySingleSliceWithSingleSlice) { - std::vector<Slice> slices; - slices.emplace_back(kContent1); - ByteBuffer buffer(&slices[0], 1); - Slice slice; - EXPECT_TRUE(buffer.TrySingleSlice(&slice).ok()); - EXPECT_EQ(slice.size(), slices[0].size()); - EXPECT_EQ(memcmp(slice.begin(), slices[0].begin(), slice.size()), 0); -} - -TEST_F(ByteBufferTest, TrySingleSliceWithMultipleSlices) { - std::vector<Slice> slices; - slices.emplace_back(kContent1); - slices.emplace_back(kContent2); - ByteBuffer buffer(&slices[0], 2); - Slice slice; - EXPECT_FALSE(buffer.TrySingleSlice(&slice).ok()); -} - -TEST_F(ByteBufferTest, DumpToSingleSlice) { - std::vector<Slice> slices; - slices.emplace_back(kContent1); - slices.emplace_back(kContent2); - ByteBuffer buffer(&slices[0], 2); - Slice slice; - EXPECT_TRUE(buffer.DumpToSingleSlice(&slice).ok()); - EXPECT_EQ(strlen(kContent1) + strlen(kContent2), slice.size()); -} - -} // namespace -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc b/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc deleted file mode 100644 index 672e5c6544..0000000000 --- a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <grpc/support/port_platform.h> - -#include "test/cpp/util/channel_trace_proto_helper.h" - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpcpp/impl/codegen/config.h> -#include <grpcpp/impl/codegen/config_protobuf.h> - -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/json/json.h" -#include "src/proto/grpc/channelz/channelz.pb.h" - -namespace grpc { - -namespace { - -// Generic helper that takes in a json string, converts it to a proto, and -// then back to json. This ensures that the json string was correctly formatted -// according to https://developers.google.com/protocol-buffers/docs/proto3#json -template <typename Message> -void VaidateProtoJsonTranslation(const TString& json_str) { - Message msg; - grpc::protobuf::json::JsonParseOptions parse_options; - // If the following line is failing, then uncomment the last line of the - // comment, and uncomment the lines that print the two strings. You can - // then compare the output, and determine what fields are missing. - // - // parse_options.ignore_unknown_fields = true; - grpc::protobuf::util::Status s = - grpc::protobuf::json::JsonStringToMessage(json_str, &msg, parse_options); - EXPECT_TRUE(s.ok()); - TString proto_json_str; - grpc::protobuf::json::JsonPrintOptions print_options; - // We usually do not want this to be true, however it can be helpful to - // uncomment and see the output produced then all fields are printed. - // print_options.always_print_primitive_fields = true; - s = grpc::protobuf::json::MessageToJsonString(msg, &proto_json_str); - EXPECT_TRUE(s.ok()); - // Parse JSON and re-dump to string, to make sure formatting is the - // same as what would be generated by our JSON library. - grpc_error_handle error = GRPC_ERROR_NONE; - grpc_core::Json parsed_json = - grpc_core::Json::Parse(proto_json_str.c_str(), &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); - ASSERT_EQ(parsed_json.type(), grpc_core::Json::Type::OBJECT); - proto_json_str = parsed_json.Dump(); - // uncomment these to compare the json strings. - // gpr_log(GPR_ERROR, "tracer json: %s", json_str.c_str()); - // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); - EXPECT_EQ(json_str, proto_json_str); -} - -} // namespace - -namespace testing { - -void ValidateChannelTraceProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::ChannelTrace>(json_c_str); -} - -void ValidateChannelProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::Channel>(json_c_str); -} - -void ValidateGetTopChannelsResponseProtoJsonTranslation( - const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::GetTopChannelsResponse>( - json_c_str); -} - -void ValidateGetChannelResponseProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::GetChannelResponse>( - json_c_str); -} - -void ValidateGetServerResponseProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::GetServerResponse>( - json_c_str); -} - -void ValidateSubchannelProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::Subchannel>(json_c_str); -} - -void ValidateServerProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::Server>(json_c_str); -} - -void ValidateGetServersResponseProtoJsonTranslation(const char* json_c_str) { - VaidateProtoJsonTranslation<grpc::channelz::v1::GetServersResponse>( - json_c_str); -} - -} // namespace testing -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.h b/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.h deleted file mode 100644 index 664e899deb..0000000000 --- a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H -#define GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H - -namespace grpc { -namespace testing { - -void ValidateChannelTraceProtoJsonTranslation(const char* json_c_str); -void ValidateChannelProtoJsonTranslation(const char* json_c_str); -void ValidateGetTopChannelsResponseProtoJsonTranslation(const char* json_c_str); -void ValidateGetChannelResponseProtoJsonTranslation(const char* json_c_str); -void ValidateGetServerResponseProtoJsonTranslation(const char* json_c_str); -void ValidateSubchannelProtoJsonTranslation(const char* json_c_str); -void ValidateServerProtoJsonTranslation(const char* json_c_str); -void ValidateGetServersResponseProtoJsonTranslation(const char* json_c_str); - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H diff --git a/contrib/libs/grpc/test/cpp/util/channelz_sampler.cc b/contrib/libs/grpc/test/cpp/util/channelz_sampler.cc deleted file mode 100644 index 65d6a18a07..0000000000 --- a/contrib/libs/grpc/test/cpp/util/channelz_sampler.cc +++ /dev/null @@ -1,593 +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. - * - */ -#include <grpc/support/port_platform.h> - -#include <unistd.h> - -#include <cstdlib> -#include <fstream> -#include <iostream> -#include <memory> -#include <ostream> -#include <queue> -#include <util/generic/string.h> - -#include "y_absl/flags/flag.h" -#include "y_absl/strings/str_format.h" -#include "y_absl/strings/str_join.h" -#include "google/protobuf/text_format.h" - -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/channelz_service_plugin.h> -#include <grpcpp/grpcpp.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/json/json.h" -#include "src/cpp/server/channelz/channelz_service.h" -#include "src/proto/grpc/channelz/channelz.pb.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/test_config.h" -#include "test/cpp/util/test_credentials_provider.h" - -Y_ABSL_FLAG(TString, server_address, "", "channelz server address"); -Y_ABSL_FLAG(TString, custom_credentials_type, "", "custom credentials type"); -Y_ABSL_FLAG(int64_t, sampling_times, 1, "number of sampling"); -// TODO(Capstan): Consider using y_absl::Duration -Y_ABSL_FLAG(int64_t, sampling_interval_seconds, 0, - "sampling interval in seconds"); -Y_ABSL_FLAG(TString, output_json, "", "output filename in json format"); - -namespace { -using grpc::ClientContext; -using grpc::Status; -using grpc::StatusCode; -using grpc::channelz::v1::GetChannelRequest; -using grpc::channelz::v1::GetChannelResponse; -using grpc::channelz::v1::GetServersRequest; -using grpc::channelz::v1::GetServersResponse; -using grpc::channelz::v1::GetSocketRequest; -using grpc::channelz::v1::GetSocketResponse; -using grpc::channelz::v1::GetSubchannelRequest; -using grpc::channelz::v1::GetSubchannelResponse; -using grpc::channelz::v1::GetTopChannelsRequest; -using grpc::channelz::v1::GetTopChannelsResponse; -} // namespace - -class ChannelzSampler final { - public: - // Get server_id of a server - int64_t GetServerID(const grpc::channelz::v1::Server& server) { - return server.ref().server_id(); - } - - // Get channel_id of a channel - inline int64_t GetChannelID(const grpc::channelz::v1::Channel& channel) { - return channel.ref().channel_id(); - } - - // Get subchannel_id of a subchannel - inline int64_t GetSubchannelID( - const grpc::channelz::v1::Subchannel& subchannel) { - return subchannel.ref().subchannel_id(); - } - - // Get socket_id of a socket - inline int64_t GetSocketID(const grpc::channelz::v1::Socket& socket) { - return socket.ref().socket_id(); - } - - // Get name of a server - inline TString GetServerName(const grpc::channelz::v1::Server& server) { - return server.ref().name(); - } - - // Get name of a channel - inline TString GetChannelName( - const grpc::channelz::v1::Channel& channel) { - return channel.ref().name(); - } - - // Get name of a subchannel - inline TString GetSubchannelName( - const grpc::channelz::v1::Subchannel& subchannel) { - return subchannel.ref().name(); - } - - // Get name of a socket - inline TString GetSocketName(const grpc::channelz::v1::Socket& socket) { - return socket.ref().name(); - } - - // Get a channel based on channel_id - grpc::channelz::v1::Channel GetChannelRPC(int64_t channel_id) { - GetChannelRequest get_channel_request; - get_channel_request.set_channel_id(channel_id); - GetChannelResponse get_channel_response; - ClientContext get_channel_context; - get_channel_context.set_deadline( - grpc_timeout_seconds_to_deadline(rpc_timeout_seconds_)); - 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()); - GPR_ASSERT(0); - } - return get_channel_response.channel(); - } - - // Get a subchannel based on subchannel_id - grpc::channelz::v1::Subchannel GetSubchannelRPC(int64_t subchannel_id) { - GetSubchannelRequest get_subchannel_request; - get_subchannel_request.set_subchannel_id(subchannel_id); - GetSubchannelResponse get_subchannel_response; - ClientContext get_subchannel_context; - get_subchannel_context.set_deadline( - grpc_timeout_seconds_to_deadline(rpc_timeout_seconds_)); - Status status = channelz_stub_->GetSubchannel(&get_subchannel_context, - get_subchannel_request, - &get_subchannel_response); - if (!status.ok()) { - gpr_log(GPR_ERROR, "GetSubchannelRPC failed: %s", - get_subchannel_context.debug_error_string().c_str()); - GPR_ASSERT(0); - } - return get_subchannel_response.subchannel(); - } - - // get a socket based on socket_id - grpc::channelz::v1::Socket GetSocketRPC(int64_t socket_id) { - GetSocketRequest get_socket_request; - get_socket_request.set_socket_id(socket_id); - GetSocketResponse get_socket_response; - ClientContext get_socket_context; - get_socket_context.set_deadline( - grpc_timeout_seconds_to_deadline(rpc_timeout_seconds_)); - 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()); - GPR_ASSERT(0); - } - return get_socket_response.socket(); - } - - // get the descedent channels/subchannels/sockets of a channel - // push descedent channels/subchannels to queue for layer traverse - // store descedent channels/subchannels/sockets for dumping data - void GetChannelDescedence( - const grpc::channelz::v1::Channel& channel, - std::queue<grpc::channelz::v1::Channel>& channel_queue, - std::queue<grpc::channelz::v1::Subchannel>& subchannel_queue) { - std::cout << " Channel ID" << GetChannelID(channel) << "_" - << GetChannelName(channel) << " descendence - "; - if (channel.channel_ref_size() > 0 || channel.subchannel_ref_size() > 0) { - if (channel.channel_ref_size() > 0) { - std::cout << "channel: "; - for (const auto& _channelref : channel.channel_ref()) { - int64_t ch_id = _channelref.channel_id(); - std::cout << "ID" << ch_id << "_" << _channelref.name() << " "; - grpc::channelz::v1::Channel ch = GetChannelRPC(ch_id); - channel_queue.push(ch); - if (CheckID(ch_id)) { - all_channels_.push_back(ch); - StoreChannelInJson(ch); - } - } - if (channel.subchannel_ref_size() > 0) { - std::cout << ", "; - } - } - if (channel.subchannel_ref_size() > 0) { - std::cout << "subchannel: "; - for (const auto& _subchannelref : channel.subchannel_ref()) { - int64_t subch_id = _subchannelref.subchannel_id(); - std::cout << "ID" << subch_id << "_" << _subchannelref.name() << " "; - grpc::channelz::v1::Subchannel subch = GetSubchannelRPC(subch_id); - subchannel_queue.push(subch); - if (CheckID(subch_id)) { - all_subchannels_.push_back(subch); - StoreSubchannelInJson(subch); - } - } - } - } else if (channel.socket_ref_size() > 0) { - std::cout << "socket: "; - for (const auto& _socketref : channel.socket_ref()) { - int64_t so_id = _socketref.socket_id(); - std::cout << "ID" << so_id << "_" << _socketref.name() << " "; - grpc::channelz::v1::Socket so = GetSocketRPC(so_id); - if (CheckID(so_id)) { - all_sockets_.push_back(so); - StoreSocketInJson(so); - } - } - } - std::cout << std::endl; - } - - // get the descedent channels/subchannels/sockets of a subchannel - // push descedent channels/subchannels to queue for layer traverse - // store descedent channels/subchannels/sockets for dumping data - void GetSubchannelDescedence( - grpc::channelz::v1::Subchannel& subchannel, - std::queue<grpc::channelz::v1::Channel>& channel_queue, - std::queue<grpc::channelz::v1::Subchannel>& subchannel_queue) { - std::cout << " Subchannel ID" << GetSubchannelID(subchannel) << "_" - << GetSubchannelName(subchannel) << " descendence - "; - if (subchannel.channel_ref_size() > 0 || - subchannel.subchannel_ref_size() > 0) { - if (subchannel.channel_ref_size() > 0) { - std::cout << "channel: "; - for (const auto& _channelref : subchannel.channel_ref()) { - int64_t ch_id = _channelref.channel_id(); - std::cout << "ID" << ch_id << "_" << _channelref.name() << " "; - grpc::channelz::v1::Channel ch = GetChannelRPC(ch_id); - channel_queue.push(ch); - if (CheckID(ch_id)) { - all_channels_.push_back(ch); - StoreChannelInJson(ch); - } - } - if (subchannel.subchannel_ref_size() > 0) { - std::cout << ", "; - } - } - if (subchannel.subchannel_ref_size() > 0) { - std::cout << "subchannel: "; - for (const auto& _subchannelref : subchannel.subchannel_ref()) { - int64_t subch_id = _subchannelref.subchannel_id(); - std::cout << "ID" << subch_id << "_" << _subchannelref.name() << " "; - grpc::channelz::v1::Subchannel subch = GetSubchannelRPC(subch_id); - subchannel_queue.push(subch); - if (CheckID(subch_id)) { - all_subchannels_.push_back(subch); - StoreSubchannelInJson(subch); - } - } - } - } else if (subchannel.socket_ref_size() > 0) { - std::cout << "socket: "; - for (const auto& _socketref : subchannel.socket_ref()) { - int64_t so_id = _socketref.socket_id(); - std::cout << "ID" << so_id << "_" << _socketref.name() << " "; - grpc::channelz::v1::Socket so = GetSocketRPC(so_id); - if (CheckID(so_id)) { - all_sockets_.push_back(so); - StoreSocketInJson(so); - } - } - } - std::cout << std::endl; - } - - // Set up the channelz sampler client - // Initialize json as an array - void Setup(const TString& custom_credentials_type, - const TString& server_address) { - json_ = grpc_core::Json::Array(); - rpc_timeout_seconds_ = 20; - grpc::ChannelArguments channel_args; - std::shared_ptr<grpc::ChannelCredentials> channel_creds = - 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()); - GPR_ASSERT(0); - } - std::shared_ptr<grpc::Channel> channel = - CreateChannel(server_address, channel_creds); - channelz_stub_ = grpc::channelz::v1::Channelz::NewStub(channel); - } - - // Get all servers, keep querying until getting all - // Store servers for dumping data - // Need to check id repeating for servers - void GetServersRPC() { - int64_t server_start_id = 0; - while (true) { - GetServersRequest get_servers_request; - GetServersResponse get_servers_response; - ClientContext get_servers_context; - get_servers_context.set_deadline( - grpc_timeout_seconds_to_deadline(rpc_timeout_seconds_)); - get_servers_request.set_start_server_id(server_start_id); - Status status = channelz_stub_->GetServers( - &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."); - } else { - gpr_log(GPR_ERROR, - "GetServers RPC with GetServersRequest.server_start_id=%d, " - "failed: %s", - int(server_start_id), - get_servers_context.debug_error_string().c_str()); - } - GPR_ASSERT(0); - } - for (const auto& _server : get_servers_response.server()) { - all_servers_.push_back(_server); - StoreServerInJson(_server); - } - if (!get_servers_response.end()) { - server_start_id = GetServerID(all_servers_.back()) + 1; - } else { - break; - } - } - std::cout << "Number of servers = " << all_servers_.size() << std::endl; - } - - // Get sockets that belongs to servers - // Store sockets for dumping data - void GetSocketsOfServers() { - for (const auto& _server : all_servers_) { - std::cout << "Server ID" << GetServerID(_server) << "_" - << GetServerName(_server) << " listen_socket - "; - for (const auto& _socket : _server.listen_socket()) { - int64_t so_id = _socket.socket_id(); - std::cout << "ID" << so_id << "_" << _socket.name() << " "; - if (CheckID(so_id)) { - grpc::channelz::v1::Socket so = GetSocketRPC(so_id); - all_sockets_.push_back(so); - StoreSocketInJson(so); - } - } - std::cout << std::endl; - } - } - - // Get all top channels, keep querying until getting all - // Store channels for dumping data - // No need to check id repeating for top channels - void GetTopChannelsRPC() { - int64_t channel_start_id = 0; - while (true) { - GetTopChannelsRequest get_top_channels_request; - GetTopChannelsResponse get_top_channels_response; - ClientContext get_top_channels_context; - get_top_channels_context.set_deadline( - grpc_timeout_seconds_to_deadline(rpc_timeout_seconds_)); - get_top_channels_request.set_start_channel_id(channel_start_id); - Status status = channelz_stub_->GetTopChannels( - &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", - int(channel_start_id), - get_top_channels_context.debug_error_string().c_str()); - GPR_ASSERT(0); - } - for (const auto& _topchannel : get_top_channels_response.channel()) { - top_channels_.push_back(_topchannel); - all_channels_.push_back(_topchannel); - StoreChannelInJson(_topchannel); - } - if (!get_top_channels_response.end()) { - channel_start_id = GetChannelID(top_channels_.back()) + 1; - } else { - break; - } - } - std::cout << std::endl - << "Number of top channels = " << top_channels_.size() - << std::endl; - } - - // layer traverse for each top channel - void TraverseTopChannels() { - for (const auto& _topchannel : top_channels_) { - int tree_depth = 0; - std::queue<grpc::channelz::v1::Channel> channel_queue; - std::queue<grpc::channelz::v1::Subchannel> subchannel_queue; - std::cout << "Tree depth = " << tree_depth << std::endl; - GetChannelDescedence(_topchannel, channel_queue, subchannel_queue); - while (!channel_queue.empty() || !subchannel_queue.empty()) { - ++tree_depth; - std::cout << "Tree depth = " << tree_depth << std::endl; - int ch_q_size = channel_queue.size(); - int subch_q_size = subchannel_queue.size(); - for (int i = 0; i < ch_q_size; ++i) { - grpc::channelz::v1::Channel ch = channel_queue.front(); - channel_queue.pop(); - GetChannelDescedence(ch, channel_queue, subchannel_queue); - } - for (int i = 0; i < subch_q_size; ++i) { - grpc::channelz::v1::Subchannel subch = subchannel_queue.front(); - subchannel_queue.pop(); - GetSubchannelDescedence(subch, channel_queue, subchannel_queue); - } - } - std::cout << std::endl; - } - } - - // dump data of all entities to stdout - void DumpStdout() { - TString data_str; - for (const auto& _channel : all_channels_) { - std::cout << "channel ID" << GetChannelID(_channel) << "_" - << GetChannelName(_channel) << " data:" << std::endl; - // TODO(mohanli): TextFormat::PrintToString records time as seconds and - // nanos. Need a more human readable way. - ::google::protobuf::TextFormat::PrintToString(_channel.data(), &data_str); - printf("%s\n", data_str.c_str()); - } - for (const auto& _subchannel : all_subchannels_) { - std::cout << "subchannel ID" << GetSubchannelID(_subchannel) << "_" - << GetSubchannelName(_subchannel) << " data:" << std::endl; - ::google::protobuf::TextFormat::PrintToString(_subchannel.data(), - &data_str); - printf("%s\n", data_str.c_str()); - } - for (const auto& _server : all_servers_) { - std::cout << "server ID" << GetServerID(_server) << "_" - << GetServerName(_server) << " data:" << std::endl; - ::google::protobuf::TextFormat::PrintToString(_server.data(), &data_str); - printf("%s\n", data_str.c_str()); - } - for (const auto& _socket : all_sockets_) { - std::cout << "socket ID" << GetSocketID(_socket) << "_" - << GetSocketName(_socket) << " data:" << std::endl; - ::google::protobuf::TextFormat::PrintToString(_socket.data(), &data_str); - printf("%s\n", data_str.c_str()); - } - } - - // Store a channel in Json - void StoreChannelInJson(const grpc::channelz::v1::Channel& channel) { - TString id = grpc::to_string(GetChannelID(channel)); - TString type = "Channel"; - TString description; - ::google::protobuf::TextFormat::PrintToString(channel.data(), &description); - grpc_core::Json description_json = grpc_core::Json(description); - StoreEntityInJson(id, type, description_json); - } - - // Store a subchannel in Json - void StoreSubchannelInJson(const grpc::channelz::v1::Subchannel& subchannel) { - TString id = grpc::to_string(GetSubchannelID(subchannel)); - TString type = "Subchannel"; - TString description; - ::google::protobuf::TextFormat::PrintToString(subchannel.data(), - &description); - grpc_core::Json description_json = grpc_core::Json(description); - StoreEntityInJson(id, type, description_json); - } - - // Store a server in Json - void StoreServerInJson(const grpc::channelz::v1::Server& server) { - TString id = grpc::to_string(GetServerID(server)); - TString type = "Server"; - TString description; - ::google::protobuf::TextFormat::PrintToString(server.data(), &description); - grpc_core::Json description_json = grpc_core::Json(description); - StoreEntityInJson(id, type, description_json); - } - - // Store a socket in Json - void StoreSocketInJson(const grpc::channelz::v1::Socket& socket) { - TString id = grpc::to_string(GetSocketID(socket)); - TString type = "Socket"; - TString description; - ::google::protobuf::TextFormat::PrintToString(socket.data(), &description); - grpc_core::Json description_json = grpc_core::Json(description); - StoreEntityInJson(id, type, description_json); - } - - // Store an entity in Json - void StoreEntityInJson(TString& id, TString& type, - const grpc_core::Json& description) { - TString start, finish; - gpr_timespec ago = gpr_time_sub( - now_, - gpr_time_from_seconds(y_absl::GetFlag(FLAGS_sampling_interval_seconds), - GPR_TIMESPAN)); - std::stringstream ss; - const time_t time_now = now_.tv_sec; - ss << std::put_time(std::localtime(&time_now), "%F %T"); - finish = ss.str(); // example: "2019-02-01 12:12:18" - ss.str(""); - const time_t time_ago = ago.tv_sec; - ss << std::put_time(std::localtime(&time_ago), "%F %T"); - start = ss.str(); - grpc_core::Json obj = - grpc_core::Json::Object{{"Task", y_absl::StrFormat("%s_ID%s", type, id)}, - {"Start", start}, - {"Finish", finish}, - {"ID", id}, - {"Type", type}, - {"Description", description}}; - json_.mutable_array()->push_back(obj); - } - - // Dump data in json - TString DumpJson() { return json_.Dump(); } - - // Check if one entity has been recorded - bool CheckID(int64_t id) { - if (id_set_.count(id) == 0) { - id_set_.insert(id); - return true; - } else { - return false; - } - } - - // Record current time - void RecordNow() { now_ = gpr_now(GPR_CLOCK_REALTIME); } - - private: - std::unique_ptr<grpc::channelz::v1::Channelz::Stub> channelz_stub_; - std::vector<grpc::channelz::v1::Channel> top_channels_; - std::vector<grpc::channelz::v1::Server> all_servers_; - std::vector<grpc::channelz::v1::Channel> all_channels_; - std::vector<grpc::channelz::v1::Subchannel> all_subchannels_; - std::vector<grpc::channelz::v1::Socket> all_sockets_; - std::unordered_set<int64_t> id_set_; - grpc_core::Json json_; - int64_t rpc_timeout_seconds_; - gpr_timespec now_; -}; - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - grpc::testing::InitTest(&argc, &argv, true); - std::ofstream output_file(y_absl::GetFlag(FLAGS_output_json)); - for (int i = 0; i < y_absl::GetFlag(FLAGS_sampling_times); ++i) { - ChannelzSampler channelz_sampler; - channelz_sampler.Setup(y_absl::GetFlag(FLAGS_custom_credentials_type), - y_absl::GetFlag(FLAGS_server_address)); - std::cout << "Wait for sampling interval " - << y_absl::GetFlag(FLAGS_sampling_interval_seconds) << "s..." - << std::endl; - const gpr_timespec kDelay = gpr_time_add( - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(y_absl::GetFlag(FLAGS_sampling_interval_seconds), - GPR_TIMESPAN)); - gpr_sleep_until(kDelay); - std::cout << "##### " << i << "th sampling #####" << std::endl; - channelz_sampler.RecordNow(); - channelz_sampler.GetServersRPC(); - channelz_sampler.GetSocketsOfServers(); - channelz_sampler.GetTopChannelsRPC(); - channelz_sampler.TraverseTopChannels(); - channelz_sampler.DumpStdout(); - if (!y_absl::GetFlag(FLAGS_output_json).empty()) { - output_file << channelz_sampler.DumpJson() << "\n" << std::flush; - } - } - output_file.close(); - return 0; -} diff --git a/contrib/libs/grpc/test/cpp/util/channelz_sampler_test.cc b/contrib/libs/grpc/test/cpp/util/channelz_sampler_test.cc deleted file mode 100644 index 6d9f05e95c..0000000000 --- a/contrib/libs/grpc/test/cpp/util/channelz_sampler_test.cc +++ /dev/null @@ -1,179 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#include <grpc/support/port_platform.h> - -#include <stdlib.h> -#include <unistd.h> - -#include <cstdlib> -#include <iostream> -#include <memory> -#include <util/generic/string.h> -#include <thread> - -#include "gtest/gtest.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/channelz_service_plugin.h> -#include <grpcpp/grpcpp.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/cpp/server/channelz/channelz_service.h" -#include "src/proto/grpc/testing/test.grpc.pb.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/subprocess.h" -#include "test/cpp/util/test_credentials_provider.h" - -static TString g_root; - -namespace { -using grpc::ClientContext; -using grpc::Server; -using grpc::ServerBuilder; -using grpc::ServerContext; -using grpc::Status; -} // namespace - -// Test variables -TString server_address("0.0.0.0:10000"); -TString custom_credentials_type("INSECURE_CREDENTIALS"); -TString sampling_times = "2"; -TString sampling_interval_seconds = "3"; -TString output_json("output.json"); - -// Creata an echo server -class EchoServerImpl final : public grpc::testing::TestService::Service { - Status EmptyCall(::grpc::ServerContext* /*context*/, - const grpc::testing::Empty* /*request*/, - grpc::testing::Empty* /*response*/) override { - return Status::OK; - } -}; - -// Run client in a thread -void RunClient(const TString& client_id, gpr_event* done_ev) { - grpc::ChannelArguments channel_args; - std::shared_ptr<grpc::ChannelCredentials> channel_creds = - grpc::testing::GetCredentialsProvider()->GetChannelCredentials( - custom_credentials_type, &channel_args); - std::unique_ptr<grpc::testing::TestService::Stub> stub = - grpc::testing::TestService::NewStub( - grpc::CreateChannel(server_address, channel_creds)); - gpr_log(GPR_INFO, "Client %s is echoing!", client_id.c_str()); - while (true) { - if (gpr_event_wait(done_ev, grpc_timeout_seconds_to_deadline(1)) != - nullptr) { - return; - } - grpc::testing::Empty request; - grpc::testing::Empty response; - ClientContext context; - Status status = stub->EmptyCall(&context, request, &response); - if (!status.ok()) { - gpr_log(GPR_ERROR, "Client echo failed."); - GPR_ASSERT(0); - } - } -} - -// Create the channelz to test the connection to the server -bool WaitForConnection(int wait_server_seconds) { - grpc::ChannelArguments channel_args; - std::shared_ptr<grpc::ChannelCredentials> channel_creds = - grpc::testing::GetCredentialsProvider()->GetChannelCredentials( - custom_credentials_type, &channel_args); - auto channel = grpc::CreateChannel(server_address, channel_creds); - return channel->WaitForConnected( - grpc_timeout_seconds_to_deadline(wait_server_seconds)); -} - -// Test the channelz sampler -TEST(ChannelzSamplerTest, SimpleTest) { - // start server - ::grpc::channelz::experimental::InitChannelzService(); - EchoServerImpl service; - grpc::ServerBuilder builder; - auto server_creds = - grpc::testing::GetCredentialsProvider()->GetServerCredentials( - custom_credentials_type); - builder.AddListeningPort(server_address, server_creds); - builder.RegisterService(&service); - std::unique_ptr<Server> server(builder.BuildAndStart()); - gpr_log(GPR_INFO, "Server listening on %s", server_address.c_str()); - const int kWaitForServerSeconds = 10; - ASSERT_TRUE(WaitForConnection(kWaitForServerSeconds)); - // client threads - gpr_event done_ev1, done_ev2; - gpr_event_init(&done_ev1); - gpr_event_init(&done_ev2); - std::thread client_thread_1(RunClient, "1", &done_ev1); - std::thread client_thread_2(RunClient, "2", &done_ev2); - // Run the channelz sampler - grpc::SubProcess* test_driver = new grpc::SubProcess( - {g_root + "/channelz_sampler", "--server_address=" + server_address, - "--custom_credentials_type=" + custom_credentials_type, - "--sampling_times=" + sampling_times, - "--sampling_interval_seconds=" + sampling_interval_seconds, - "--output_json=" + output_json}); - 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)); - GPR_ASSERT(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)); - GPR_ASSERT(0); - } else { - gpr_log(GPR_ERROR, - "Channelz sampler test test-runner ended with unknown status %d", - status); - GPR_ASSERT(0); - } - delete test_driver; - gpr_event_set(&done_ev1, reinterpret_cast<void*>(1)); - gpr_event_set(&done_ev2, reinterpret_cast<void*>(1)); - client_thread_1.join(); - client_thread_2.join(); -} - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - TString me = argv[0]; - auto lslash = me.rfind('/'); - if (lslash != TString::npos) { - g_root = me.substr(0, lslash); - } else { - g_root = "."; - } - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/util/cli_call_test.cc b/contrib/libs/grpc/test/cpp/util/cli_call_test.cc deleted file mode 100644 index 4064899e0c..0000000000 --- a/contrib/libs/grpc/test/cpp/util/cli_call_test.cc +++ /dev/null @@ -1,129 +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. - * - */ - -#include "test/cpp/util/cli_call.h" - -#include <gtest/gtest.h> - -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/string_ref_helper.h" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -namespace grpc { -namespace testing { - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - if (!context->client_metadata().empty()) { - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator - iter = context->client_metadata().begin(); - iter != context->client_metadata().end(); ++iter) { - context->AddInitialMetadata(ToString(iter->first), - ToString(iter->second)); - } - } - context->AddTrailingMetadata("trailing_key", "trailing_value"); - response->set_message(request->message()); - return Status::OK; - } -}; - -class CliCallTest : public ::testing::Test { - protected: - CliCallTest() {} - - void SetUp() override { - int port = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port; - // Setup server - ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), - InsecureServerCredentials()); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - } - - void TearDown() override { server_->Shutdown(); } - - void ResetStub() { - channel_ = grpc::CreateChannel(server_address_.str(), - InsecureChannelCredentials()); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); - } - - std::shared_ptr<Channel> channel_; - std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; - std::unique_ptr<Server> server_; - std::ostringstream server_address_; - TestServiceImpl service_; -}; - -// Send a rpc with a normal stub and then a CliCall. Verify they match. -TEST_F(CliCallTest, SimpleRpc) { - ResetStub(); - // Normal stub. - EchoRequest request; - EchoResponse response; - request.set_message("Hello"); - - ClientContext context; - context.AddMetadata("key1", "val1"); - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.ok()); - - const TString kMethod("/grpc.testing.EchoTestService/Echo"); - TString request_bin, response_bin, expected_response_bin; - EXPECT_TRUE(request.SerializeToString(&request_bin)); - EXPECT_TRUE(response.SerializeToString(&expected_response_bin)); - std::multimap<TString, TString> client_metadata; - std::multimap<grpc::string_ref, grpc::string_ref> server_initial_metadata, - server_trailing_metadata; - client_metadata.insert(std::pair<TString, TString>("key1", "val1")); - CliCall call(channel_, kMethod, client_metadata); - Status s2 = call.Call(request_bin, &response_bin, &server_initial_metadata, - &server_trailing_metadata); - EXPECT_TRUE(s2.ok()); - - EXPECT_EQ(expected_response_bin, response_bin); - EXPECT_EQ(context.GetServerInitialMetadata(), server_initial_metadata); - EXPECT_EQ(context.GetServerTrailingMetadata(), server_trailing_metadata); -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/util/create_test_channel.cc b/contrib/libs/grpc/test/cpp/util/create_test_channel.cc deleted file mode 100644 index be13bb4e55..0000000000 --- a/contrib/libs/grpc/test/cpp/util/create_test_channel.cc +++ /dev/null @@ -1,252 +0,0 @@ -/* - * - * Copyright 2015-2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/cpp/util/create_test_channel.h" - -#include "y_absl/flags/flag.h" - -#include <grpc/support/log.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> - -#include "test/cpp/util/test_credentials_provider.h" - -Y_ABSL_FLAG(TString, grpc_test_use_grpclb_with_child_policy, "", - "If non-empty, set a static service config on channels created by " - "grpc::CreateTestChannel, that configures the grpclb LB policy " - "with a child policy being the value of this flag (e.g. round_robin " - "or pick_first)."); - -namespace grpc { - -namespace { - -const char kProdTlsCredentialsType[] = "prod_ssl"; - -class SslCredentialProvider : public testing::CredentialTypeProvider { - public: - std::shared_ptr<ChannelCredentials> GetChannelCredentials( - grpc::ChannelArguments* /*args*/) override { - return grpc::SslCredentials(SslCredentialsOptions()); - } - std::shared_ptr<ServerCredentials> GetServerCredentials() override { - return nullptr; - } -}; - -gpr_once g_once_init_add_prod_ssl_provider = GPR_ONCE_INIT; -// Register ssl with non-test roots type to the credentials provider. -void AddProdSslType() { - testing::GetCredentialsProvider()->AddSecureType( - kProdTlsCredentialsType, std::unique_ptr<testing::CredentialTypeProvider>( - new SslCredentialProvider)); -} - -void MaybeSetCustomChannelArgs(grpc::ChannelArguments* args) { - if (!y_absl::GetFlag(FLAGS_grpc_test_use_grpclb_with_child_policy).empty()) { - args->SetString( - "grpc.service_config", - "{\"loadBalancingConfig\":[{\"grpclb\":{\"childPolicy\":[{" - "\"" + - y_absl::GetFlag(FLAGS_grpc_test_use_grpclb_with_child_policy) + - "\":{}}]}}]}"); - } -} - -} // namespace - -// When cred_type is 'ssl', if server is empty, override_hostname is used to -// create channel. Otherwise, connect to server and override hostname if -// override_hostname is provided. -// When cred_type is not 'ssl', override_hostname is ignored. -// Set use_prod_root to true to use the SSL root for connecting to google. -// In this case, path to the roots pem file must be set via environment variable -// GRPC_DEFAULT_SSL_ROOTS_FILE_PATH. -// Otherwise, root for test SSL cert will be used. -// creds will be used to create a channel when cred_type is 'ssl'. -// Use examples: -// CreateTestChannel( -// "1.1.1.1:12345", "ssl", "override.hostname.com", false, creds); -// CreateTestChannel("test.google.com:443", "ssl", "", true, creds); -// same as above -// CreateTestChannel("", "ssl", "test.google.com:443", true, creds); -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& cred_type, - const TString& override_hostname, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - const ChannelArguments& args) { - return CreateTestChannel(server, cred_type, override_hostname, use_prod_roots, - creds, args, - /*interceptor_creators=*/{}); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - const ChannelArguments& args) { - return CreateTestChannel(server, override_hostname, security_type, - use_prod_roots, creds, args, - /*interceptor_creators=*/{}); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds) { - return CreateTestChannel(server, override_hostname, security_type, - use_prod_roots, creds, ChannelArguments()); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots) { - return CreateTestChannel(server, override_hostname, security_type, - use_prod_roots, std::shared_ptr<CallCredentials>()); -} - -// Shortcut for end2end and interop tests. -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, testing::transport_security security_type) { - return CreateTestChannel(server, "foo.test.google.fr", security_type, false); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& credential_type, - const std::shared_ptr<CallCredentials>& creds) { - ChannelArguments channel_args; - MaybeSetCustomChannelArgs(&channel_args); - std::shared_ptr<ChannelCredentials> channel_creds = - testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, - &channel_args); - GPR_ASSERT(channel_creds != nullptr); - if (creds.get()) { - channel_creds = grpc::CompositeChannelCredentials(channel_creds, creds); - } - return ::grpc::CreateCustomChannel(server, channel_creds, channel_args); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& cred_type, - const TString& override_hostname, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators) { - ChannelArguments channel_args(args); - MaybeSetCustomChannelArgs(&channel_args); - std::shared_ptr<ChannelCredentials> channel_creds; - if (cred_type.empty()) { - if (interceptor_creators.empty()) { - return ::grpc::CreateCustomChannel(server, InsecureChannelCredentials(), - channel_args); - } else { - return experimental::CreateCustomChannelWithInterceptors( - server, InsecureChannelCredentials(), channel_args, - std::move(interceptor_creators)); - } - } else if (cred_type == testing::kTlsCredentialsType) { // cred_type == "ssl" - if (use_prod_roots) { - gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType); - channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( - kProdTlsCredentialsType, &channel_args); - if (!server.empty() && !override_hostname.empty()) { - channel_args.SetSslTargetNameOverride(override_hostname); - } - } else { - // override_hostname is discarded as the provider handles it. - channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( - testing::kTlsCredentialsType, &channel_args); - } - GPR_ASSERT(channel_creds != nullptr); - - const TString& connect_to = server.empty() ? override_hostname : server; - if (creds.get()) { - channel_creds = grpc::CompositeChannelCredentials(channel_creds, creds); - } - if (interceptor_creators.empty()) { - return ::grpc::CreateCustomChannel(connect_to, channel_creds, - channel_args); - } else { - return experimental::CreateCustomChannelWithInterceptors( - connect_to, channel_creds, channel_args, - std::move(interceptor_creators)); - } - } else { - channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( - cred_type, &channel_args); - GPR_ASSERT(channel_creds != nullptr); - - if (interceptor_creators.empty()) { - return ::grpc::CreateCustomChannel(server, channel_creds, channel_args); - } else { - return experimental::CreateCustomChannelWithInterceptors( - server, channel_creds, channel_args, std::move(interceptor_creators)); - } - } -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators) { - TString credential_type = - security_type == testing::ALTS - ? testing::kAltsCredentialsType - : (security_type == testing::TLS ? testing::kTlsCredentialsType - : testing::kInsecureCredentialsType); - return CreateTestChannel(server, credential_type, override_hostname, - use_prod_roots, creds, args, - std::move(interceptor_creators)); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators) { - return CreateTestChannel(server, override_hostname, security_type, - use_prod_roots, creds, ChannelArguments(), - std::move(interceptor_creators)); -} - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& credential_type, - const std::shared_ptr<CallCredentials>& creds, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators) { - ChannelArguments channel_args; - MaybeSetCustomChannelArgs(&channel_args); - std::shared_ptr<ChannelCredentials> channel_creds = - testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, - &channel_args); - GPR_ASSERT(channel_creds != nullptr); - if (creds.get()) { - channel_creds = grpc::CompositeChannelCredentials(channel_creds, creds); - } - return experimental::CreateCustomChannelWithInterceptors( - server, channel_creds, channel_args, std::move(interceptor_creators)); -} - -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/create_test_channel.h b/contrib/libs/grpc/test/cpp/util/create_test_channel.h deleted file mode 100644 index ed4ce6c11b..0000000000 --- a/contrib/libs/grpc/test/cpp/util/create_test_channel.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Copyright 2015-2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H -#define GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H - -#include <memory> - -#include <grpcpp/channel.h> -#include <grpcpp/impl/codegen/client_interceptor.h> -#include <grpcpp/security/credentials.h> -#include <grpcpp/support/channel_arguments.h> - -namespace grpc { -class Channel; - -namespace testing { - -typedef enum { INSECURE = 0, TLS, ALTS } transport_security; - -} // namespace testing - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, testing::transport_security security_type); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - const ChannelArguments& args); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& cred_type, - const TString& override_hostname, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - const ChannelArguments& args); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& credential_type, - const std::shared_ptr<CallCredentials>& creds); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& override_hostname, - testing::transport_security security_type, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& cred_type, - const TString& override_hostname, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators); - -std::shared_ptr<Channel> CreateTestChannel( - const TString& server, const TString& credential_type, - const std::shared_ptr<CallCredentials>& creds, - std::vector< - std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> - interceptor_creators); - -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H diff --git a/contrib/libs/grpc/test/cpp/util/error_details_test.cc b/contrib/libs/grpc/test/cpp/util/error_details_test.cc deleted file mode 100644 index 9ce827038d..0000000000 --- a/contrib/libs/grpc/test/cpp/util/error_details_test.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <gtest/gtest.h> - -#include <grpcpp/support/error_details.h> - -#include "src/proto/grpc/status/status.pb.h" -#include "src/proto/grpc/testing/echo_messages.pb.h" -#include "test/core/util/test_config.h" - -namespace grpc { -namespace { - -TEST(ExtractTest, Success) { - google::rpc::Status expected; - expected.set_code(13); // INTERNAL - expected.set_message("I am an error message"); - testing::EchoRequest expected_details; - expected_details.set_message(TString(100, '\0')); - expected.add_details()->PackFrom(expected_details); - - google::rpc::Status to; - TString error_details = expected.SerializeAsString(); - Status from(static_cast<StatusCode>(expected.code()), expected.message(), - error_details); - EXPECT_TRUE(ExtractErrorDetails(from, &to).ok()); - EXPECT_EQ(expected.code(), to.code()); - EXPECT_EQ(expected.message(), to.message()); - EXPECT_EQ(1, to.details_size()); - testing::EchoRequest details; - to.details(0).UnpackTo(&details); - EXPECT_EQ(expected_details.message(), details.message()); -} - -TEST(ExtractTest, NullInput) { - EXPECT_EQ(StatusCode::FAILED_PRECONDITION, - ExtractErrorDetails(Status(), nullptr).error_code()); -} - -TEST(ExtractTest, Unparsable) { - TString error_details("I am not a status object"); - Status from(StatusCode::INTERNAL, "", error_details); - google::rpc::Status to; - EXPECT_EQ(StatusCode::INVALID_ARGUMENT, - ExtractErrorDetails(from, &to).error_code()); -} - -TEST(SetTest, Success) { - google::rpc::Status expected; - expected.set_code(13); // INTERNAL - expected.set_message("I am an error message"); - testing::EchoRequest expected_details; - expected_details.set_message(TString(100, '\0')); - expected.add_details()->PackFrom(expected_details); - - Status to; - Status s = SetErrorDetails(expected, &to); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(expected.code(), to.error_code()); - EXPECT_EQ(expected.message(), to.error_message()); - EXPECT_EQ(expected.SerializeAsString(), to.error_details()); -} - -TEST(SetTest, NullInput) { - EXPECT_EQ(StatusCode::FAILED_PRECONDITION, - SetErrorDetails(google::rpc::Status(), nullptr).error_code()); -} - -TEST(SetTest, OutOfScopeErrorCode) { - google::rpc::Status expected; - expected.set_code(17); // Out of scope (UNAUTHENTICATED is 16). - expected.set_message("I am an error message"); - testing::EchoRequest expected_details; - expected_details.set_message(TString(100, '\0')); - expected.add_details()->PackFrom(expected_details); - - Status to; - Status s = SetErrorDetails(expected, &to); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(StatusCode::UNKNOWN, to.error_code()); - EXPECT_EQ(expected.message(), to.error_message()); - EXPECT_EQ(expected.SerializeAsString(), to.error_details()); -} - -TEST(SetTest, ValidScopeErrorCode) { - for (int c = StatusCode::OK; c <= StatusCode::UNAUTHENTICATED; c++) { - google::rpc::Status expected; - expected.set_code(c); - expected.set_message("I am an error message"); - testing::EchoRequest expected_details; - expected_details.set_message(TString(100, '\0')); - expected.add_details()->PackFrom(expected_details); - - Status to; - Status s = SetErrorDetails(expected, &to); - EXPECT_TRUE(s.ok()); - EXPECT_EQ(c, to.error_code()); - EXPECT_EQ(expected.message(), to.error_message()); - EXPECT_EQ(expected.SerializeAsString(), to.error_details()); - } -} - -} // namespace -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/util/grpc_cli.cc b/contrib/libs/grpc/test/cpp/util/grpc_cli.cc deleted file mode 100644 index 9b587901bc..0000000000 --- a/contrib/libs/grpc/test/cpp/util/grpc_cli.cc +++ /dev/null @@ -1,95 +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. - * - */ - -/* - A command line tool to talk to a grpc server. - Run `grpc_cli help` command to see its usage information. - - Example of talking to grpc interop server: - grpc_cli call localhost:50051 UnaryCall "response_size:10" \ - --protofiles=src/proto/grpc/testing/test.proto \ - --channel_creds_type=insecure - - Options: - 1. --protofiles, use this flag to provide proto files if the server does - does not have the reflection service. - 2. --proto_path, if your proto file is not under current working directory, - use this flag to provide a search root. It should work similar to the - counterpart in protoc. This option is valid only when protofiles is - provided. - 3. --metadata specifies metadata to be sent to the server, such as: - --metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2" - 4. --channel_creds_type, whether to use tls, insecure or platform-specific - options. - 5. --use_auth, if set to true, attach a GoogleDefaultCredentials to the call - 6. --infile, input filename (defaults to stdin) - 7. --outfile, output filename (defaults to stdout) - 8. --binary_input, use the serialized request as input. The serialized - request can be generated by calling something like: - protoc --proto_path=src/proto/grpc/testing/ \ - --encode=grpc.testing.SimpleRequest \ - src/proto/grpc/testing/messages.proto \ - < input.txt > input.bin - If this is used and no proto file is provided in the argument list, the - method string has to be exact in the form of /package.service/method. - 9. --binary_output, use binary format response as output, it can - be later decoded using protoc: - protoc --proto_path=src/proto/grpc/testing/ \ - --decode=grpc.testing.SimpleResponse \ - src/proto/grpc/testing/messages.proto \ - < output.bin > output.txt - 10. --default_service_config, optional default service config to use - on the channel. Note that this may be ignored if the name resolver - returns a service config. - 11. --display_peer_address, on CallMethod commands, log the peer socket - address of the connection that each RPC is made on to stderr. -*/ - -#include <fstream> -#include <functional> -#include <iostream> - -#include "y_absl/flags/flag.h" - -#include <grpcpp/support/config.h> - -#include "test/cpp/util/cli_credentials.h" -#include "test/cpp/util/grpc_tool.h" -#include "test/cpp/util/test_config.h" - -Y_ABSL_FLAG(TString, outfile, "", "Output file (default is stdout)"); - -static bool SimplePrint(const TString& outfile, const TString& output) { - if (outfile.empty()) { - std::cout << output << std::flush; - } else { - std::ofstream output_file(outfile, std::ios::app | std::ios::binary); - output_file << output << std::flush; - output_file.close(); - } - return true; -} - -int main(int argc, char** argv) { - grpc::testing::InitTest(&argc, &argv, true); - - return grpc::testing::GrpcToolMainLib( - argc, const_cast<const char**>(argv), grpc::testing::CliCredentials(), - std::bind(SimplePrint, y_absl::GetFlag(FLAGS_outfile), - std::placeholders::_1)); -} diff --git a/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc b/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc deleted file mode 100644 index e2798b8a2b..0000000000 --- a/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc +++ /dev/null @@ -1,1354 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/cpp/util/grpc_tool.h" - -#include <chrono> -#include <sstream> - -#include <gtest/gtest.h> - -#include "y_absl/flags/declare.h" -#include "y_absl/flags/flag.h" - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/ext/proto_server_reflection_plugin.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> -#include <grpcpp/server_context.h> - -#include "src/core/lib/gpr/env.h" -#include "src/core/lib/iomgr/load_file.h" -#include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "src/proto/grpc/testing/echo.pb.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/cpp/util/cli_credentials.h" -#include "test/cpp/util/string_ref_helper.h" -#include "test/cpp/util/test_config.h" - -#define CA_CERT_PATH "src/core/tsi/test_creds/ca.pem" -#define SERVER_CERT_PATH "src/core/tsi/test_creds/server1.pem" -#define SERVER_KEY_PATH "src/core/tsi/test_creds/server1.key" - -using grpc::testing::EchoRequest; -using grpc::testing::EchoResponse; - -#define USAGE_REGEX "( grpc_cli .+\n){2,10}" - -#define ECHO_TEST_SERVICE_SUMMARY \ - "Echo\n" \ - "Echo1\n" \ - "Echo2\n" \ - "CheckDeadlineUpperBound\n" \ - "CheckDeadlineSet\n" \ - "CheckClientInitialMetadata\n" \ - "RequestStream\n" \ - "ResponseStream\n" \ - "BidiStream\n" \ - "Unimplemented\n" \ - "UnimplementedBidi\n" - -#define ECHO_TEST_SERVICE_DESCRIPTION \ - "filename: src/proto/grpc/testing/echo.proto\n" \ - "package: grpc.testing;\n" \ - "service EchoTestService {\n" \ - " rpc Echo(grpc.testing.EchoRequest) returns (grpc.testing.EchoResponse) " \ - "{}\n" \ - " rpc Echo1(grpc.testing.EchoRequest) returns (grpc.testing.EchoResponse) " \ - "{}\n" \ - " rpc Echo2(grpc.testing.EchoRequest) returns (grpc.testing.EchoResponse) " \ - "{}\n" \ - " rpc CheckDeadlineUpperBound(grpc.testing.SimpleRequest) returns " \ - "(grpc.testing.StringValue) {}\n" \ - " rpc CheckDeadlineSet(grpc.testing.SimpleRequest) returns " \ - "(grpc.testing.StringValue) {}\n" \ - " rpc CheckClientInitialMetadata(grpc.testing.SimpleRequest) returns " \ - "(grpc.testing.SimpleResponse) {}\n" \ - " rpc RequestStream(stream grpc.testing.EchoRequest) returns " \ - "(grpc.testing.EchoResponse) {}\n" \ - " rpc ResponseStream(grpc.testing.EchoRequest) returns (stream " \ - "grpc.testing.EchoResponse) {}\n" \ - " rpc BidiStream(stream grpc.testing.EchoRequest) returns (stream " \ - "grpc.testing.EchoResponse) {}\n" \ - " rpc Unimplemented(grpc.testing.EchoRequest) returns " \ - "(grpc.testing.EchoResponse) {}\n" \ - " rpc UnimplementedBidi(stream grpc.testing.EchoRequest) returns (stream " \ - "grpc.testing.EchoResponse) {}\n" \ - "}\n" \ - "\n" - -#define ECHO_METHOD_DESCRIPTION \ - " rpc Echo(grpc.testing.EchoRequest) returns (grpc.testing.EchoResponse) " \ - "{}\n" - -#define ECHO_RESPONSE_MESSAGE_TEXT_FORMAT \ - "message: \"echo\"\n" \ - "param {\n" \ - " host: \"localhost\"\n" \ - " peer: \"peer\"\n" \ - "}\n\n" - -#define ECHO_RESPONSE_MESSAGE_JSON_FORMAT \ - "{\n" \ - " \"message\": \"echo\",\n" \ - " \"param\": {\n" \ - " \"host\": \"localhost\",\n" \ - " \"peer\": \"peer\"\n" \ - " }\n" \ - "}\n\n" - -Y_ABSL_DECLARE_FLAG(TString, channel_creds_type); -Y_ABSL_DECLARE_FLAG(TString, ssl_target); -Y_ABSL_DECLARE_FLAG(bool, binary_input); -Y_ABSL_DECLARE_FLAG(bool, binary_output); -Y_ABSL_DECLARE_FLAG(bool, json_input); -Y_ABSL_DECLARE_FLAG(bool, json_output); -Y_ABSL_DECLARE_FLAG(bool, l); -Y_ABSL_DECLARE_FLAG(bool, batch); -Y_ABSL_DECLARE_FLAG(TString, metadata); -Y_ABSL_DECLARE_FLAG(TString, protofiles); -Y_ABSL_DECLARE_FLAG(TString, proto_path); -Y_ABSL_DECLARE_FLAG(TString, default_service_config); -Y_ABSL_DECLARE_FLAG(double, timeout); - -namespace grpc { -namespace testing { -namespace { - -const int kServerDefaultResponseStreamsToSend = 3; - -class TestCliCredentials final : public grpc::testing::CliCredentials { - public: - explicit TestCliCredentials(bool secure = false) : secure_(secure) {} - std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials() - const override { - if (!secure_) { - return InsecureChannelCredentials(); - } - grpc_slice ca_slice; - GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(CA_CERT_PATH, 1, &ca_slice))); - const char* test_root_cert = - reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice); - SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; - std::shared_ptr<grpc::ChannelCredentials> credential_ptr = - grpc::SslCredentials(grpc::SslCredentialsOptions(ssl_opts)); - grpc_slice_unref(ca_slice); - return credential_ptr; - } - TString GetCredentialUsage() const override { return ""; } - - private: - const bool secure_; -}; - -bool PrintStream(std::stringstream* ss, const TString& output) { - (*ss) << output; - return true; -} - -template <typename T> -size_t ArraySize(T& a) { - return ((sizeof(a) / sizeof(*(a))) / - static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))); -} - -class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { - public: - Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { - if (!context->client_metadata().empty()) { - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator - iter = context->client_metadata().begin(); - iter != context->client_metadata().end(); ++iter) { - context->AddInitialMetadata(ToString(iter->first), - ToString(iter->second)); - } - } - context->AddTrailingMetadata("trailing_key", "trailing_value"); - response->set_message(request->message()); - return Status::OK; - } - - Status CheckDeadlineSet(ServerContext* context, - const SimpleRequest* /*request*/, - StringValue* response) override { - response->set_message(context->deadline() != - std::chrono::system_clock::time_point::max() - ? "true" - : "false"); - return Status::OK; - } - - // Check if deadline - current time <= timeout - // If deadline set, timeout + current time should be an upper bound for it - Status CheckDeadlineUpperBound(ServerContext* context, - const SimpleRequest* /*request*/, - StringValue* response) override { - auto seconds = std::chrono::duration_cast<std::chrono::seconds>( - context->deadline() - std::chrono::system_clock::now()); - - // Returning string instead of bool to avoid using embedded messages in - // proto3 - response->set_message( - seconds.count() <= y_absl::GetFlag(FLAGS_timeout) ? "true" : "false"); - return Status::OK; - } - - Status RequestStream(ServerContext* context, - ServerReader<EchoRequest>* reader, - EchoResponse* response) override { - EchoRequest request; - response->set_message(""); - if (!context->client_metadata().empty()) { - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator - iter = context->client_metadata().begin(); - iter != context->client_metadata().end(); ++iter) { - context->AddInitialMetadata(ToString(iter->first), - ToString(iter->second)); - } - } - context->AddTrailingMetadata("trailing_key", "trailing_value"); - while (reader->Read(&request)) { - response->mutable_message()->append(request.message()); - } - - return Status::OK; - } - - Status ResponseStream(ServerContext* context, const EchoRequest* request, - ServerWriter<EchoResponse>* writer) override { - if (!context->client_metadata().empty()) { - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator - iter = context->client_metadata().begin(); - iter != context->client_metadata().end(); ++iter) { - context->AddInitialMetadata(ToString(iter->first), - ToString(iter->second)); - } - } - context->AddTrailingMetadata("trailing_key", "trailing_value"); - - EchoResponse response; - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - response.set_message(request->message() + ToString(i)); - writer->Write(response); - } - - return Status::OK; - } - - Status BidiStream( - ServerContext* context, - ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { - EchoRequest request; - EchoResponse response; - if (!context->client_metadata().empty()) { - for (std::multimap<grpc::string_ref, grpc::string_ref>::const_iterator - iter = context->client_metadata().begin(); - iter != context->client_metadata().end(); ++iter) { - context->AddInitialMetadata(ToString(iter->first), - ToString(iter->second)); - } - } - context->AddTrailingMetadata("trailing_key", "trailing_value"); - - while (stream->Read(&request)) { - response.set_message(request.message()); - stream->Write(response); - } - - return Status::OK; - } -}; - -} // namespace - -class GrpcToolTest : public ::testing::Test { - protected: - GrpcToolTest() {} - - // SetUpServer cannot be used with EXPECT_EXIT. grpc_pick_unused_port_or_die() - // uses atexit() to free chosen ports, and it will spawn a new thread in - // resolve_address_posix.c:192 at exit time. - TString SetUpServer(bool secure = false) { - std::ostringstream server_address; - int port = grpc_pick_unused_port_or_die(); - server_address << "localhost:" << port; - // Setup server - ServerBuilder builder; - std::shared_ptr<grpc::ServerCredentials> creds; - grpc_slice cert_slice, key_slice; - GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); - GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", grpc_load_file(SERVER_KEY_PATH, 1, &key_slice))); - const char* server_cert = - reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice); - const char* server_key = - reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice); - SslServerCredentialsOptions::PemKeyCertPair pkcp = {server_key, - server_cert}; - if (secure) { - SslServerCredentialsOptions ssl_opts; - ssl_opts.pem_root_certs = ""; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); - creds = SslServerCredentials(ssl_opts); - } else { - creds = InsecureServerCredentials(); - } - builder.AddListeningPort(server_address.str(), creds); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - grpc_slice_unref(cert_slice); - grpc_slice_unref(key_slice); - return server_address.str(); - } - - void ShutdownServer() { server_->Shutdown(); } - - std::unique_ptr<Server> server_; - TestServiceImpl service_; - reflection::ProtoServerReflectionPlugin plugin_; -}; - -TEST_F(GrpcToolTest, NoCommand) { - // Test input "grpc_cli" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli"}; - // Exit with 1, print usage instruction in stderr - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), "No command specified\n" USAGE_REGEX); - // No output - EXPECT_TRUE(0 == output_stream.tellp()); -} - -TEST_F(GrpcToolTest, InvalidCommand) { - // Test input "grpc_cli" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli", "abc"}; - // Exit with 1, print usage instruction in stderr - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), "Invalid command 'abc'\n" USAGE_REGEX); - // No output - EXPECT_TRUE(0 == output_stream.tellp()); -} - -TEST_F(GrpcToolTest, HelpCommand) { - // Test input "grpc_cli help" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli", "help"}; - // Exit with 1, print usage instruction in stderr - EXPECT_EXIT(GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1)), - ::testing::ExitedWithCode(1), USAGE_REGEX); - // No output - EXPECT_TRUE(0 == output_stream.tellp()); -} - -TEST_F(GrpcToolTest, ListCommand) { - // Test input "grpc_cli list localhost:<port>" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; - - y_absl::SetFlag(&FLAGS_l, false); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - "grpc.testing.EchoTestService\n" - "grpc.reflection.v1alpha.ServerReflection\n")); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, ListOneService) { - // Test input "grpc_cli list localhost:<port> grpc.testing.EchoTestService" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), - "grpc.testing.EchoTestService"}; - // without -l flag - y_absl::SetFlag(&FLAGS_l, false); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: ECHO_TEST_SERVICE_SUMMARY - EXPECT_TRUE(0 == - strcmp(output_stream.str().c_str(), ECHO_TEST_SERVICE_SUMMARY)); - - // with -l flag - output_stream.str(TString()); - output_stream.clear(); - y_absl::SetFlag(&FLAGS_l, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: ECHO_TEST_SERVICE_DESCRIPTION - EXPECT_TRUE( - 0 == strcmp(output_stream.str().c_str(), ECHO_TEST_SERVICE_DESCRIPTION)); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, TypeCommand) { - // Test input "grpc_cli type localhost:<port> grpc.testing.EchoRequest" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "type", server_address.c_str(), - "grpc.testing.EchoRequest"}; - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - const grpc::protobuf::Descriptor* desc = - grpc::protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName( - "grpc.testing.EchoRequest"); - // Expected output: the DebugString of grpc.testing.EchoRequest - EXPECT_TRUE(0 == - strcmp(output_stream.str().c_str(), desc->DebugString().c_str())); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, ListOneMethod) { - // Test input "grpc_cli list localhost:<port> grpc.testing.EchoTestService" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "ls", server_address.c_str(), - "grpc.testing.EchoTestService.Echo"}; - // without -l flag - y_absl::SetFlag(&FLAGS_l, false); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "Echo" - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), "Echo\n")); - - // with -l flag - output_stream.str(TString()); - output_stream.clear(); - y_absl::SetFlag(&FLAGS_l, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: ECHO_METHOD_DESCRIPTION - EXPECT_TRUE(0 == - strcmp(output_stream.str().c_str(), ECHO_METHOD_DESCRIPTION)); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, TypeNotFound) { - // Test input "grpc_cli type localhost:<port> grpc.testing.PhonyRequest" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "type", server_address.c_str(), - "grpc.testing.PhonyRequest"}; - - EXPECT_TRUE(1 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommand) { - // Test input "grpc_cli call localhost:<port> Echo "message: 'Hello'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "message: 'Hello'"}; - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "message: \"Hello\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello\"")); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - - // TODO(Capstan): Consider using y_absl::FlagSaver - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - - // Expected output: - // { - // "message": "Hello" - // } - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello\"\n}")); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandJsonInput) { - // Test input "grpc_cli call localhost:<port> Echo "{ \"message\": \"Hello\"}" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "{ \"message\": \"Hello\"}"}; - - y_absl::SetFlag(&FLAGS_json_input, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "message: \"Hello\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello\"")); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_json_input, false); - - // Expected output: - // { - // "message": "Hello" - // } - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello\"\n}")); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBatch) { - // Test input "grpc_cli call Echo" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "message: 'Hello0'"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: " - "\"Hello1\"\nmessage: \"Hello2\"\n")); - // with json_output - output_stream.str(TString()); - output_stream.clear(); - ss.clear(); - ss.seekg(0); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: - // { - // "message": "Hello0" - // } - // { - // "message": "Hello1" - // } - // { - // "message": "Hello2" - // } - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello0\"\n}\n" - "{\n \"message\": \"Hello1\"\n}\n" - "{\n \"message\": \"Hello2\"\n}\n")); - - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBatchJsonInput) { - // Test input "grpc_cli call Echo" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "{\"message\": \"Hello0\"}"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss( - "{\"message\": \"Hello1\"}\n\n{\"message\": \"Hello2\" }\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_json_input, true); - y_absl::SetFlag(&FLAGS_batch, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: " - "\"Hello1\"\nmessage: \"Hello2\"\n")); - // with json_output - output_stream.str(TString()); - output_stream.clear(); - ss.clear(); - ss.seekg(0); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_batch, false); - y_absl::SetFlag(&FLAGS_json_input, false); - - // Expected output: - // { - // "message": "Hello0" - // } - // { - // "message": "Hello1" - // } - // { - // "message": "Hello2" - // } - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello0\"\n}\n" - "{\n \"message\": \"Hello1\"\n}\n" - "{\n \"message\": \"Hello2\"\n}\n")); - - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) { - // Test input "grpc_cli call Echo" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "message: 'Hello0'"}; - - // Mock std::cin input "message: 1\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("message: 1\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: "message: "Hello0"\nmessage: "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: \"Hello2\"\n")); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - ss.clear(); - ss.seekg(0); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: - // { - // "message": "Hello0" - // } - // { - // "message": "Hello2" - // } - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello0\"\n}\n" - "{\n \"message\": \"Hello2\"\n}\n")); - - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBatchJsonInputWithBadRequest) { - // Test input "grpc_cli call Echo" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "{ \"message\": \"Hello0\"}"}; - - // Mock std::cin input "message: 1\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss( - "{ \"message\": 1 }\n\n { \"message\": \"Hello2\" }\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - y_absl::SetFlag(&FLAGS_json_input, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_input, false); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: "message: "Hello0"\nmessage: "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: \"Hello2\"\n")); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - ss.clear(); - ss.seekg(0); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_batch, true); - y_absl::SetFlag(&FLAGS_json_input, true); - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_json_input, false); - y_absl::SetFlag(&FLAGS_batch, false); - - // Expected output: - // { - // "message": "Hello0" - // } - // { - // "message": "Hello2" - // } - // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: - // "Hello2"\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "{\n \"message\": \"Hello0\"\n}\n" - "{\n \"message\": \"Hello2\"\n}\n")); - - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandRequestStream) { - // Test input: grpc_cli call localhost:<port> RequestStream "message: - // 'Hello0'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "RequestStream", "message: 'Hello0'"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: \"Hello0Hello1Hello2\"" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0Hello1Hello2\"")); - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandRequestStreamJsonInput) { - // Test input: grpc_cli call localhost:<port> RequestStream "{ \"message\": - // \"Hello0\"}" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "RequestStream", "{ \"message\": \"Hello0\" }"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss( - "{ \"message\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_json_input, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_input, false); - - // Expected output: "message: \"Hello0Hello1Hello2\"" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0Hello1Hello2\"")); - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) { - // Test input: grpc_cli call localhost:<port> RequestStream "message: - // 'Hello0'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "RequestStream", "message: 'Hello0'"}; - - // Mock std::cin input "bad_field: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("bad_field: 'Hello1'\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: \"Hello0Hello2\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\"")); - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequestJsonInput) { - // Test input: grpc_cli call localhost:<port> RequestStream "message: - // 'Hello0'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "RequestStream", "{ \"message\": \"Hello0\" }"}; - - // Mock std::cin input "bad_field: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss( - "{ \"bad_field\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - y_absl::SetFlag(&FLAGS_json_input, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_input, false); - - // Expected output: "message: \"Hello0Hello2\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\"")); - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandWithTimeoutDeadlineSet) { - // Test input "grpc_cli call CheckDeadlineSet --timeout=5000.25" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "CheckDeadlineSet"}; - - // Set timeout to 5000.25 seconds - y_absl::SetFlag(&FLAGS_timeout, 5000.25); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: "true"", deadline set - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"true\"")); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandWithTimeoutDeadlineUpperBound) { - // Test input "grpc_cli call CheckDeadlineUpperBound --timeout=900" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "CheckDeadlineUpperBound"}; - - // Set timeout to 900 seconds - y_absl::SetFlag(&FLAGS_timeout, 900); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - TString output = output_stream.str(); - - // Expected output: "message: "true"" - // deadline not greater than timeout + current time - EXPECT_TRUE(nullptr != strstr(output.c_str(), "message: \"true\"")) << output; - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandWithNegativeTimeoutValue) { - // Test input "grpc_cli call CheckDeadlineSet --timeout=-5" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "CheckDeadlineSet"}; - - // Set timeout to -5 (deadline not set) - y_absl::SetFlag(&FLAGS_timeout, -5); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: "false"", deadline not set - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"false\"")); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandWithDefaultTimeoutValue) { - // Test input "grpc_cli call CheckDeadlineSet --timeout=-1" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "CheckDeadlineSet"}; - - // Set timeout to -1 (default value, deadline not set) - y_absl::SetFlag(&FLAGS_timeout, -1); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: "false"", deadline not set - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"false\"")); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandResponseStream) { - // Test input: grpc_cli call localhost:<port> ResponseStream "message: - // 'Hello'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "ResponseStream", "message: 'Hello'"}; - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: \"Hello{n}\"" - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - TString expected_response_text = - "message: \"Hello" + ToString(i) + "\"\n"; - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - expected_response_text.c_str())); - } - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - - // Expected output: "{\n \"message\": \"Hello{n}\"\n}\n" - for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { - TString expected_response_text = - "{\n \"message\": \"Hello" + ToString(i) + "\"\n}\n"; - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - expected_response_text.c_str())); - } - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBidiStream) { - // Test input: grpc_cli call localhost:<port> BidiStream "message: 'Hello0'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "BidiStream", "message: 'Hello0'"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("message: 'Hello1'\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: - // \"Hello2\"\n\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: " - "\"Hello1\"\nmessage: \"Hello2\"\n")); - std::cin.rdbuf(orig); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandBidiStreamWithBadRequest) { - // Test input: grpc_cli call localhost:<port> BidiStream "message: 'Hello0'" - std::stringstream output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), - "BidiStream", "message: 'Hello0'"}; - - // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n" - std::streambuf* orig = std::cin.rdbuf(); - std::istringstream ss("message: 1.0\n\n message: 'Hello2'\n\n"); - std::cin.rdbuf(ss.rdbuf()); - - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: - // \"Hello2\"\n\n" - EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), - "message: \"Hello0\"\nmessage: \"Hello2\"\n")); - std::cin.rdbuf(orig); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, ParseCommand) { - // Test input "grpc_cli parse localhost:<port> grpc.testing.EchoResponse - // ECHO_RESPONSE_MESSAGE" - std::stringstream output_stream; - std::stringstream binary_output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "parse", server_address.c_str(), - "grpc.testing.EchoResponse", - ECHO_RESPONSE_MESSAGE_TEXT_FORMAT}; - - y_absl::SetFlag(&FLAGS_binary_input, false); - y_absl::SetFlag(&FLAGS_binary_output, false); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - ECHO_RESPONSE_MESSAGE_TEXT_FORMAT)); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - - // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - ECHO_RESPONSE_MESSAGE_JSON_FORMAT)); - - // Parse text message to binary message and then parse it back to text message - output_stream.str(TString()); - output_stream.clear(); - y_absl::SetFlag(&FLAGS_binary_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - TString binary_data = output_stream.str(); - output_stream.str(TString()); - output_stream.clear(); - argv[4] = binary_data.c_str(); - y_absl::SetFlag(&FLAGS_binary_input, true); - y_absl::SetFlag(&FLAGS_binary_output, false); - EXPECT_TRUE(0 == GrpcToolMainLib(5, argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: ECHO_RESPONSE_MESSAGE - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - ECHO_RESPONSE_MESSAGE_TEXT_FORMAT)); - - y_absl::SetFlag(&FLAGS_binary_input, false); - y_absl::SetFlag(&FLAGS_binary_output, false); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, ParseCommandJsonFormat) { - // Test input "grpc_cli parse localhost:<port> grpc.testing.EchoResponse - // ECHO_RESPONSE_MESSAGE_JSON_FORMAT" - std::stringstream output_stream; - std::stringstream binary_output_stream; - - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "parse", server_address.c_str(), - "grpc.testing.EchoResponse", - ECHO_RESPONSE_MESSAGE_JSON_FORMAT}; - - y_absl::SetFlag(&FLAGS_json_input, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - - // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - ECHO_RESPONSE_MESSAGE_TEXT_FORMAT)); - - // with json_output - output_stream.str(TString()); - output_stream.clear(); - - y_absl::SetFlag(&FLAGS_json_output, true); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_json_output, false); - y_absl::SetFlag(&FLAGS_json_input, false); - - // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - ECHO_RESPONSE_MESSAGE_JSON_FORMAT)); - - ShutdownServer(); -} - -TEST_F(GrpcToolTest, TooFewArguments) { - // Test input "grpc_cli call Echo" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli", "call", "Echo"}; - - // Exit with 1 - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), ".*Wrong number of arguments for call.*"); - // No output - EXPECT_TRUE(0 == output_stream.tellp()); -} - -TEST_F(GrpcToolTest, TooManyArguments) { - // Test input "grpc_cli call localhost:<port> Echo Echo "message: 'Hello'" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli", "call", "localhost:10000", - "Echo", "Echo", "message: 'Hello'"}; - - // Exit with 1 - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), ".*Wrong number of arguments for call.*"); - // No output - EXPECT_TRUE(0 == output_stream.tellp()); -} - -TEST_F(GrpcToolTest, CallCommandWithMetadata) { - // Test input "grpc_cli call localhost:<port> Echo "message: 'Hello'" - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo", - "message: 'Hello'"}; - - { - std::stringstream output_stream; - y_absl::SetFlag(&FLAGS_metadata, "key0:val0:key1:valq:key2:val2"); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, - TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "message: \"Hello\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello\"")); - } - - { - std::stringstream output_stream; - y_absl::SetFlag(&FLAGS_metadata, "key:val\\:val"); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, - TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "message: \"Hello\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello\"")); - } - - { - std::stringstream output_stream; - y_absl::SetFlag(&FLAGS_metadata, "key:val\\\\val"); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, - TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - // Expected output: "message: \"Hello\"" - EXPECT_TRUE(nullptr != - strstr(output_stream.str().c_str(), "message: \"Hello\"")); - } - - y_absl::SetFlag(&FLAGS_metadata, ""); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { - // Test input "grpc_cli call localhost:10000 Echo "message: 'Hello'" - const char* argv[] = {"grpc_cli", "call", "localhost:10000", - "grpc.testing.EchoTestService.Echo", - "message: 'Hello'"}; - y_absl::SetFlag(&FLAGS_protofiles, "src/proto/grpc/testing/echo.proto"); - char* test_srcdir = gpr_getenv("TEST_SRCDIR"); - if (test_srcdir != nullptr) { - y_absl::SetFlag(&FLAGS_proto_path, - test_srcdir + TString("/com_github_grpc_grpc")); - } - - { - std::stringstream output_stream; - y_absl::SetFlag(&FLAGS_metadata, "key0:val0:key1"); - // Exit with 1 - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*"); - } - - { - std::stringstream output_stream; - y_absl::SetFlag(&FLAGS_metadata, "key:val\\val"); - // Exit with 1 - EXPECT_EXIT( - GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, std::placeholders::_1)), - ::testing::ExitedWithCode(1), ".*Failed to parse metadata flag.*"); - } - - y_absl::SetFlag(&FLAGS_metadata, ""); - y_absl::SetFlag(&FLAGS_protofiles, ""); - - gpr_free(test_srcdir); -} - -TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) { - const TString server_address = SetUpServer(true); - - // Test input "grpc_cli ls localhost:<port> --channel_creds_type=ssl - // --ssl_target=z.test.google.fr" - std::stringstream output_stream; - const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; - y_absl::SetFlag(&FLAGS_l, false); - y_absl::SetFlag(&FLAGS_channel_creds_type, "ssl"); - y_absl::SetFlag(&FLAGS_ssl_target, "z.test.google.fr"); - EXPECT_TRUE( - 0 == GrpcToolMainLib( - ArraySize(argv), argv, TestCliCredentials(true), - std::bind(PrintStream, &output_stream, std::placeholders::_1))); - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - "grpc.testing.EchoTestService\n" - "grpc.reflection.v1alpha.ServerReflection\n")); - - y_absl::SetFlag(&FLAGS_channel_creds_type, ""); - y_absl::SetFlag(&FLAGS_ssl_target, ""); - ShutdownServer(); -} - -TEST_F(GrpcToolTest, ConfiguringDefaultServiceConfig) { - // Test input "grpc_cli list localhost:<port> - // --default_service_config={\"loadBalancingConfig\":[{\"pick_first\":{}}]}" - std::stringstream output_stream; - const TString server_address = SetUpServer(); - const char* argv[] = {"grpc_cli", "ls", server_address.c_str()}; - // Just check that the tool is still operational when --default_service_config - // is configured. This particular service config is in reality redundant with - // the channel's default configuration. - y_absl::SetFlag(&FLAGS_l, false); - y_absl::SetFlag(&FLAGS_default_service_config, - "{\"loadBalancingConfig\":[{\"pick_first\":{}}]}"); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), - std::bind(PrintStream, &output_stream, - std::placeholders::_1))); - y_absl::SetFlag(&FLAGS_default_service_config, ""); - EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(), - "grpc.testing.EchoTestService\n" - "grpc.reflection.v1alpha.ServerReflection\n")); - ShutdownServer(); -} - -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - GRPC_GTEST_FLAG_SET_DEATH_TEST_STYLE("threadsafe"); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/util/metrics_server.cc b/contrib/libs/grpc/test/cpp/util/metrics_server.cc deleted file mode 100644 index 0493da053e..0000000000 --- a/contrib/libs/grpc/test/cpp/util/metrics_server.cc +++ /dev/null @@ -1,117 +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. - *is % allowed in string - */ - -#include "test/cpp/util/metrics_server.h" - -#include <grpc/support/log.h> -#include <grpcpp/server.h> -#include <grpcpp/server_builder.h> - -#include "src/proto/grpc/testing/metrics.grpc.pb.h" -#include "src/proto/grpc/testing/metrics.pb.h" - -namespace grpc { -namespace testing { - -QpsGauge::QpsGauge() - : start_time_(gpr_now(GPR_CLOCK_REALTIME)), num_queries_(0) {} - -void QpsGauge::Reset() { - std::lock_guard<std::mutex> lock(num_queries_mu_); - num_queries_ = 0; - start_time_ = gpr_now(GPR_CLOCK_REALTIME); -} - -void QpsGauge::Incr() { - std::lock_guard<std::mutex> lock(num_queries_mu_); - num_queries_++; -} - -long QpsGauge::Get() { - std::lock_guard<std::mutex> lock(num_queries_mu_); - gpr_timespec time_diff = - gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time_); - long duration_secs = time_diff.tv_sec > 0 ? time_diff.tv_sec : 1; - return num_queries_ / duration_secs; -} - -grpc::Status MetricsServiceImpl::GetAllGauges( - ServerContext* /*context*/, const EmptyMessage* /*request*/, - ServerWriter<GaugeResponse>* writer) { - gpr_log(GPR_DEBUG, "GetAllGauges called"); - - std::lock_guard<std::mutex> lock(mu_); - for (auto it = qps_gauges_.begin(); it != qps_gauges_.end(); it++) { - GaugeResponse resp; - resp.set_name(it->first); // Gauge name - resp.set_long_value(it->second->Get()); // Gauge value - writer->Write(resp); - } - - return Status::OK; -} - -grpc::Status MetricsServiceImpl::GetGauge(ServerContext* /*context*/, - const GaugeRequest* request, - GaugeResponse* response) { - std::lock_guard<std::mutex> lock(mu_); - - const auto it = qps_gauges_.find(request->name()); - if (it != qps_gauges_.end()) { - response->set_name(it->first); - response->set_long_value(it->second->Get()); - } - - return Status::OK; -} - -std::shared_ptr<QpsGauge> MetricsServiceImpl::CreateQpsGauge( - const TString& name, bool* already_present) { - std::lock_guard<std::mutex> lock(mu_); - - std::shared_ptr<QpsGauge> qps_gauge(new QpsGauge()); - const auto p = qps_gauges_.insert(std::make_pair(name, qps_gauge)); - - // p.first is an iterator pointing to <name, shared_ptr<QpsGauge>> pair. - // p.second is a boolean which is set to 'true' if the QpsGauge is - // successfully inserted in the guages_ map and 'false' if it is already - // present in the map - *already_present = !p.second; - return p.first->second; -} - -// Starts the metrics server and returns the grpc::Server instance. Call Wait() -// on the returned server instance. -std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) { - gpr_log(GPR_INFO, "Building metrics server.."); - - const TString address = "0.0.0.0:" + ToString(port); - - ServerBuilder builder; - builder.AddListeningPort(address, grpc::InsecureServerCredentials()); - builder.RegisterService(this); - - std::unique_ptr<grpc::Server> server(builder.BuildAndStart()); - gpr_log(GPR_INFO, "Metrics server %s started. Ready to receive requests..", - address.c_str()); - - return server; -} - -} // namespace testing -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/metrics_server.h b/contrib/libs/grpc/test/cpp/util/metrics_server.h deleted file mode 100644 index 10ffa7b4dd..0000000000 --- a/contrib/libs/grpc/test/cpp/util/metrics_server.h +++ /dev/null @@ -1,98 +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. - *is % allowed in string - */ -#ifndef GRPC_TEST_CPP_METRICS_SERVER_H -#define GRPC_TEST_CPP_METRICS_SERVER_H - -#include <map> -#include <mutex> - -#include <grpcpp/server.h> - -#include "src/proto/grpc/testing/metrics.grpc.pb.h" -#include "src/proto/grpc/testing/metrics.pb.h" - -/* - * This implements a Metrics server defined in - * src/proto/grpc/testing/metrics.proto. Any - * test service can use this to export Metrics (TODO (sreek): Only Gauges for - * now). - * - * Example: - * MetricsServiceImpl metricsImpl; - * .. - * // Create QpsGauge(s). Note: QpsGauges can be created even after calling - * // 'StartServer'. - * QpsGauge qps_gauge1 = metricsImpl.CreateQpsGauge("foo", is_present); - * // qps_gauge1 can now be used anywhere in the program by first making a - * // one-time call qps_gauge1.Reset() and then calling qps_gauge1.Incr() - * // every time to increment a query counter - * - * ... - * // Create the metrics server - * std::unique_ptr<grpc::Server> server = metricsImpl.StartServer(port); - * server->Wait(); // Note: This is blocking. - */ -namespace grpc { -namespace testing { - -class QpsGauge { - public: - QpsGauge(); - - // Initialize the internal timer and reset the query count to 0 - void Reset(); - - // Increment the query count by 1 - void Incr(); - - // Return the current qps (i.e query count divided by the time since this - // QpsGauge object created (or Reset() was called)) - long Get(); - - private: - gpr_timespec start_time_; - long num_queries_; - std::mutex num_queries_mu_; -}; - -class MetricsServiceImpl final : public MetricsService::Service { - public: - grpc::Status GetAllGauges(ServerContext* context, const EmptyMessage* request, - ServerWriter<GaugeResponse>* writer) override; - - grpc::Status GetGauge(ServerContext* context, const GaugeRequest* request, - GaugeResponse* response) override; - - // Create a QpsGauge with name 'name'. is_present is set to true if the Gauge - // is already present in the map. - // NOTE: CreateQpsGauge can be called anytime (i.e before or after calling - // StartServer). - std::shared_ptr<QpsGauge> CreateQpsGauge(const TString& name, - bool* already_present); - - std::unique_ptr<grpc::Server> StartServer(int port); - - private: - std::map<string, std::shared_ptr<QpsGauge>> qps_gauges_; - std::mutex mu_; -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_METRICS_SERVER_H diff --git a/contrib/libs/grpc/test/cpp/util/slice_test.cc b/contrib/libs/grpc/test/cpp/util/slice_test.cc deleted file mode 100644 index c10319c5a2..0000000000 --- a/contrib/libs/grpc/test/cpp/util/slice_test.cc +++ /dev/null @@ -1,151 +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. - * - */ - -#include <gtest/gtest.h> - -#include <grpc++/support/slice.h> -#include <grpc/grpc.h> -#include <grpc/slice.h> -#include <grpcpp/impl/grpc_library.h> - -#include "test/core/util/test_config.h" - -namespace grpc { - -static internal::GrpcLibraryInitializer g_gli_initializer; - -namespace { - -const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world"; - -class SliceTest : public ::testing::Test { - protected: - static void SetUpTestCase() { grpc_init(); } - - static void TearDownTestCase() { grpc_shutdown(); } - - void CheckSliceSize(const Slice& s, const TString& content) { - EXPECT_EQ(content.size(), s.size()); - } - void CheckSlice(const Slice& s, const TString& content) { - EXPECT_EQ(content.size(), s.size()); - EXPECT_EQ(content, - TString(reinterpret_cast<const char*>(s.begin()), s.size())); - } -}; - -TEST_F(SliceTest, Empty) { - Slice empty_slice; - CheckSlice(empty_slice, ""); -} - -TEST_F(SliceTest, Sized) { - Slice sized_slice(strlen(kContent)); - CheckSliceSize(sized_slice, kContent); -} - -TEST_F(SliceTest, String) { - Slice spp(kContent); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, Buf) { - Slice spp(kContent, strlen(kContent)); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, StaticBuf) { - Slice spp(kContent, strlen(kContent), Slice::STATIC_SLICE); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, SliceNew) { - char* x = new char[strlen(kContent) + 1]; - strcpy(x, kContent); - Slice spp(x, strlen(x), [](void* p) { delete[] static_cast<char*>(p); }); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, SliceNewDoNothing) { - Slice spp(const_cast<char*>(kContent), strlen(kContent), [](void* /*p*/) {}); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, SliceNewWithUserData) { - struct stest { - char* x; - int y; - }; - auto* t = new stest; - t->x = new char[strlen(kContent) + 1]; - strcpy(t->x, kContent); - Slice spp( - t->x, strlen(t->x), - [](void* p) { - auto* t = static_cast<stest*>(p); - delete[] t->x; - delete t; - }, - t); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, SliceNewLen) { - Slice spp(const_cast<char*>(kContent), strlen(kContent), - [](void* /*p*/, size_t l) { EXPECT_EQ(l, strlen(kContent)); }); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, Steal) { - grpc_slice s = grpc_slice_from_copied_string(kContent); - Slice spp(s, Slice::STEAL_REF); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, Add) { - grpc_slice s = grpc_slice_from_copied_string(kContent); - Slice spp(s, Slice::ADD_REF); - grpc_slice_unref(s); - CheckSlice(spp, kContent); -} - -TEST_F(SliceTest, Sub) { - Slice spp("0123456789"); - Slice sub = spp.sub(1, 9); - CheckSlice(sub, "12345678"); -} - -TEST_F(SliceTest, Cslice) { - grpc_slice s = grpc_slice_from_copied_string(kContent); - Slice spp(s, Slice::STEAL_REF); - CheckSlice(spp, kContent); - grpc_slice c_slice = spp.c_slice(); - EXPECT_EQ(GRPC_SLICE_START_PTR(s), GRPC_SLICE_START_PTR(c_slice)); - EXPECT_EQ(GRPC_SLICE_END_PTR(s), GRPC_SLICE_END_PTR(c_slice)); - grpc_slice_unref(c_slice); -} - -} // namespace -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/contrib/libs/grpc/test/cpp/util/string_ref_test.cc b/contrib/libs/grpc/test/cpp/util/string_ref_test.cc deleted file mode 100644 index 1537e187e2..0000000000 --- a/contrib/libs/grpc/test/cpp/util/string_ref_test.cc +++ /dev/null @@ -1,205 +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. - * - */ - -#include <string.h> - -#include <gtest/gtest.h> - -#include <grpcpp/support/string_ref.h> - -#include "test/core/util/test_config.h" - -namespace grpc { -namespace { - -const char kTestString[] = "blah"; -const char kTestStringWithEmbeddedNull[] = "blah\0foo"; -const size_t kTestStringWithEmbeddedNullLength = 8; -const char kTestUnrelatedString[] = "foo"; - -class StringRefTest : public ::testing::Test {}; - -TEST_F(StringRefTest, Empty) { - string_ref s; - EXPECT_EQ(0U, s.length()); - EXPECT_EQ(nullptr, s.data()); -} - -TEST_F(StringRefTest, FromCString) { - string_ref s(kTestString); - EXPECT_EQ(strlen(kTestString), s.length()); - EXPECT_EQ(kTestString, s.data()); -} - -TEST_F(StringRefTest, FromCStringWithLength) { - string_ref s(kTestString, 2); - EXPECT_EQ(2U, s.length()); - EXPECT_EQ(kTestString, s.data()); -} - -TEST_F(StringRefTest, FromString) { - string copy(kTestString); - string_ref s(copy); - EXPECT_EQ(copy.data(), s.data()); - EXPECT_EQ(copy.length(), s.length()); -} - -TEST_F(StringRefTest, CopyConstructor) { - string_ref s1(kTestString); - ; - const string_ref& s2(s1); - EXPECT_EQ(s1.length(), s2.length()); - EXPECT_EQ(s1.data(), s2.data()); -} - -TEST_F(StringRefTest, FromStringWithEmbeddedNull) { - string copy(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - string_ref s(copy); - EXPECT_EQ(copy.data(), s.data()); - EXPECT_EQ(copy.length(), s.length()); - EXPECT_EQ(kTestStringWithEmbeddedNullLength, s.length()); -} - -TEST_F(StringRefTest, Assignment) { - string_ref s1(kTestString); - ; - string_ref s2; - EXPECT_EQ(nullptr, s2.data()); - s2 = s1; - EXPECT_EQ(s1.length(), s2.length()); - EXPECT_EQ(s1.data(), s2.data()); -} - -TEST_F(StringRefTest, Iterator) { - string_ref s(kTestString); - size_t i = 0; - for (auto it = s.cbegin(); it != s.cend(); ++it) { - auto val = kTestString[i++]; - EXPECT_EQ(val, *it); - } - EXPECT_EQ(strlen(kTestString), i); -} - -TEST_F(StringRefTest, ReverseIterator) { - string_ref s(kTestString); - size_t i = strlen(kTestString); - for (auto rit = s.crbegin(); rit != s.crend(); ++rit) { - auto val = kTestString[--i]; - EXPECT_EQ(val, *rit); - } - EXPECT_EQ(0U, i); -} - -TEST_F(StringRefTest, Capacity) { - string_ref empty; - EXPECT_EQ(0U, empty.length()); - EXPECT_EQ(0U, empty.size()); - EXPECT_EQ(0U, empty.max_size()); - EXPECT_TRUE(empty.empty()); - - string_ref s(kTestString); - EXPECT_EQ(strlen(kTestString), s.length()); - EXPECT_EQ(s.length(), s.size()); - EXPECT_EQ(s.max_size(), s.length()); - EXPECT_FALSE(s.empty()); -} - -TEST_F(StringRefTest, Compare) { - string_ref s1(kTestString); - string s1_copy(kTestString); - string_ref s2(kTestUnrelatedString); - string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - EXPECT_EQ(0, s1.compare(s1_copy)); - EXPECT_NE(0, s1.compare(s2)); - EXPECT_NE(0, s1.compare(s3)); -} - -TEST_F(StringRefTest, StartsWith) { - string_ref s1(kTestString); - string_ref s2(kTestUnrelatedString); - string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - EXPECT_TRUE(s1.starts_with(s1)); - EXPECT_FALSE(s1.starts_with(s2)); - EXPECT_FALSE(s2.starts_with(s1)); - EXPECT_FALSE(s1.starts_with(s3)); - EXPECT_TRUE(s3.starts_with(s1)); -} - -TEST_F(StringRefTest, Endswith) { - string_ref s1(kTestString); - string_ref s2(kTestUnrelatedString); - string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - EXPECT_TRUE(s1.ends_with(s1)); - EXPECT_FALSE(s1.ends_with(s2)); - EXPECT_FALSE(s2.ends_with(s1)); - EXPECT_FALSE(s2.ends_with(s3)); - EXPECT_TRUE(s3.ends_with(s2)); -} - -TEST_F(StringRefTest, Find) { - string_ref s1(kTestString); - string_ref s2(kTestUnrelatedString); - string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - EXPECT_EQ(0U, s1.find(s1)); - EXPECT_EQ(0U, s2.find(s2)); - EXPECT_EQ(0U, s3.find(s3)); - EXPECT_EQ(string_ref::npos, s1.find(s2)); - EXPECT_EQ(string_ref::npos, s2.find(s1)); - EXPECT_EQ(string_ref::npos, s1.find(s3)); - EXPECT_EQ(0U, s3.find(s1)); - EXPECT_EQ(5U, s3.find(s2)); - EXPECT_EQ(string_ref::npos, s1.find('z')); - EXPECT_EQ(1U, s2.find('o')); -} - -TEST_F(StringRefTest, SubString) { - string_ref s(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - string_ref sub1 = s.substr(0, 4); - EXPECT_EQ(string_ref(kTestString), sub1); - string_ref sub2 = s.substr(5); - EXPECT_EQ(string_ref(kTestUnrelatedString), sub2); -} - -TEST_F(StringRefTest, ComparisonOperators) { - string_ref s1(kTestString); - string_ref s2(kTestUnrelatedString); - string_ref s3(kTestStringWithEmbeddedNull, kTestStringWithEmbeddedNullLength); - EXPECT_EQ(s1, s1); - EXPECT_EQ(s2, s2); - EXPECT_EQ(s3, s3); - EXPECT_GE(s1, s1); - EXPECT_GE(s2, s2); - EXPECT_GE(s3, s3); - EXPECT_LE(s1, s1); - EXPECT_LE(s2, s2); - EXPECT_LE(s3, s3); - EXPECT_NE(s1, s2); - EXPECT_NE(s1, s3); - EXPECT_NE(s2, s3); - EXPECT_GT(s3, s1); - EXPECT_LT(s1, s3); -} - -} // namespace -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/util/subprocess.cc b/contrib/libs/grpc/test/cpp/util/subprocess.cc deleted file mode 100644 index 648bd50274..0000000000 --- a/contrib/libs/grpc/test/cpp/util/subprocess.cc +++ /dev/null @@ -1,44 +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. - * - */ - -#include "test/cpp/util/subprocess.h" - -#include <vector> - -#include "test/core/util/subprocess.h" - -namespace grpc { - -static gpr_subprocess* MakeProcess(const std::vector<TString>& args) { - std::vector<const char*> vargs; - for (auto it = args.begin(); it != args.end(); ++it) { - vargs.push_back(it->c_str()); - } - return gpr_subprocess_create(vargs.size(), &vargs[0]); -} - -SubProcess::SubProcess(const std::vector<TString>& args) - : subprocess_(MakeProcess(args)) {} - -SubProcess::~SubProcess() { gpr_subprocess_destroy(subprocess_); } - -int SubProcess::Join() { return gpr_subprocess_join(subprocess_); } - -void SubProcess::Interrupt() { gpr_subprocess_interrupt(subprocess_); } - -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/subprocess.h b/contrib/libs/grpc/test/cpp/util/subprocess.h deleted file mode 100644 index c01a15f0d7..0000000000 --- a/contrib/libs/grpc/test/cpp/util/subprocess.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CPP_UTIL_SUBPROCESS_H -#define GRPC_TEST_CPP_UTIL_SUBPROCESS_H - -#include <initializer_list> -#include <util/generic/string.h> -#include <vector> - -struct gpr_subprocess; - -namespace grpc { - -class SubProcess { - public: - explicit SubProcess(const std::vector<TString>& args); - ~SubProcess(); - - int Join(); - void Interrupt(); - - private: - SubProcess(const SubProcess& other); - SubProcess& operator=(const SubProcess& other); - - gpr_subprocess* const subprocess_; -}; - -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_SUBPROCESS_H diff --git a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc deleted file mode 100644 index 6f339dd3f5..0000000000 --- a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc +++ /dev/null @@ -1,183 +0,0 @@ - -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/cpp/util/test_credentials_provider.h" - -#include <cstdio> -#include <fstream> -#include <iostream> -#include <mutex> -#include <unordered_map> - -#include "y_absl/flags/flag.h" - -#include <grpc/support/log.h> -#include <grpc/support/sync.h> -#include <grpcpp/security/server_credentials.h> - -#include "test/core/end2end/data/ssl_test_data.h" - -Y_ABSL_FLAG(TString, tls_cert_file, "", - "The TLS cert file used when --use_tls=true"); -Y_ABSL_FLAG(TString, tls_key_file, "", - "The TLS key file used when --use_tls=true"); - -namespace grpc { -namespace testing { -namespace { - -TString ReadFile(const TString& src_path) { - std::ifstream src; - src.open(src_path, std::ifstream::in | std::ifstream::binary); - - TString contents; - src.seekg(0, std::ios::end); - contents.reserve(src.tellg()); - src.seekg(0, std::ios::beg); - contents.assign((std::istreambuf_iterator<char>(src)), - (std::istreambuf_iterator<char>())); - return contents; -} - -class DefaultCredentialsProvider : public CredentialsProvider { - public: - DefaultCredentialsProvider() { - if (!y_absl::GetFlag(FLAGS_tls_key_file).empty()) { - custom_server_key_ = ReadFile(y_absl::GetFlag(FLAGS_tls_key_file)); - } - if (!y_absl::GetFlag(FLAGS_tls_cert_file).empty()) { - custom_server_cert_ = ReadFile(y_absl::GetFlag(FLAGS_tls_cert_file)); - } - } - ~DefaultCredentialsProvider() override {} - - void AddSecureType( - const TString& type, - std::unique_ptr<CredentialTypeProvider> type_provider) override { - // This clobbers any existing entry for type, except the defaults, which - // can't be clobbered. - std::unique_lock<std::mutex> lock(mu_); - auto it = std::find(added_secure_type_names_.begin(), - added_secure_type_names_.end(), type); - if (it == added_secure_type_names_.end()) { - added_secure_type_names_.push_back(type); - added_secure_type_providers_.push_back(std::move(type_provider)); - } else { - added_secure_type_providers_[it - added_secure_type_names_.begin()] = - std::move(type_provider); - } - } - - std::shared_ptr<ChannelCredentials> GetChannelCredentials( - const TString& type, ChannelArguments* args) override { - if (type == grpc::testing::kInsecureCredentialsType) { - return InsecureChannelCredentials(); - } else if (type == grpc::testing::kAltsCredentialsType) { - grpc::experimental::AltsCredentialsOptions alts_opts; - return grpc::experimental::AltsCredentials(alts_opts); - } else if (type == grpc::testing::kTlsCredentialsType) { - SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; - args->SetSslTargetNameOverride("foo.test.google.fr"); - return grpc::SslCredentials(ssl_opts); - } else if (type == grpc::testing::kGoogleDefaultCredentialsType) { - return grpc::GoogleDefaultCredentials(); - } else { - std::unique_lock<std::mutex> lock(mu_); - 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()); - return nullptr; - } - return added_secure_type_providers_[it - added_secure_type_names_.begin()] - ->GetChannelCredentials(args); - } - } - - std::shared_ptr<ServerCredentials> GetServerCredentials( - const TString& type) override { - if (type == grpc::testing::kInsecureCredentialsType) { - return InsecureServerCredentials(); - } else if (type == grpc::testing::kAltsCredentialsType) { - grpc::experimental::AltsServerCredentialsOptions alts_opts; - return grpc::experimental::AltsServerCredentials(alts_opts); - } else if (type == grpc::testing::kTlsCredentialsType) { - SslServerCredentialsOptions ssl_opts; - ssl_opts.pem_root_certs = ""; - if (!custom_server_key_.empty() && !custom_server_cert_.empty()) { - SslServerCredentialsOptions::PemKeyCertPair pkcp = { - custom_server_key_, custom_server_cert_}; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); - } else { - SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, - test_server1_cert}; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); - } - return SslServerCredentials(ssl_opts); - } else { - std::unique_lock<std::mutex> lock(mu_); - 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()); - return nullptr; - } - return added_secure_type_providers_[it - added_secure_type_names_.begin()] - ->GetServerCredentials(); - } - } - std::vector<TString> GetSecureCredentialsTypeList() override { - std::vector<TString> types; - types.push_back(grpc::testing::kTlsCredentialsType); - std::unique_lock<std::mutex> lock(mu_); - for (auto it = added_secure_type_names_.begin(); - it != added_secure_type_names_.end(); it++) { - types.push_back(*it); - } - return types; - } - - private: - std::mutex mu_; - std::vector<TString> added_secure_type_names_; - std::vector<std::unique_ptr<CredentialTypeProvider>> - added_secure_type_providers_; - TString custom_server_key_; - TString custom_server_cert_; -}; - -CredentialsProvider* g_provider = nullptr; - -} // namespace - -CredentialsProvider* GetCredentialsProvider() { - if (g_provider == nullptr) { - g_provider = new DefaultCredentialsProvider; - } - return g_provider; -} - -void SetCredentialsProvider(CredentialsProvider* provider) { - // For now, forbids overriding provider. - GPR_ASSERT(g_provider == nullptr); - g_provider = provider; -} - -} // namespace testing -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h deleted file mode 100644 index acba277ada..0000000000 --- a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H -#define GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H - -#include <memory> - -#include <grpcpp/security/credentials.h> -#include <grpcpp/security/server_credentials.h> -#include <grpcpp/support/channel_arguments.h> - -namespace grpc { -namespace testing { - -const char kInsecureCredentialsType[] = "INSECURE_CREDENTIALS"; -// For real credentials, like tls/ssl, this name should match the AuthContext -// property "transport_security_type". -const char kTlsCredentialsType[] = "ssl"; -const char kAltsCredentialsType[] = "alts"; -const char kGoogleDefaultCredentialsType[] = "google_default_credentials"; - -// Provide test credentials of a particular type. -class CredentialTypeProvider { - public: - virtual ~CredentialTypeProvider() {} - - virtual std::shared_ptr<ChannelCredentials> GetChannelCredentials( - ChannelArguments* args) = 0; - virtual std::shared_ptr<ServerCredentials> GetServerCredentials() = 0; -}; - -// Provide test credentials. Thread-safe. -class CredentialsProvider { - public: - virtual ~CredentialsProvider() {} - - // Add a secure type in addition to the defaults. The default provider has - // (kInsecureCredentialsType, kTlsCredentialsType). - virtual void AddSecureType( - const TString& type, - std::unique_ptr<CredentialTypeProvider> type_provider) = 0; - - // Provide channel credentials according to the given type. Alter the channel - // arguments if needed. Return nullptr if type is not registered. - virtual std::shared_ptr<ChannelCredentials> GetChannelCredentials( - const TString& type, ChannelArguments* args) = 0; - - // Provide server credentials according to the given type. - // Return nullptr if type is not registered. - virtual std::shared_ptr<ServerCredentials> GetServerCredentials( - const TString& type) = 0; - - // Provide a list of secure credentials type. - virtual std::vector<TString> GetSecureCredentialsTypeList() = 0; -}; - -// Get the current provider. Create a default one if not set. -// Not thread-safe. -CredentialsProvider* GetCredentialsProvider(); - -// Set the global provider. Takes ownership. The previous set provider will be -// destroyed. -// Not thread-safe. -void SetCredentialsProvider(CredentialsProvider* provider); - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H diff --git a/contrib/libs/grpc/test/cpp/util/time_test.cc b/contrib/libs/grpc/test/cpp/util/time_test.cc deleted file mode 100644 index 4970f4b56b..0000000000 --- a/contrib/libs/grpc/test/cpp/util/time_test.cc +++ /dev/null @@ -1,72 +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. - * - */ - -#include <gtest/gtest.h> - -#include <grpc/support/time.h> -#include <grpcpp/support/time.h> - -#include "test/core/util/test_config.h" - -using std::chrono::microseconds; -using std::chrono::system_clock; - -namespace grpc { -namespace { - -class TimeTest : public ::testing::Test {}; - -TEST_F(TimeTest, AbsolutePointTest) { - int64_t us = 10000000L; - gpr_timespec ts = gpr_time_from_micros(us, GPR_TIMESPAN); - ts.clock_type = GPR_CLOCK_REALTIME; - system_clock::time_point tp{microseconds(us)}; - system_clock::time_point tp_converted = Timespec2Timepoint(ts); - gpr_timespec ts_converted; - Timepoint2Timespec(tp_converted, &ts_converted); - EXPECT_TRUE(ts.tv_sec == ts_converted.tv_sec); - EXPECT_TRUE(ts.tv_nsec == ts_converted.tv_nsec); - system_clock::time_point tp_converted_2 = Timespec2Timepoint(ts_converted); - EXPECT_TRUE(tp == tp_converted); - EXPECT_TRUE(tp == tp_converted_2); -} - -// gpr_inf_future is treated specially and mapped to/from time_point::max() -TEST_F(TimeTest, InfFuture) { - EXPECT_EQ(system_clock::time_point::max(), - Timespec2Timepoint(gpr_inf_future(GPR_CLOCK_REALTIME))); - gpr_timespec from_time_point_max; - Timepoint2Timespec(system_clock::time_point::max(), &from_time_point_max); - EXPECT_EQ( - 0, gpr_time_cmp(gpr_inf_future(GPR_CLOCK_REALTIME), from_time_point_max)); - // This will cause an overflow - Timepoint2Timespec( - std::chrono::time_point<system_clock, std::chrono::seconds>::max(), - &from_time_point_max); - EXPECT_EQ( - 0, gpr_time_cmp(gpr_inf_future(GPR_CLOCK_REALTIME), from_time_point_max)); -} - -} // namespace -} // namespace grpc - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/contrib/libs/grpc/test/cpp/util/tls_test_utils.cc b/contrib/libs/grpc/test/cpp/util/tls_test_utils.cc deleted file mode 100644 index 6bf727c8cb..0000000000 --- a/contrib/libs/grpc/test/cpp/util/tls_test_utils.cc +++ /dev/null @@ -1,99 +0,0 @@ -// -// 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. -// - -#include "test/cpp/util/tls_test_utils.h" - -#include <memory> - -#include "src/core/lib/gprpp/thd.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -using ::grpc::experimental::ExternalCertificateVerifier; -using ::grpc::experimental::TlsCustomVerificationCheckRequest; - -namespace grpc { -namespace testing { - -bool SyncCertificateVerifier::Verify(TlsCustomVerificationCheckRequest*, - std::function<void(grpc::Status)>, - grpc::Status* sync_status) { - if (!success_) { - *sync_status = grpc::Status(grpc::StatusCode::UNAUTHENTICATED, - "SyncCertificateVerifier failed"); - } else { - *sync_status = grpc::Status(grpc::StatusCode::OK, ""); - } - return true; -} - -AsyncCertificateVerifier::AsyncCertificateVerifier(bool success) - : success_(success), - thread_("AsyncCertificateVerifierWorkerThread", WorkerThread, this) { - thread_.Start(); -} - -AsyncCertificateVerifier::~AsyncCertificateVerifier() { - // Tell the thread to shut down. - { - internal::MutexLock lock(&mu_); - queue_.push_back(Request{nullptr, nullptr, true}); - } - // Wait for thread to exit. - thread_.Join(); -} - -bool AsyncCertificateVerifier::Verify( - TlsCustomVerificationCheckRequest* request, - std::function<void(grpc::Status)> callback, grpc::Status*) { - internal::MutexLock lock(&mu_); - queue_.push_back(Request{request, std::move(callback), false}); - return false; // Asynchronous call -} - -void AsyncCertificateVerifier::WorkerThread(void* arg) { - auto* self = static_cast<AsyncCertificateVerifier*>(arg); - while (true) { - // Check queue for work. - bool got_request = false; - Request request; - { - internal::MutexLock lock(&self->mu_); - if (!self->queue_.empty()) { - got_request = true; - request = self->queue_.front(); - self->queue_.pop_front(); - } - } - // If nothing found in the queue, sleep for a bit and try again. - if (!got_request) { - gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100)); - continue; - } - // If we're being told to shut down, return. - if (request.shutdown) return; - auto return_status = grpc::Status(grpc::StatusCode::OK, ""); - // Process the request. - if (!self->success_) { - return_status = grpc::Status(grpc::StatusCode::UNAUTHENTICATED, - "AsyncCertificateVerifier failed"); - } - request.callback(return_status); - } -} - -} // namespace testing -} // namespace grpc diff --git a/contrib/libs/grpc/test/cpp/util/tls_test_utils.h b/contrib/libs/grpc/test/cpp/util/tls_test_utils.h deleted file mode 100644 index 3f8d3d5a5d..0000000000 --- a/contrib/libs/grpc/test/cpp/util/tls_test_utils.h +++ /dev/null @@ -1,82 +0,0 @@ -// -// 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. -// - -#ifndef GRPC_TEST_CPP_UTIL_TLS_TEST_UTILS_H -#define GRPC_TEST_CPP_UTIL_TLS_TEST_UTILS_H - -#include <deque> - -#include <grpc/grpc.h> -#include <grpc/grpc_security.h> -#include <grpcpp/security/server_credentials.h> - -#include "src/core/lib/gprpp/thd.h" - -namespace grpc { -namespace testing { - -class SyncCertificateVerifier - : public ::grpc::experimental::ExternalCertificateVerifier { - public: - explicit SyncCertificateVerifier(bool success) : success_(success) {} - - ~SyncCertificateVerifier() override {} - - bool Verify(::grpc::experimental::TlsCustomVerificationCheckRequest* request, - std::function<void(grpc::Status)> callback, - grpc::Status* sync_status) override; - - void Cancel( - ::grpc::experimental::TlsCustomVerificationCheckRequest*) override {} - - private: - bool success_ = false; -}; - -class AsyncCertificateVerifier - : public ::grpc::experimental::ExternalCertificateVerifier { - public: - explicit AsyncCertificateVerifier(bool success); - - ~AsyncCertificateVerifier() override; - - bool Verify(::grpc::experimental::TlsCustomVerificationCheckRequest* request, - std::function<void(grpc::Status)> callback, - grpc::Status* sync_status) override; - - void Cancel( - ::grpc::experimental::TlsCustomVerificationCheckRequest*) override {} - - private: - // A request to pass to the worker thread. - struct Request { - ::grpc::experimental::TlsCustomVerificationCheckRequest* request; - std::function<void(grpc::Status)> callback; - bool shutdown; // If true, thread will exit. - }; - - static void WorkerThread(void* arg); - - bool success_ = false; - grpc_core::Thread thread_; - grpc::internal::Mutex mu_; - std::deque<Request> queue_ Y_ABSL_GUARDED_BY(mu_); -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_TLS_TEST_UTILS_H diff --git a/contrib/libs/grpc/third_party/address_sorting/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/third_party/address_sorting/.yandex_meta/licenses.list.txt deleted file mode 100644 index 2b12fd7215..0000000000 --- a/contrib/libs/grpc/third_party/address_sorting/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,54 +0,0 @@ -====================BSD-3-Clause==================== - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - - -====================BSD-3-Clause==================== -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the project nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -====================COPYRIGHT==================== - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. diff --git a/contrib/libs/grpc/third_party/upb/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/third_party/upb/.yandex_meta/licenses.list.txt deleted file mode 100644 index 5c18842012..0000000000 --- a/contrib/libs/grpc/third_party/upb/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,99 +0,0 @@ -====================BSD-3-Clause==================== - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Google LLC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -====================BSD-3-Clause==================== -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of Google LLC nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -====================BSD-3-Clause==================== -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Google LLC nor the names of any other - contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -EVENT SHALL GOOGLE LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -====================BSD-3-Clause AND BSD-3-Clause==================== - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Google LLC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -====================COPYRIGHT==================== -Copyright (c) 2009-2021, Google LLC -All rights reserved. diff --git a/contrib/libs/grpc/tools/codegen/core/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/tools/codegen/core/.yandex_meta/licenses.list.txt deleted file mode 100644 index c982a91eb1..0000000000 --- a/contrib/libs/grpc/tools/codegen/core/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,16 +0,0 @@ -====================Apache-2.0==================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2015 gRPC authors. |