From dbaeee26111f954daeafcb94f9f4afa85dd12a6d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 15 Apr 2024 14:17:43 -0700 Subject: [PATCH 01/45] Revert "[experiments] Stabilize http2_stats_fix (#36351)" (#36362) Missed a few steps before stabilizing this Closes #36362 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36362 from yashykt:Revert36351 5110bc04ecdf29d4d2cbb2609a69eb596b7e644c PiperOrigin-RevId: 625080972 --- bazel/experiments.bzl | 1 + .../chttp2/transport/chttp2_transport.cc | 8 +++++--- .../ext/transport/chttp2/transport/frame_data.cc | 3 +++ src/core/lib/experiments/experiments.cc | 15 +++++++++++++++ src/core/lib/experiments/experiments.h | 11 +++++++++++ src/core/lib/experiments/experiments.yaml | 6 ++++++ test/core/end2end/tests/http2_stats.cc | 3 +++ 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/bazel/experiments.bzl b/bazel/experiments.bzl index 0e5f00b71eb..e366840a1e6 100644 --- a/bazel/experiments.bzl +++ b/bazel/experiments.bzl @@ -25,6 +25,7 @@ EXPERIMENT_ENABLES = { "event_engine_dns": "event_engine_dns", "event_engine_listener": "event_engine_listener", "free_large_allocator": "free_large_allocator", + "http2_stats_fix": "http2_stats_fix", "keepalive_fix": "keepalive_fix", "keepalive_server_fix": "keepalive_server_fix", "monitoring_experiment": "monitoring_experiment", diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 6be0152cae6..a1e490e44b6 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1471,9 +1471,11 @@ static void perform_stream_op_locked(void* stream_op, frame_hdr[3] = static_cast(len >> 8); frame_hdr[4] = static_cast(len); - s->stats.outgoing.framing_bytes += GRPC_HEADER_SIZE_IN_BYTES; - s->stats.outgoing.data_bytes += - op_payload->send_message.send_message->Length(); + if (grpc_core::IsHttp2StatsFixEnabled()) { + s->stats.outgoing.framing_bytes += GRPC_HEADER_SIZE_IN_BYTES; + s->stats.outgoing.data_bytes += + op_payload->send_message.send_message->Length(); + } s->next_message_end_offset = s->flow_controlled_bytes_written + static_cast(s->flow_controlled_buffer.length) + diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 334eff52f22..e10dea34134 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -78,6 +78,9 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf, grpc_slice_buffer_move_first_no_ref(inbuf, write_bytes, outbuf); stats->framing_bytes += header_size; + if (!grpc_core::IsHttp2StatsFixEnabled()) { + stats->data_bytes += write_bytes; + } } grpc_core::Poll grpc_deframe_unprocessed_incoming_frames( diff --git a/src/core/lib/experiments/experiments.cc b/src/core/lib/experiments/experiments.cc index 460dd87650c..3f9e6a840ca 100644 --- a/src/core/lib/experiments/experiments.cc +++ b/src/core/lib/experiments/experiments.cc @@ -48,6 +48,9 @@ const char* const additional_constraints_event_engine_listener = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; +const char* const description_http2_stats_fix = + "Fix on HTTP2 outgoing data stats reporting"; +const char* const additional_constraints_http2_stats_fix = "{}"; const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; @@ -162,6 +165,8 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_event_engine_listener, nullptr, 0, false, true}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, + {"http2_stats_fix", description_http2_stats_fix, + additional_constraints_http2_stats_fix, nullptr, 0, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, nullptr, 0, false, false}, {"keepalive_server_fix", description_keepalive_server_fix, @@ -243,6 +248,9 @@ const char* const additional_constraints_event_engine_listener = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; +const char* const description_http2_stats_fix = + "Fix on HTTP2 outgoing data stats reporting"; +const char* const additional_constraints_http2_stats_fix = "{}"; const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; @@ -357,6 +365,8 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_event_engine_listener, nullptr, 0, true, true}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, + {"http2_stats_fix", description_http2_stats_fix, + additional_constraints_http2_stats_fix, nullptr, 0, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, nullptr, 0, false, false}, {"keepalive_server_fix", description_keepalive_server_fix, @@ -438,6 +448,9 @@ const char* const additional_constraints_event_engine_listener = "{}"; const char* const description_free_large_allocator = "If set, return all free bytes from a \042big\042 allocator"; const char* const additional_constraints_free_large_allocator = "{}"; +const char* const description_http2_stats_fix = + "Fix on HTTP2 outgoing data stats reporting"; +const char* const additional_constraints_http2_stats_fix = "{}"; const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; @@ -552,6 +565,8 @@ const ExperimentMetadata g_experiment_metadata[] = { additional_constraints_event_engine_listener, nullptr, 0, true, true}, {"free_large_allocator", description_free_large_allocator, additional_constraints_free_large_allocator, nullptr, 0, false, true}, + {"http2_stats_fix", description_http2_stats_fix, + additional_constraints_http2_stats_fix, nullptr, 0, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, nullptr, 0, false, false}, {"keepalive_server_fix", description_keepalive_server_fix, diff --git a/src/core/lib/experiments/experiments.h b/src/core/lib/experiments/experiments.h index 39c448f5943..faf13fca4cf 100644 --- a/src/core/lib/experiments/experiments.h +++ b/src/core/lib/experiments/experiments.h @@ -66,6 +66,8 @@ inline bool IsEventEngineClientEnabled() { return false; } inline bool IsEventEngineDnsEnabled() { return false; } inline bool IsEventEngineListenerEnabled() { return false; } inline bool IsFreeLargeAllocatorEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX +inline bool IsHttp2StatsFixEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } inline bool IsKeepaliveServerFixEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT @@ -103,6 +105,8 @@ inline bool IsEventEngineDnsEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_LISTENER inline bool IsEventEngineListenerEnabled() { return true; } inline bool IsFreeLargeAllocatorEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX +inline bool IsHttp2StatsFixEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } inline bool IsKeepaliveServerFixEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT @@ -141,6 +145,8 @@ inline bool IsEventEngineDnsEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_LISTENER inline bool IsEventEngineListenerEnabled() { return true; } inline bool IsFreeLargeAllocatorEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX +inline bool IsHttp2StatsFixEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } inline bool IsKeepaliveServerFixEnabled() { return false; } #define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT @@ -179,6 +185,7 @@ enum ExperimentIds { kExperimentIdEventEngineDns, kExperimentIdEventEngineListener, kExperimentIdFreeLargeAllocator, + kExperimentIdHttp2StatsFix, kExperimentIdKeepaliveFix, kExperimentIdKeepaliveServerFix, kExperimentIdMonitoringExperiment, @@ -233,6 +240,10 @@ inline bool IsEventEngineListenerEnabled() { inline bool IsFreeLargeAllocatorEnabled() { return IsExperimentEnabled(kExperimentIdFreeLargeAllocator); } +#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX +inline bool IsHttp2StatsFixEnabled() { + return IsExperimentEnabled(kExperimentIdHttp2StatsFix); +} #define GRPC_EXPERIMENT_IS_INCLUDED_KEEPALIVE_FIX inline bool IsKeepaliveFixEnabled() { return IsExperimentEnabled(kExperimentIdKeepaliveFix); diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index 37f9003adbc..9be9619ff3c 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -98,6 +98,12 @@ expiry: 2024/08/01 owner: alishananda@google.com test_tags: [resource_quota_test] +- name: http2_stats_fix + description: + Fix on HTTP2 outgoing data stats reporting + expiry: 2024/09/30 + owner: yashkt@google.com + test_tags: [] - name: keepalive_fix description: Allows overriding keepalive_permit_without_calls. diff --git a/test/core/end2end/tests/http2_stats.cc b/test/core/end2end/tests/http2_stats.cc index b12d7a431a0..5e497f7b8f2 100644 --- a/test/core/end2end/tests/http2_stats.cc +++ b/test/core/end2end/tests/http2_stats.cc @@ -193,6 +193,9 @@ class NewFakeStatsPlugin : public FakeStatsPlugin { // This test verifies the HTTP2 stats on a stream CORE_END2END_TEST(Http2FullstackSingleHopTest, StreamStats) { + if (!IsHttp2StatsFixEnabled()) { + GTEST_SKIP() << "Test needs http2_stats_fix experiment to be enabled"; + } g_mu = new Mutex(); g_client_call_ended_notify = new Notification(); g_server_call_ended_notify = new Notification(); From 7d04e020dfdaf3811eefcbe94dfe434e140b0c58 Mon Sep 17 00:00:00 2001 From: Xuan Wang Date: Mon, 15 Apr 2024 14:27:00 -0700 Subject: [PATCH 02/45] [Python Dist] Fix grpc_distribtests_python (#36352) `setuptools` made a decision to change the artifact name it builds (from `grpcio-health-checking` to `grpcio_health_checking`) in their latest release (https://github.com/pypa/setuptools/issues/4300). As a result, we need broaden our regex so that our tests can pickup the correct files. ### Note * Using `[_-]*` instead of `[_-]?` to match one character since `bash` uses a different flavor of regular expressions called basic regular expressions (BREs) which do not support the optional quantifier `?`. Closes #36352 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36352 from XuanWang-Amos:fix_distribution_test 8dfcc4e9a3b3513b8c8d0a5321d689592e1fe7da PiperOrigin-RevId: 625083784 --- test/distrib/python/test_packages.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/distrib/python/test_packages.sh b/test/distrib/python/test_packages.sh index 136632833b1..fa6f2fceeeb 100755 --- a/test/distrib/python/test_packages.sh +++ b/test/distrib/python/test_packages.sh @@ -19,22 +19,25 @@ cd "$(dirname "$0")" shopt -s nullglob +echo "Testing Python packages with input artifacts:" +ls "$EXTERNAL_GIT_ROOT"/input_artifacts + if [[ "$1" == "binary" ]] then echo "Testing Python binary distribution" - ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-[0-9]*.whl) - TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-[0-9]*.whl) - OBSERVABILITY_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_observability-[0-9]*.whl) + ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[-_0-9a-z.]*.whl) + TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*tools[-_0-9a-z.]*.whl) + OBSERVABILITY_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*observability[-_0-9a-z.]*.whl) else echo "Testing Python source distribution" - ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-[0-9]*.tar.gz) - TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-tools-[0-9]*.tar.gz) - OBSERVABILITY_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-observability-[0-9]*.tar.gz) + ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[-_0-9a-z.]*.tar.gz) + TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*tools[-_0-9a-z.]*.tar.gz) + OBSERVABILITY_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*observability[-_0-9a-z.]*.tar.gz) fi -HEALTH_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-health-checking-[0-9]*.tar.gz) -REFLECTION_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-reflection-[0-9]*.tar.gz) -TESTING_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-testing-[0-9]*.tar.gz) +HEALTH_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*health[_-]*checking[-_0-9a-z.]*.tar.gz) +REFLECTION_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*reflection[-_0-9a-z.]*.tar.gz) +TESTING_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio[_-]*testing[-_0-9a-z.]*.tar.gz) VIRTUAL_ENV=$(mktemp -d) python3 -m virtualenv "$VIRTUAL_ENV" From 8a6a02ff4daa2571a8f9b5190a3e31d308840355 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 15 Apr 2024 15:06:19 -0700 Subject: [PATCH 03/45] [call-v3] Interim step to allow multiple representations of CallSpine (#36321) Make `CallSpineInterface` describe the operations that we need, and return `Promise<>` types -- these are `std::function` wrappers and involve an allocation. This ought to be acceptable for the use cases we'll be using `CallSpineInterface` for in the short term - and doing this lets us bring the rest of the v3 stack in concurrently with the "v2.5" stack -- the v2 stack using some of the v3 interfaces I put together to unblock chaotic-good. Later we'll remove this scaffolding and eventually `CallSpineInterface` in its entirety, in preference to something wrapped around `CallFilters`. Closes #36321 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36321 from ctiller:cally-2 7f608c36d37473d647ebc6ea4c3d69402ba1f285 PiperOrigin-RevId: 625096226 --- src/core/BUILD | 3 +- .../ext/filters/deadline/deadline_filter.cc | 5 +- .../message_size/message_size_filter.cc | 2 +- .../chaotic_good/client_transport.cc | 20 +- .../chaotic_good/server_transport.cc | 54 ++- .../ext/transport/inproc/inproc_transport.cc | 10 +- .../lib/channel/channel_stack_builder_impl.cc | 16 +- src/core/lib/channel/connected_channel.cc | 59 +-- src/core/lib/channel/promise_based_filter.cc | 4 +- src/core/lib/channel/promise_based_filter.h | 145 +++---- .../lib/channel/server_call_tracer_filter.cc | 1 + src/core/lib/promise/for_each.h | 84 +++- src/core/lib/promise/pipe.h | 2 +- src/core/lib/surface/call.cc | 72 ++-- src/core/lib/surface/call.h | 7 +- src/core/lib/surface/server.cc | 35 +- src/core/lib/surface/server.h | 2 +- src/core/lib/transport/batch_builder.h | 7 +- src/core/lib/transport/call_spine.cc | 28 +- src/core/lib/transport/call_spine.h | 394 +++++++++++------- src/core/lib/transport/transport.h | 2 +- .../core/end2end/tests/filter_causes_close.cc | 9 +- .../client_transport_error_test.cc | 129 +++--- .../chaotic_good/client_transport_test.cc | 76 ++-- .../chaotic_good/server_transport_test.cc | 92 ++-- .../core/transport/test_suite/call_content.cc | 45 +- test/core/transport/test_suite/call_shapes.cc | 337 +++++++-------- test/core/transport/test_suite/stress.cc | 48 +-- test/core/transport/test_suite/test.cc | 23 +- test/core/transport/test_suite/test.h | 4 +- 30 files changed, 900 insertions(+), 815 deletions(-) diff --git a/src/core/BUILD b/src/core/BUILD index 437735b143f..3ecb922f38b 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -6451,7 +6451,6 @@ grpc_cc_library( "//:endpoint_addresses", "//:gpr", "//:grpc_base", - "//:grpc_client_channel", "//:grpc_public_hdrs", "//:grpc_resolver", "//:grpc_service_config_impl", @@ -7341,7 +7340,6 @@ grpc_cc_library( ], deps = [ "1999", - "call_final_info", "for_each", "if", "latch", @@ -7353,6 +7351,7 @@ grpc_cc_library( "status_flag", "try_seq", "//:gpr", + "//:promise", ], ) diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index 588827b9584..a2dc24594e2 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -370,8 +370,9 @@ const grpc_channel_filter grpc_server_deadline_filter = { return next_promise_factory(std::move(call_args)); }, [](grpc_channel_element*, grpc_core::CallSpineInterface* spine) { - spine->client_initial_metadata().receiver.InterceptAndMap( - [](grpc_core::ClientMetadataHandle md) { + grpc_core::DownCast(spine) + ->client_initial_metadata() + .receiver.InterceptAndMap([](grpc_core::ClientMetadataHandle md) { auto deadline = md->get(grpc_core::GrpcTimeoutMetadata()); if (deadline.has_value()) { grpc_core::GetContext()->UpdateDeadline( diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index 252bb1a46cb..d975282432a 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -168,7 +168,7 @@ ServerMetadataHandle CheckPayload(const Message& msg, is_send ? "send" : "recv", msg.payload()->Length(), *max_length); } if (msg.payload()->Length() <= *max_length) return nullptr; - auto r = GetContext()->MakePooled(); + auto r = Arena::MakePooled(); r->Set(GrpcStatusMetadata(), GRPC_STATUS_RESOURCE_EXHAUSTED); r->Set(GrpcMessageMetadata(), Slice::FromCopiedString(absl::StrFormat( diff --git a/src/core/ext/transport/chaotic_good/client_transport.cc b/src/core/ext/transport/chaotic_good/client_transport.cc index 14be491f0ee..6b3160e8182 100644 --- a/src/core/ext/transport/chaotic_good/client_transport.cc +++ b/src/core/ext/transport/chaotic_good/client_transport.cc @@ -102,14 +102,12 @@ auto ChaoticGoodClientTransport::PushFrameIntoCall(ServerFragmentFrame frame, }, []() -> StatusFlag { return Success{}; }); }, - [call_handler, trailers = std::move(frame.trailers)]() mutable { - return If( - trailers != nullptr, - [&call_handler, &trailers]() mutable { - return call_handler.PushServerTrailingMetadata( - std::move(trailers)); - }, - []() -> StatusFlag { return Success{}; }); + [call_handler, + trailers = std::move(frame.trailers)]() mutable -> StatusFlag { + if (trailers != nullptr) { + call_handler.PushServerTrailingMetadata(std::move(trailers)); + } + return Success{}; }); // Wrap the actual sequence with something that owns the call handler so that // its lifetime extends until the push completes. @@ -223,7 +221,7 @@ void ChaoticGoodClientTransport::AbortWithError() { for (const auto& pair : stream_map) { auto call_handler = pair.second; call_handler.SpawnInfallible("cancel", [call_handler]() mutable { - call_handler.Cancel(ServerMetadataFromStatus( + call_handler.PushServerTrailingMetadata(ServerMetadataFromStatus( absl::UnavailableError("Transport closed."))); return Empty{}; }); @@ -300,6 +298,10 @@ void ChaoticGoodClientTransport::StartCall(CallHandler call_handler) { const uint32_t stream_id = MakeStream(call_handler); return Map(CallOutboundLoop(stream_id, call_handler), [stream_id, this](absl::Status result) { + if (grpc_chaotic_good_trace.enabled()) { + gpr_log(GPR_INFO, "CHAOTIC_GOOD: Call %d finished with %s", + stream_id, result.ToString().c_str()); + } if (!result.ok()) { CancelFrame frame; frame.stream_id = stream_id; diff --git a/src/core/ext/transport/chaotic_good/server_transport.cc b/src/core/ext/transport/chaotic_good/server_transport.cc index 05edb2d0eb3..7975975203c 100644 --- a/src/core/ext/transport/chaotic_good/server_transport.cc +++ b/src/core/ext/transport/chaotic_good/server_transport.cc @@ -72,33 +72,29 @@ auto ChaoticGoodServerTransport::TransportWriteLoop( auto ChaoticGoodServerTransport::PushFragmentIntoCall( CallInitiator call_initiator, ClientFragmentFrame frame, uint32_t stream_id) { - auto& headers = frame.headers; - return TrySeq( - If( - headers != nullptr, - [call_initiator, &headers]() mutable { - return call_initiator.PushClientInitialMetadata(std::move(headers)); - }, - []() -> StatusFlag { return Success{}; }), - [call_initiator, message = std::move(frame.message)]() mutable { - return If( - message.has_value(), - [&call_initiator, &message]() mutable { - return call_initiator.PushMessage(std::move(message->message)); - }, - []() -> StatusFlag { return Success{}; }); - }, - [this, call_initiator, end_of_stream = frame.end_of_stream, - stream_id]() mutable -> StatusFlag { - if (end_of_stream) { - call_initiator.FinishSends(); - // We have received end_of_stream. It is now safe to remove the call - // from the stream map. - MutexLock lock(&mu_); - stream_map_.erase(stream_id); - } - return Success{}; - }); + GPR_DEBUG_ASSERT(frame.headers == nullptr); + if (grpc_chaotic_good_trace.enabled()) { + gpr_log(GPR_INFO, "CHAOTIC_GOOD: PushFragmentIntoCall: frame=%s", + frame.ToString().c_str()); + } + return TrySeq(If( + frame.message.has_value(), + [&call_initiator, &frame]() mutable { + return call_initiator.PushMessage( + std::move(frame.message->message)); + }, + []() -> StatusFlag { return Success{}; }), + [this, call_initiator, end_of_stream = frame.end_of_stream, + stream_id]() mutable -> StatusFlag { + if (end_of_stream) { + call_initiator.FinishSends(); + // We have received end_of_stream. It is now safe to remove + // the call from the stream map. + MutexLock lock(&mu_); + stream_map_.erase(stream_id); + } + return Success{}; + }); } auto ChaoticGoodServerTransport::MaybePushFragmentIntoCall( @@ -244,8 +240,8 @@ auto ChaoticGoodServerTransport::DeserializeAndPushFragmentToNewCall( FrameLimits{1024 * 1024 * 1024, aligned_bytes_ - 1}); absl::optional call_initiator; if (status.ok()) { - auto create_call_result = - acceptor_->CreateCall(*fragment_frame.headers, arena.release()); + auto create_call_result = acceptor_->CreateCall( + std::move(fragment_frame.headers), arena.release()); if (grpc_chaotic_good_trace.enabled()) { gpr_log(GPR_INFO, "CHAOTIC_GOOD: DeserializeAndPushFragmentToNewCall: " diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 7be425993e1..d49dce8daf6 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -83,7 +83,7 @@ class InprocServerTransport final : public RefCounted, "inproc transport disconnected"); } - absl::StatusOr AcceptCall(ClientMetadata& md) { + absl::StatusOr AcceptCall(ClientMetadataHandle md) { switch (state_.load(std::memory_order_acquire)) { case ConnectionState::kInitial: return absl::InternalError( @@ -93,7 +93,7 @@ class InprocServerTransport final : public RefCounted, case ConnectionState::kReady: break; } - return acceptor_->CreateCall(md, acceptor_->CreateArena()); + return acceptor_->CreateCall(std::move(md), acceptor_->CreateArena()); } private: @@ -116,10 +116,10 @@ class InprocClientTransport final : public Transport, public ClientTransport { TrySeq(call_handler.PullClientInitialMetadata(), [server_transport = server_transport_, call_handler](ClientMetadataHandle md) { - auto call_initiator = server_transport->AcceptCall(*md); + auto call_initiator = + server_transport->AcceptCall(std::move(md)); if (!call_initiator.ok()) return call_initiator.status(); - ForwardCall(call_handler, std::move(*call_initiator), - std::move(md)); + ForwardCall(call_handler, std::move(*call_initiator)); return absl::OkStatus(); })); } diff --git a/src/core/lib/channel/channel_stack_builder_impl.cc b/src/core/lib/channel/channel_stack_builder_impl.cc index 6fd0b9f6484..62c527ffe61 100644 --- a/src/core/lib/channel/channel_stack_builder_impl.cc +++ b/src/core/lib/channel/channel_stack_builder_impl.cc @@ -95,43 +95,37 @@ const grpc_channel_filter* PromiseTracingFilterFor( }, /* init_call: */ [](grpc_channel_element* elem, CallSpineInterface* call) { + auto* c = DownCast(call); auto* source_filter = static_cast(elem->filter)->filter; - call->client_initial_metadata().receiver.InterceptAndMap( + c->client_initial_metadata().receiver.InterceptAndMap( [source_filter](ClientMetadataHandle md) { gpr_log(GPR_DEBUG, "%s[%s] OnClientInitialMetadata: %s", GetContext()->DebugTag().c_str(), source_filter->name, md->DebugString().c_str()); return md; }); - call->client_to_server_messages().receiver.InterceptAndMap( + c->client_to_server_messages().receiver.InterceptAndMap( [source_filter](MessageHandle msg) { gpr_log(GPR_DEBUG, "%s[%s] OnClientToServerMessage: %s", GetContext()->DebugTag().c_str(), source_filter->name, msg->DebugString().c_str()); return msg; }); - call->server_initial_metadata().sender.InterceptAndMap( + c->server_initial_metadata().sender.InterceptAndMap( [source_filter](ServerMetadataHandle md) { gpr_log(GPR_DEBUG, "%s[%s] OnServerInitialMetadata: %s", GetContext()->DebugTag().c_str(), source_filter->name, md->DebugString().c_str()); return md; }); - call->server_to_client_messages().sender.InterceptAndMap( + c->server_to_client_messages().sender.InterceptAndMap( [source_filter](MessageHandle msg) { gpr_log(GPR_DEBUG, "%s[%s] OnServerToClientMessage: %s", GetContext()->DebugTag().c_str(), source_filter->name, msg->DebugString().c_str()); return msg; }); - call->server_trailing_metadata().sender.InterceptAndMap( - [source_filter](ServerMetadataHandle md) { - gpr_log(GPR_DEBUG, "%s[%s] OnServerTrailingMetadata: %s", - GetContext()->DebugTag().c_str(), - source_filter->name, md->DebugString().c_str()); - return md; - }); }, grpc_channel_next_op, /* sizeof_call_data: */ 0, diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc index f54e64c1aa7..6cbf9df086e 100644 --- a/src/core/lib/channel/connected_channel.cc +++ b/src/core/lib/channel/connected_channel.cc @@ -463,8 +463,7 @@ ArenaPromise MakeClientCallPromise(Transport* transport, [](absl::Status) {}); // Start a promise to receive server initial metadata and then forward it up // through the receiving pipe. - auto server_initial_metadata = - GetContext()->MakePooled(); + auto server_initial_metadata = Arena::MakePooled(); party->Spawn( "recv_initial_metadata", TrySeq(GetContext()->ReceiveServerInitialMetadata( @@ -501,27 +500,25 @@ ArenaPromise MakeClientCallPromise(Transport* transport, // Create a promise that will receive server trailing metadata. // If this fails, we massage the error into metadata that we can report // upwards. - auto server_trailing_metadata = - GetContext()->MakePooled(); - auto recv_trailing_metadata = - Map(GetContext()->ReceiveServerTrailingMetadata( - stream->batch_target()), - [](absl::StatusOr status) mutable { - if (!status.ok()) { - auto server_trailing_metadata = - GetContext()->MakePooled(); - grpc_status_code status_code = GRPC_STATUS_UNKNOWN; - std::string message; - grpc_error_get_status(status.status(), Timestamp::InfFuture(), - &status_code, &message, nullptr, nullptr); - server_trailing_metadata->Set(GrpcStatusMetadata(), status_code); - server_trailing_metadata->Set(GrpcMessageMetadata(), - Slice::FromCopiedString(message)); - return server_trailing_metadata; - } else { - return std::move(*status); - } - }); + auto server_trailing_metadata = Arena::MakePooled(); + auto recv_trailing_metadata = Map( + GetContext()->ReceiveServerTrailingMetadata( + stream->batch_target()), + [](absl::StatusOr status) mutable { + if (!status.ok()) { + auto server_trailing_metadata = Arena::MakePooled(); + grpc_status_code status_code = GRPC_STATUS_UNKNOWN; + std::string message; + grpc_error_get_status(status.status(), Timestamp::InfFuture(), + &status_code, &message, nullptr, nullptr); + server_trailing_metadata->Set(GrpcStatusMetadata(), status_code); + server_trailing_metadata->Set(GrpcMessageMetadata(), + Slice::FromCopiedString(message)); + return server_trailing_metadata; + } else { + return std::move(*status); + } + }); // Finally the main call promise. // Concurrently: send initial metadata and receive messages, until BOTH // complete (or one fails). @@ -784,8 +781,7 @@ ArenaPromise MakeServerCallPromise( if (status.ok()) { trailing_metadata = std::move(*status); } else { - trailing_metadata = - GetContext()->MakePooled(); + trailing_metadata = Arena::MakePooled(); grpc_status_code status_code = GRPC_STATUS_UNKNOWN; std::string message; grpc_error_get_status(status.status(), Timestamp::InfFuture(), @@ -888,18 +884,7 @@ ArenaPromise MakeClientTransportCallPromise( Transport* transport, CallArgs call_args, NextPromiseFactory) { auto spine = GetContext()->MakeCallSpine(std::move(call_args)); transport->client_transport()->StartCall(CallHandler{spine}); - return Map(spine->server_trailing_metadata().receiver.Next(), - [](NextResult r) { - if (r.has_value()) { - auto md = std::move(r.value()); - md->Set(GrpcStatusFromWire(), true); - return md; - } - auto m = GetContext()->MakePooled(); - m->Set(GrpcStatusMetadata(), GRPC_STATUS_CANCELLED); - m->Set(GrpcCallWasCancelled(), true); - return m; - }); + return spine->PullServerTrailingMetadata(); } const grpc_channel_filter kClientPromiseBasedTransportFilter = diff --git a/src/core/lib/channel/promise_based_filter.cc b/src/core/lib/channel/promise_based_filter.cc index e5fe93ab058..746e171334b 100644 --- a/src/core/lib/channel/promise_based_filter.cc +++ b/src/core/lib/channel/promise_based_filter.cc @@ -508,7 +508,7 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher, case State::kGotBatch: if (allow_push_to_pipe) { state_ = State::kPushedToPipe; - auto message = GetContext()->MakePooled(); + auto message = Arena::MakePooled(); message->payload()->Swap(batch_->payload->send_message.send_message); message->mutable_flags() = batch_->payload->send_message.flags; push_ = interceptor()->Push()->Push(std::move(message)); @@ -839,7 +839,7 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher, } else { state_ = State::kCompletedWhilePushedToPipe; } - auto message = GetContext()->MakePooled(); + auto message = Arena::MakePooled(); message->payload()->Swap(&**intercepted_slice_buffer_); message->mutable_flags() = *intercepted_flags_; push_ = interceptor()->Push()->Push(std::move(message)); diff --git a/src/core/lib/channel/promise_based_filter.h b/src/core/lib/channel/promise_based_filter.h index 25229d16376..347f2004b8c 100644 --- a/src/core/lib/channel/promise_based_filter.h +++ b/src/core/lib/channel/promise_based_filter.h @@ -534,13 +534,14 @@ inline void InterceptClientToServerMessage(const NoInterceptor*, void*, void*, template inline void InterceptClientToServerMessage( ServerMetadataHandle (Derived::Call::*fn)(const Message&), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { + typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage); call_spine->client_to_server_messages().receiver.InterceptAndMap( [call, call_spine](MessageHandle msg) -> absl::optional { auto return_md = call->OnClientToServerMessage(*msg); if (return_md == nullptr) return std::move(msg); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } @@ -548,14 +549,15 @@ template inline void InterceptClientToServerMessage( ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage); call_spine->client_to_server_messages().receiver.InterceptAndMap( [call, call_spine, channel](MessageHandle msg) -> absl::optional { auto return_md = call->OnClientToServerMessage(*msg, channel); if (return_md == nullptr) return std::move(msg); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } @@ -563,7 +565,7 @@ template inline void InterceptClientToServerMessage( MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage); call_spine->client_to_server_messages().receiver.InterceptAndMap( [call, channel](MessageHandle msg) { @@ -575,24 +577,26 @@ template inline void InterceptClientToServerMessage( absl::StatusOr (Derived::Call::*fn)(MessageHandle, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage); call_spine->client_to_server_messages().receiver.InterceptAndMap( [call, call_spine, channel](MessageHandle msg) -> absl::optional { auto r = call->OnClientToServerMessage(std::move(msg), channel); if (r.ok()) return std::move(*r); - return call_spine->Cancel(ServerMetadataFromStatus(r.status())); + call_spine->PushServerTrailingMetadata( + ServerMetadataFromStatus(r.status())); + return absl::nullopt; }); } inline void InterceptClientInitialMetadata(const NoInterceptor*, void*, void*, - CallSpineInterface*) {} + PipeBasedCallSpine*) {} template inline void InterceptClientInitialMetadata( void (Derived::Call::*fn)(ClientMetadata& md), typename Derived::Call* call, - Derived*, CallSpineInterface* call_spine) { + Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call](ClientMetadataHandle md) { @@ -605,7 +609,7 @@ template inline void InterceptClientInitialMetadata( void (Derived::Call::*fn)(ClientMetadata& md, Derived* channel), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call, channel](ClientMetadataHandle md) { @@ -617,14 +621,15 @@ inline void InterceptClientInitialMetadata( template inline void InterceptClientInitialMetadata( ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { + typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call_spine, call](ClientMetadataHandle md) -> absl::optional { auto return_md = call->OnClientInitialMetadata(*md); if (return_md == nullptr) return std::move(md); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } @@ -633,28 +638,31 @@ inline void InterceptClientInitialMetadata( ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md, Derived* channel), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call_spine, call, channel]( ClientMetadataHandle md) -> absl::optional { auto return_md = call->OnClientInitialMetadata(*md, channel); if (return_md == nullptr) return std::move(md); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } template inline void InterceptClientInitialMetadata( absl::Status (Derived::Call::*fn)(ClientMetadata& md), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { + typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call_spine, call](ClientMetadataHandle md) -> absl::optional { auto status = call->OnClientInitialMetadata(*md); if (status.ok()) return std::move(md); - return call_spine->Cancel(ServerMetadataFromStatus(status)); + call_spine->PushServerTrailingMetadata( + ServerMetadataFromStatus(status)); + return absl::nullopt; }); } @@ -662,14 +670,16 @@ template inline void InterceptClientInitialMetadata( absl::Status (Derived::Call::*fn)(ClientMetadata& md, Derived* channel), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call_spine, call, channel]( ClientMetadataHandle md) -> absl::optional { auto status = call->OnClientInitialMetadata(*md, channel); if (status.ok()) return std::move(md); - return call_spine->Cancel(ServerMetadataFromStatus(status)); + call_spine->PushServerTrailingMetadata( + ServerMetadataFromStatus(status)); + return absl::nullopt; }); } @@ -681,7 +691,7 @@ absl::void_t( InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)( ClientMetadata& md, Derived* channel), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(promise_factory == &Derived::Call::OnClientInitialMetadata); call_spine->client_initial_metadata().receiver.InterceptAndMap( [call, call_spine, channel](ClientMetadataHandle md) { @@ -691,8 +701,9 @@ InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)( call_spine](PromiseResult status) mutable -> absl::optional { if (IsStatusOk(status)) return std::move(md); - return call_spine->Cancel( + call_spine->PushServerTrailingMetadata( StatusCast(std::move(status))); + return absl::nullopt; }); }); } @@ -766,7 +777,7 @@ inline void InterceptServerInitialMetadata(const NoInterceptor*, void*, void*, template inline void InterceptServerInitialMetadata( void (Derived::Call::*fn)(ServerMetadata&), typename Derived::Call* call, - Derived*, CallSpineInterface* call_spine) { + Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata); call_spine->server_initial_metadata().sender.InterceptAndMap( [call](ServerMetadataHandle md) { @@ -778,14 +789,16 @@ inline void InterceptServerInitialMetadata( template inline void InterceptServerInitialMetadata( absl::Status (Derived::Call::*fn)(ServerMetadata&), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { + typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata); call_spine->server_initial_metadata().sender.InterceptAndMap( [call, call_spine]( ServerMetadataHandle md) -> absl::optional { auto status = call->OnServerInitialMetadata(*md); if (status.ok()) return std::move(md); - return call_spine->Cancel(ServerMetadataFromStatus(status)); + call_spine->PushServerTrailingMetadata( + ServerMetadataFromStatus(status)); + return absl::nullopt; }); } @@ -793,7 +806,7 @@ template inline void InterceptServerInitialMetadata( void (Derived::Call::*fn)(ServerMetadata&, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata); call_spine->server_initial_metadata().sender.InterceptAndMap( [call, channel](ServerMetadataHandle md) { @@ -806,14 +819,16 @@ template inline void InterceptServerInitialMetadata( absl::Status (Derived::Call::*fn)(ServerMetadata&, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata); call_spine->server_initial_metadata().sender.InterceptAndMap( [call, call_spine, channel]( ServerMetadataHandle md) -> absl::optional { auto status = call->OnServerInitialMetadata(*md, channel); if (status.ok()) return std::move(md); - return call_spine->Cancel(ServerMetadataFromStatus(status)); + call_spine->PullServerTrailingMetadata( + ServerMetadataFromStatus(status)); + return absl::nullopt; }); } @@ -885,13 +900,14 @@ inline void InterceptServerToClientMessage(const NoInterceptor*, void*, void*, template inline void InterceptServerToClientMessage( ServerMetadataHandle (Derived::Call::*fn)(const Message&), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { + typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage); call_spine->server_to_client_messages().sender.InterceptAndMap( [call, call_spine](MessageHandle msg) -> absl::optional { auto return_md = call->OnServerToClientMessage(*msg); if (return_md == nullptr) return std::move(msg); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } @@ -899,14 +915,15 @@ template inline void InterceptServerToClientMessage( ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage); call_spine->server_to_client_messages().sender.InterceptAndMap( [call, call_spine, channel](MessageHandle msg) -> absl::optional { auto return_md = call->OnServerToClientMessage(*msg, channel); if (return_md == nullptr) return std::move(msg); - return call_spine->Cancel(std::move(return_md)); + call_spine->PushServerTrailingMetadata(std::move(return_md)); + return absl::nullopt; }); } @@ -914,7 +931,7 @@ template inline void InterceptServerToClientMessage( MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage); call_spine->server_to_client_messages().sender.InterceptAndMap( [call, channel](MessageHandle msg) { @@ -926,14 +943,16 @@ template inline void InterceptServerToClientMessage( absl::StatusOr (Derived::Call::*fn)(MessageHandle, Derived*), typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { + PipeBasedCallSpine* call_spine) { GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage); call_spine->server_to_client_messages().sender.InterceptAndMap( [call, call_spine, channel](MessageHandle msg) -> absl::optional { auto r = call->OnServerToClientMessage(std::move(msg), channel); if (r.ok()) return std::move(*r); - return call_spine->Cancel(ServerMetadataFromStatus(r.status())); + call_spine->PushServerTrailingMetadata( + ServerMetadataFromStatus(r.status())); + return absl::nullopt; }); } @@ -942,40 +961,25 @@ inline void InterceptServerTrailingMetadata(const NoInterceptor*, void*, void*, template inline void InterceptServerTrailingMetadata( - void (Derived::Call::*fn)(ServerMetadata&), typename Derived::Call* call, - Derived*, CallSpineInterface* call_spine) { - GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata); - call_spine->server_trailing_metadata().sender.InterceptAndMap( - [call](ServerMetadataHandle md) { - call->OnServerTrailingMetadata(*md); - return md; - }); + void (Derived::Call::*)(ServerMetadata&), typename Derived::Call*, Derived*, + PipeBasedCallSpine*) { + gpr_log(GPR_ERROR, + "InterceptServerTrailingMetadata not available for call v2.5"); } - template inline void InterceptServerTrailingMetadata( - void (Derived::Call::*fn)(ServerMetadata&, Derived*), - typename Derived::Call* call, Derived* channel, - CallSpineInterface* call_spine) { - GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata); - call_spine->server_trailing_metadata().sender.InterceptAndMap( - [call, channel](ServerMetadataHandle md) { - call->OnServerTrailingMetadata(*md, channel); - return md; - }); + void (Derived::Call::*)(ServerMetadata&, Derived*), typename Derived::Call*, + Derived*, PipeBasedCallSpine*) { + gpr_log(GPR_ERROR, + "InterceptServerTrailingMetadata not available for call v2.5"); } template inline void InterceptServerTrailingMetadata( - absl::Status (Derived::Call::*fn)(ServerMetadata&), - typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) { - GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata); - call_spine->server_trailing_metadata().sender.InterceptAndMap( - [call](ServerMetadataHandle md) -> absl::optional { - auto status = call->OnServerTrailingMetadata(*md); - if (status.ok()) return std::move(md); - return ServerMetadataFromStatus(status); - }); + absl::Status (Derived::Call::*)(ServerMetadata&), typename Derived::Call*, + Derived*, PipeBasedCallSpine*) { + gpr_log(GPR_ERROR, + "InterceptServerTrailingMetadata not available for call v2.5"); } inline void InterceptFinalize(const NoInterceptor*, void*, void*) {} @@ -1085,23 +1089,20 @@ class ImplementChannelFilter : public ChannelFilter, GetContext() ->ManagedNew>( static_cast(this)); + auto* c = DownCast(call_spine); + auto* d = static_cast(this); promise_filter_detail::InterceptClientInitialMetadata( - &Derived::Call::OnClientInitialMetadata, call, - static_cast(this), call_spine); + &Derived::Call::OnClientInitialMetadata, call, d, c); promise_filter_detail::InterceptClientToServerMessage( - &Derived::Call::OnClientToServerMessage, call, - static_cast(this), call_spine); + &Derived::Call::OnClientToServerMessage, call, d, c); promise_filter_detail::InterceptServerInitialMetadata( - &Derived::Call::OnServerInitialMetadata, call, - static_cast(this), call_spine); + &Derived::Call::OnServerInitialMetadata, call, d, c); promise_filter_detail::InterceptServerToClientMessage( - &Derived::Call::OnServerToClientMessage, call, - static_cast(this), call_spine); + &Derived::Call::OnServerToClientMessage, call, d, c); promise_filter_detail::InterceptServerTrailingMetadata( - &Derived::Call::OnServerTrailingMetadata, call, - static_cast(this), call_spine); - promise_filter_detail::InterceptFinalize(&Derived::Call::OnFinalize, - static_cast(this), call); + &Derived::Call::OnServerTrailingMetadata, call, d, c); + promise_filter_detail::InterceptFinalize(&Derived::Call::OnFinalize, d, + call); } // Polyfill for the original promise scheme. diff --git a/src/core/lib/channel/server_call_tracer_filter.cc b/src/core/lib/channel/server_call_tracer_filter.cc index dbf628d8b83..982f160468e 100644 --- a/src/core/lib/channel/server_call_tracer_filter.cc +++ b/src/core/lib/channel/server_call_tracer_filter.cc @@ -106,6 +106,7 @@ absl::StatusOr ServerCallTracerFilter::Create( } // namespace void RegisterServerCallTracerFilter(CoreConfiguration::Builder* builder) { + if (IsChaoticGoodEnabled()) return; builder->channel_init()->RegisterFilter( GRPC_SERVER_CHANNEL); } diff --git a/src/core/lib/promise/for_each.h b/src/core/lib/promise/for_each.h index 4f431a9c4a9..82322add349 100644 --- a/src/core/lib/promise/for_each.h +++ b/src/core/lib/promise/for_each.h @@ -56,13 +56,52 @@ struct Done { static StatusFlag Make(bool cancelled) { return StatusFlag(!cancelled); } }; +template +struct NextValueTraits; + +enum class NextValueType { + kValue, + kEndOfStream, + kError, +}; + +template +struct NextValueTraits> { + using Value = typename T::value_type; + + static NextValueType Type(const T& t) { + if (t.has_value()) return NextValueType::kValue; + if (t.cancelled()) return NextValueType::kError; + return NextValueType::kEndOfStream; + } + + static Value& MutableValue(T& t) { return *t; } +}; + +template +struct NextValueTraits>> { + using Value = T; + + static NextValueType Type(const ValueOrFailure>& t) { + if (t.ok()) { + if (t.value().has_value()) return NextValueType::kValue; + return NextValueType::kEndOfStream; + } + return NextValueType::kError; + } + + static Value& MutableValue(ValueOrFailure>& t) { + return **t; + } +}; + template class ForEach { private: using ReaderNext = decltype(std::declval().Next()); using ReaderResult = typename PollTraits()())>::Type; - using ReaderResultValue = typename ReaderResult::value_type; + using ReaderResultValue = typename NextValueTraits::Value; using ActionFactory = promise_detail::RepeatedPromiseFactory; using ActionPromise = typename ActionFactory::Promise; @@ -120,22 +159,37 @@ class ForEach { Poll PollReaderNext() { if (grpc_trace_promise_primitives.enabled()) { - gpr_log(GPR_DEBUG, "%s PollReaderNext", DebugTag().c_str()); + gpr_log(GPR_INFO, "%s PollReaderNext", DebugTag().c_str()); } auto r = reader_next_(); if (auto* p = r.value_if_ready()) { - if (grpc_trace_promise_primitives.enabled()) { - gpr_log(GPR_DEBUG, "%s PollReaderNext: got has_value=%s", - DebugTag().c_str(), p->has_value() ? "true" : "false"); - } - if (p->has_value()) { - Destruct(&reader_next_); - auto action = action_factory_.Make(std::move(**p)); - Construct(&in_action_, std::move(action), std::move(*p)); - reading_next_ = false; - return PollAction(); - } else { - return Done::Make(p->cancelled()); + switch (NextValueTraits::Type(*p)) { + case NextValueType::kValue: { + if (grpc_trace_promise_primitives.enabled()) { + gpr_log(GPR_INFO, "%s PollReaderNext: got value", + DebugTag().c_str()); + } + Destruct(&reader_next_); + auto action = action_factory_.Make( + std::move(NextValueTraits::MutableValue(*p))); + Construct(&in_action_, std::move(action), std::move(*p)); + reading_next_ = false; + return PollAction(); + } + case NextValueType::kEndOfStream: { + if (grpc_trace_promise_primitives.enabled()) { + gpr_log(GPR_INFO, "%s PollReaderNext: got end of stream", + DebugTag().c_str()); + } + return Done::Make(false); + } + case NextValueType::kError: { + if (grpc_trace_promise_primitives.enabled()) { + gpr_log(GPR_INFO, "%s PollReaderNext: got error", + DebugTag().c_str()); + } + return Done::Make(true); + } } } return Pending(); @@ -143,7 +197,7 @@ class ForEach { Poll PollAction() { if (grpc_trace_promise_primitives.enabled()) { - gpr_log(GPR_DEBUG, "%s PollAction", DebugTag().c_str()); + gpr_log(GPR_INFO, "%s PollAction", DebugTag().c_str()); } auto r = in_action_.promise(); if (auto* p = r.value_if_ready()) { diff --git a/src/core/lib/promise/pipe.h b/src/core/lib/promise/pipe.h index a1533bbcae5..f56567e6cf2 100644 --- a/src/core/lib/promise/pipe.h +++ b/src/core/lib/promise/pipe.h @@ -89,7 +89,7 @@ class NextResult final { const T& operator*() const; T& operator*(); // Only valid if !has_value() - bool cancelled() { return cancelled_; } + bool cancelled() const { return cancelled_; } private: RefCountedPtr> center_; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index a8e026b0ece..08a3aeb02a5 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -2739,7 +2739,7 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { ScopedContext context(this); args->channel->channel_stack()->stats_plugin_group->AddClientCallTracers( *args->path, args->registered_method, this->context()); - send_initial_metadata_ = GetContext()->MakePooled(); + send_initial_metadata_ = Arena::MakePooled(); send_initial_metadata_->Set(HttpPathMetadata(), std::move(*args->path)); if (args->authority.has_value()) { send_initial_metadata_->Set(HttpAuthorityMetadata(), @@ -2818,7 +2818,7 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { } RefCountedPtr MakeCallSpine(CallArgs call_args) final { - class WrappingCallSpine final : public CallSpineInterface { + class WrappingCallSpine final : public PipeBasedCallSpine { public: WrappingCallSpine(ClientPromiseBasedCall* call, ClientMetadataHandle metadata) @@ -2859,14 +2859,14 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { return call_->server_to_client_messages_; } - Pipe& server_trailing_metadata() override { - return server_trailing_metadata_; - } - Latch& cancel_latch() override { return cancel_error_; } + Latch& was_cancelled_latch() override { + return was_cancelled_latch_; + } + Party& party() override { return *call_; } Arena* arena() override { return call_->arena(); } @@ -2886,6 +2886,7 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { Pipe client_initial_metadata_{call_->arena()}; Pipe server_trailing_metadata_{call_->arena()}; Latch cancel_error_; + Latch was_cancelled_latch_; }; GPR_ASSERT(call_args.server_initial_metadata == &server_initial_metadata_.sender); @@ -3700,11 +3701,12 @@ ServerPromiseBasedCall::MakeTopOfServerCallPromise( /////////////////////////////////////////////////////////////////////////////// // CallSpine based Server Call -class ServerCallSpine final : public CallSpineInterface, +class ServerCallSpine final : public PipeBasedCallSpine, public ServerCallContext, public BasicPromiseBasedCall { public: - ServerCallSpine(ServerInterface* server, Channel* channel, Arena* arena); + ServerCallSpine(ClientMetadataHandle client_initial_metadata, + ServerInterface* server, Channel* channel, Arena* arena); // CallSpineInterface Pipe& client_initial_metadata() override { @@ -3719,10 +3721,8 @@ class ServerCallSpine final : public CallSpineInterface, Pipe& server_to_client_messages() override { return server_to_client_messages_; } - Pipe& server_trailing_metadata() override { - return server_trailing_metadata_; - } Latch& cancel_latch() override { return cancel_latch_; } + Latch& was_cancelled_latch() override { return was_cancelled_latch_; } Party& party() override { return *this; } Arena* arena() override { return BasicPromiseBasedCall::arena(); } void IncrementRefCount() override { InternalRef("CallSpine"); } @@ -3735,7 +3735,9 @@ class ServerCallSpine final : public CallSpineInterface, } void CancelWithError(grpc_error_handle error) override { SpawnInfallible("CancelWithError", [this, error = std::move(error)] { - std::ignore = Cancel(ServerMetadataFromStatus(error)); + auto status = ServerMetadataFromStatus(error); + status->Set(GrpcCallWasCancelled(), true); + PushServerTrailingMetadata(std::move(status)); return Empty{}; }); } @@ -3784,15 +3786,15 @@ class ServerCallSpine final : public CallSpineInterface, Pipe client_to_server_messages_; // Messages travelling from the transport to the application. Pipe server_to_client_messages_; - // Trailing metadata from server to client - Pipe server_trailing_metadata_; // Latch that can be set to terminate the call Latch cancel_latch_; + Latch was_cancelled_latch_; grpc_byte_buffer** recv_message_ = nullptr; ClientMetadataHandle client_initial_metadata_stored_; }; -ServerCallSpine::ServerCallSpine(ServerInterface* server, Channel* channel, +ServerCallSpine::ServerCallSpine(ClientMetadataHandle client_initial_metadata, + ServerInterface* server, Channel* channel, Arena* arena) : BasicPromiseBasedCall(arena, 0, 1, [channel, server]() -> grpc_call_create_args { @@ -3811,11 +3813,15 @@ ServerCallSpine::ServerCallSpine(ServerInterface* server, Channel* channel, client_initial_metadata_(arena), server_initial_metadata_(arena), client_to_server_messages_(arena), - server_to_client_messages_(arena), - server_trailing_metadata_(arena) { + server_to_client_messages_(arena) { global_stats().IncrementServerCallsCreated(); ScopedContext ctx(this); channel->channel_stack()->InitServerCallSpine(this); + SpawnGuarded("push_client_initial_metadata", + [this, md = std::move(client_initial_metadata)]() mutable { + return Map(client_initial_metadata_.sender.Push(std::move(md)), + [](bool r) { return StatusFlag(r); }); + }); } void ServerCallSpine::PublishInitialMetadata( @@ -4081,10 +4087,15 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, metadata->Set(GrpcMessageMetadata(), Slice(grpc_slice_copy(*details))); } + GPR_ASSERT(metadata != nullptr); return [this, metadata = std::move(metadata)]() mutable { - server_to_client_messages_.sender.Close(); - return Map(server_trailing_metadata_.sender.Push(std::move(metadata)), - [](bool r) { return StatusFlag(r); }); + GPR_ASSERT(metadata != nullptr); + return [this, + metadata = std::move(metadata)]() mutable -> Poll { + GPR_ASSERT(metadata != nullptr); + PushServerTrailingMetadata(std::move(metadata)); + return Success{}; + }; }; }); auto recv_message = @@ -4099,13 +4110,15 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, }; }); auto primary_ops = AllOk( - std::move(send_initial_metadata), std::move(send_message), - std::move(send_trailing_metadata), std::move(recv_message)); + TrySeq(AllOk(std::move(send_initial_metadata), + std::move(send_message)), + std::move(send_trailing_metadata)), + std::move(recv_message)); if (got_ops[GRPC_OP_RECV_CLOSE_ON_SERVER] != 255) { auto recv_trailing_metadata = MaybeOp( ops, got_ops[GRPC_OP_RECV_CLOSE_ON_SERVER], [this](const grpc_op& op) { return [this, cancelled = op.data.recv_close_on_server.cancelled]() { - return Map(server_trailing_metadata_.receiver.AwaitClosed(), + return Map(WasCancelled(), [cancelled, this](bool result) -> Success { ResetDeadline(); *cancelled = result ? 1 : 0; @@ -4141,14 +4154,15 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, } } -RefCountedPtr MakeServerCall(ServerInterface* server, - Channel* channel, - Arena* arena) { - return RefCountedPtr( - arena->New(server, channel, arena)); +RefCountedPtr MakeServerCall( + ClientMetadataHandle client_initial_metadata, ServerInterface* server, + Channel* channel, Arena* arena) { + return RefCountedPtr(arena->New( + std::move(client_initial_metadata), server, channel, arena)); } #else -RefCountedPtr MakeServerCall(ServerInterface*, Channel*, +RefCountedPtr MakeServerCall(ClientMetadataHandle, + ServerInterface*, Channel*, Arena*) { Crash("not implemented"); } diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 32aba4c3c60..ddc29ed878a 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -158,9 +158,10 @@ class CallContext { template <> struct ContextType {}; -RefCountedPtr MakeServerCall(ServerInterface* server, - Channel* channel, - Arena* arena); +// TODO(ctiller): remove once call-v3 finalized +RefCountedPtr MakeServerCall( + ClientMetadataHandle client_initial_metadata, ServerInterface* server, + Channel* channel, Arena* arena); } // namespace grpc_core diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 7b5fb2b95f9..5e974ec25a6 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -232,7 +232,8 @@ struct Server::RequestedCall { data.registered.optional_payload = optional_payload; } - void Complete(NextResult payload, ClientMetadata& md) { + template + void Complete(OptionalPayload payload, ClientMetadata& md) { Timestamp deadline = GetContext()->deadline(); switch (type) { case RequestedCall::Type::BATCH_CALL: @@ -1301,9 +1302,10 @@ Server::ChannelData::~ChannelData() { Arena* Server::ChannelData::CreateArena() { return channel_->CreateArena(); } absl::StatusOr Server::ChannelData::CreateCall( - ClientMetadata& client_initial_metadata, Arena* arena) { - SetRegisteredMethodOnMetadata(client_initial_metadata); - auto call = MakeServerCall(server_.get(), channel_.get(), arena); + ClientMetadataHandle client_initial_metadata, Arena* arena) { + SetRegisteredMethodOnMetadata(*client_initial_metadata); + auto call = MakeServerCall(std::move(client_initial_metadata), server_.get(), + channel_.get(), arena); InitCall(call); return CallInitiator(std::move(call)); } @@ -1427,10 +1429,10 @@ void Server::ChannelData::InitCall(RefCountedPtr call) { call->SpawnGuarded("request_matcher", [this, call]() { return TrySeq( // Wait for initial metadata to pass through all filters - Map(call->client_initial_metadata().receiver.Next(), - [](NextResult md) + Map(call->PullClientInitialMetadata(), + [](ValueOrFailure md) -> absl::StatusOr { - if (!md.has_value()) { + if (!md.ok()) { return absl::InternalError("Missing metadata"); } if (!md.value()->get_pointer(HttpPathMetadata())) { @@ -1456,24 +1458,19 @@ void Server::ChannelData::InitCall(RefCountedPtr call) { } auto maybe_read_first_message = If( payload_handling == GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, - [call]() { - return call->client_to_server_messages().receiver.Next(); - }, - []() -> NextResult { - return NextResult(); + [call]() { return call->PullClientToServerMessage(); }, + []() -> ValueOrFailure> { + return ValueOrFailure>( + absl::nullopt); }); return TryJoin( - Map(std::move(maybe_read_first_message), - [](NextResult n) { - return ValueOrFailure>{ - std::move(n)}; - }), - rm->MatchRequest(cq_idx()), [md = std::move(md)]() mutable { + std::move(maybe_read_first_message), rm->MatchRequest(cq_idx()), + [md = std::move(md)]() mutable { return ValueOrFailure(std::move(md)); }); }, // Publish call to cq - [](std::tuple, + [](std::tuple, RequestMatcherInterface::MatchResult, ClientMetadataHandle> r) { diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 6e80b96445f..356bcc40269 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -246,7 +246,7 @@ class Server : public ServerInterface, Arena* CreateArena() override; absl::StatusOr CreateCall( - ClientMetadata& client_initial_metadata, Arena* arena) override; + ClientMetadataHandle client_initial_metadata, Arena* arena) override; private: class ConnectivityWatcher; diff --git a/src/core/lib/transport/batch_builder.h b/src/core/lib/transport/batch_builder.h index ee032df12db..68a65ba25be 100644 --- a/src/core/lib/transport/batch_builder.h +++ b/src/core/lib/transport/batch_builder.h @@ -147,8 +147,7 @@ class BatchBuilder { absl::string_view name() const override { return "receive_message"; } MessageHandle IntoMessageHandle() { - return GetContext()->MakePooled(std::move(*payload), - flags); + return Arena::MakePooled(std::move(*payload), flags); } absl::optional payload; @@ -161,7 +160,7 @@ class BatchBuilder { using PendingCompletion::PendingCompletion; Arena::PoolPtr metadata = - GetContext()->MakePooled(); + Arena::MakePooled(); protected: ~PendingReceiveMetadata() = default; @@ -328,7 +327,7 @@ inline auto BatchBuilder::SendClientTrailingMetadata(Target target) { auto* pc = batch->GetInitializedCompletion(&Batch::pending_sends); batch->batch.on_complete = &pc->on_done_closure; batch->batch.send_trailing_metadata = true; - auto metadata = GetContext()->MakePooled(); + auto metadata = Arena::MakePooled(); payload_->send_trailing_metadata.send_trailing_metadata = metadata.get(); payload_->send_trailing_metadata.sent = nullptr; pc->send_trailing_metadata = std::move(metadata); diff --git a/src/core/lib/transport/call_spine.cc b/src/core/lib/transport/call_spine.cc index 0edcc3d335b..6b8ce59916e 100644 --- a/src/core/lib/transport/call_spine.cc +++ b/src/core/lib/transport/call_spine.cc @@ -18,16 +18,7 @@ namespace grpc_core { -void ForwardCall(CallHandler call_handler, CallInitiator call_initiator, - ClientMetadataHandle client_initial_metadata) { - // Send initial metadata. - call_initiator.SpawnGuarded( - "send_initial_metadata", - [client_initial_metadata = std::move(client_initial_metadata), - call_initiator]() mutable { - return call_initiator.PushClientInitialMetadata( - std::move(client_initial_metadata)); - }); +void ForwardCall(CallHandler call_handler, CallInitiator call_initiator) { // Read messages from handler into initiator. call_handler.SpawnGuarded("read_messages", [call_handler, call_initiator]() mutable { @@ -88,10 +79,10 @@ void ForwardCall(CallHandler call_handler, CallInitiator call_initiator, })), call_initiator.PullServerTrailingMetadata(), [call_handler](ServerMetadataHandle md) mutable { - call_handler.SpawnGuarded( - "recv_trailing_metadata", - [md = std::move(md), call_handler]() mutable { - return call_handler.PushServerTrailingMetadata(std::move(md)); + call_handler.SpawnInfallible( + "recv_trailing", [call_handler, md = std::move(md)]() mutable { + call_handler.PushServerTrailingMetadata(std::move(md)); + return Empty{}; }); return Empty{}; }); @@ -99,9 +90,12 @@ void ForwardCall(CallHandler call_handler, CallInitiator call_initiator, } CallInitiatorAndHandler MakeCall( - grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena) { - auto spine = CallSpine::Create(event_engine, arena); - return {CallInitiator(spine), CallHandler(spine)}; + ClientMetadataHandle client_initial_metadata, + grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena, + bool is_arena_owned) { + auto spine = CallSpine::Create(std::move(client_initial_metadata), + event_engine, arena, is_arena_owned); + return {CallInitiator(spine), UnstartedCallHandler(spine)}; } } // namespace grpc_core diff --git a/src/core/lib/transport/call_spine.h b/src/core/lib/transport/call_spine.h index 31381ef9f83..514c92c245d 100644 --- a/src/core/lib/transport/call_spine.h +++ b/src/core/lib/transport/call_spine.h @@ -25,6 +25,7 @@ #include "src/core/lib/promise/party.h" #include "src/core/lib/promise/pipe.h" #include "src/core/lib/promise/prioritized_race.h" +#include "src/core/lib/promise/promise.h" #include "src/core/lib/promise/status_flag.h" #include "src/core/lib/promise/try_seq.h" #include "src/core/lib/transport/message.h" @@ -42,12 +43,6 @@ namespace grpc_core { class CallSpineInterface { public: virtual ~CallSpineInterface() = default; - virtual Pipe& client_initial_metadata() = 0; - virtual Pipe& server_initial_metadata() = 0; - virtual Pipe& client_to_server_messages() = 0; - virtual Pipe& server_to_client_messages() = 0; - virtual Pipe& server_trailing_metadata() = 0; - virtual Latch& cancel_latch() = 0; // Add a callback to be called when server trailing metadata is received. void OnDone(absl::AnyInvocable fn) { if (on_done_ == nullptr) { @@ -67,33 +62,24 @@ class CallSpineInterface { virtual void IncrementRefCount() = 0; virtual void Unref() = 0; - // Cancel the call with the given metadata. - // Regarding the `MUST_USE_RESULT absl::nullopt_t`: - // Most cancellation calls right now happen in pipe interceptors; - // there `nullopt` indicates terminate processing of this pipe and close with - // error. - // It's convenient then to have the Cancel operation (setting the latch to - // terminate the call) be the last thing that occurs in a pipe interceptor, - // and this construction supports that (and has helped the author not write - // some bugs). - GRPC_MUST_USE_RESULT absl::nullopt_t Cancel(ServerMetadataHandle metadata) { - GPR_DEBUG_ASSERT(GetContext() == &party()); - auto& c = cancel_latch(); - if (c.is_set()) return absl::nullopt; - c.Set(std::move(metadata)); - CallOnDone(); - client_initial_metadata().sender.CloseWithError(); - server_initial_metadata().sender.CloseWithError(); - client_to_server_messages().sender.CloseWithError(); - server_to_client_messages().sender.CloseWithError(); - server_trailing_metadata().sender.CloseWithError(); - return absl::nullopt; - } - - auto WaitForCancel() { - GPR_DEBUG_ASSERT(GetContext() == &party()); - return cancel_latch().Wait(); - } + virtual Promise>> + PullServerInitialMetadata() = 0; + virtual Promise PullServerTrailingMetadata() = 0; + virtual Promise PushClientToServerMessage( + MessageHandle message) = 0; + virtual Promise>> + PullClientToServerMessage() = 0; + virtual Promise PushServerToClientMessage( + MessageHandle message) = 0; + virtual Promise>> + PullServerToClientMessage() = 0; + virtual void PushServerTrailingMetadata(ServerMetadataHandle md) = 0; + virtual void FinishSends() = 0; + virtual Promise> + PullClientInitialMetadata() = 0; + virtual Promise PushServerInitialMetadata( + absl::optional md) = 0; + virtual Promise WasCancelled() = 0; // Wrap a promise so that if it returns failure it automatically cancels // the rest of the call. @@ -105,7 +91,7 @@ class CallSpineInterface { using ResultType = typename P::Result; return Map(std::move(promise), [this](ResultType r) { if (!IsStatusOk(r)) { - std::ignore = Cancel(StatusCast(r)); + PushServerTrailingMetadata(StatusCast(r)); } return r; }); @@ -121,7 +107,8 @@ class CallSpineInterface { // Spawn a promise that returns some status-like type; if the status // represents failure automatically cancel the rest of the call. template - void SpawnGuarded(absl::string_view name, PromiseFactory promise_factory) { + void SpawnGuarded(absl::string_view name, PromiseFactory promise_factory, + DebugLocation whence = {}) { using FactoryType = promise_detail::OncePromiseFactory; using PromiseType = typename FactoryType::Promise; @@ -130,27 +117,158 @@ class CallSpineInterface { std::is_same()))>::value, "SpawnGuarded promise must return a status-like object"); - party().Spawn(name, std::move(promise_factory), [this](ResultType r) { - if (!IsStatusOk(r)) { - if (grpc_trace_promise_primitives.enabled()) { - gpr_log(GPR_DEBUG, "SpawnGuarded sees failure: %s", - r.ToString().c_str()); - } - std::ignore = Cancel(StatusCast(std::move(r))); - } - }); + party().Spawn( + name, std::move(promise_factory), [this, whence](ResultType r) { + if (!IsStatusOk(r)) { + if (grpc_trace_promise_primitives.enabled()) { + gpr_log(GPR_INFO, "SpawnGuarded sees failure: %s (source: %s:%d)", + r.ToString().c_str(), whence.file(), whence.line()); + } + auto status = StatusCast(std::move(r)); + status->Set(GrpcCallWasCancelled(), true); + PushServerTrailingMetadata(std::move(status)); + } + }); } private: absl::AnyInvocable on_done_{nullptr}; }; -class CallSpine final : public CallSpineInterface, public Party { +// Implementation of CallSpine atop the v2 Pipe based arrangement. +// This implementation will go away in favor of an implementation atop +// CallFilters by the time v3 lands. +class PipeBasedCallSpine : public CallSpineInterface { + public: + virtual Pipe& client_initial_metadata() = 0; + virtual Pipe& server_initial_metadata() = 0; + virtual Pipe& client_to_server_messages() = 0; + virtual Pipe& server_to_client_messages() = 0; + virtual Latch& cancel_latch() = 0; + virtual Latch& was_cancelled_latch() = 0; + + Promise>> + PullServerInitialMetadata() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(server_initial_metadata().receiver.Next(), + [](NextResult md) + -> ValueOrFailure> { + if (!md.has_value()) { + if (md.cancelled()) return Failure{}; + return absl::optional(); + } + return absl::optional(std::move(*md)); + }); + } + + Promise PullServerTrailingMetadata() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return cancel_latch().Wait(); + } + + Promise>> + PullServerToClientMessage() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(server_to_client_messages().receiver.Next(), MapNextMessage); + } + + Promise PushClientToServerMessage(MessageHandle message) final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(client_to_server_messages().sender.Push(std::move(message)), + [](bool r) { return StatusFlag(r); }); + } + + Promise>> + PullClientToServerMessage() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(client_to_server_messages().receiver.Next(), MapNextMessage); + } + + Promise PushServerToClientMessage(MessageHandle message) final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(server_to_client_messages().sender.Push(std::move(message)), + [](bool r) { return StatusFlag(r); }); + } + + void FinishSends() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + client_to_server_messages().sender.Close(); + } + + void PushServerTrailingMetadata(ServerMetadataHandle metadata) final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + auto& c = cancel_latch(); + if (c.is_set()) return; + const bool was_cancelled = + metadata->get(GrpcCallWasCancelled()).value_or(false); + c.Set(std::move(metadata)); + CallOnDone(); + was_cancelled_latch().Set(was_cancelled); + client_initial_metadata().sender.CloseWithError(); + server_initial_metadata().sender.Close(); + client_to_server_messages().sender.CloseWithError(); + server_to_client_messages().sender.Close(); + } + + Promise WasCancelled() final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return was_cancelled_latch().Wait(); + } + + Promise> PullClientInitialMetadata() + final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return Map(client_initial_metadata().receiver.Next(), + [](NextResult md) + -> ValueOrFailure { + if (!md.has_value()) return Failure{}; + return std::move(*md); + }); + } + + Promise PushServerInitialMetadata( + absl::optional md) final { + GPR_DEBUG_ASSERT(GetContext() == &party()); + return If( + md.has_value(), + [&md, this]() { + return Map(server_initial_metadata().sender.Push(std::move(*md)), + [](bool ok) { return StatusFlag(ok); }); + }, + [this]() { + server_initial_metadata().sender.Close(); + return []() -> StatusFlag { return Success{}; }; + }); + } + + private: + static ValueOrFailure> MapNextMessage( + NextResult r) { + if (!r.has_value()) { + if (r.cancelled()) return Failure{}; + return absl::optional(); + } + return absl::optional(std::move(*r)); + } +}; + +class CallSpine final : public PipeBasedCallSpine, public Party { public: static RefCountedPtr Create( - grpc_event_engine::experimental::EventEngine* event_engine, - Arena* arena) { - return RefCountedPtr(arena->New(event_engine, arena)); + ClientMetadataHandle client_initial_metadata, + grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena, + bool is_arena_owned) { + auto spine = RefCountedPtr( + arena->New(event_engine, arena, is_arena_owned)); + spine->SpawnInfallible( + "push_client_initial_metadata", + [spine = spine.get(), client_initial_metadata = std::move( + client_initial_metadata)]() mutable { + return Map(spine->client_initial_metadata_.sender.Push( + std::move(client_initial_metadata)), + [](bool) { return Empty{}; }); + }); + return spine; } Pipe& client_initial_metadata() override { @@ -165,10 +283,8 @@ class CallSpine final : public CallSpineInterface, public Party { Pipe& server_to_client_messages() override { return server_to_client_messages_; } - Pipe& server_trailing_metadata() override { - return server_trailing_metadata_; - } Latch& cancel_latch() override { return cancel_latch_; } + Latch& was_cancelled_latch() override { return was_cancelled_latch_; } Party& party() override { return *this; } Arena* arena() override { return arena_; } void IncrementRefCount() override { Party::IncrementRefCount(); } @@ -177,8 +293,11 @@ class CallSpine final : public CallSpineInterface, public Party { private: friend class Arena; CallSpine(grpc_event_engine::experimental::EventEngine* event_engine, - Arena* arena) - : Party(1), arena_(arena), event_engine_(event_engine) {} + Arena* arena, bool is_arena_owned) + : Party(1), + arena_(arena), + is_arena_owned_(is_arena_owned), + event_engine_(event_engine) {} class ScopedContext : public ScopedActivity, public promise_detail::Context { @@ -208,6 +327,7 @@ class CallSpine final : public CallSpineInterface, public Party { } Arena* arena_; + bool is_arena_owned_; // Initial metadata from client to server Pipe client_initial_metadata_{arena()}; // Initial metadata from server to client @@ -216,10 +336,9 @@ class CallSpine final : public CallSpineInterface, public Party { Pipe client_to_server_messages_{arena()}; // Messages travelling from the transport to the application. Pipe server_to_client_messages_{arena()}; - // Trailing metadata from server to client - Pipe server_trailing_metadata_{arena()}; // Latch that can be set to terminate the call Latch cancel_latch_; + Latch was_cancelled_latch_; // Event engine associated with this call grpc_event_engine::experimental::EventEngine* const event_engine_; }; @@ -229,73 +348,31 @@ class CallInitiator { explicit CallInitiator(RefCountedPtr spine) : spine_(std::move(spine)) {} - auto PushClientInitialMetadata(ClientMetadataHandle md) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return Map(spine_->client_initial_metadata().sender.Push(std::move(md)), - [](bool ok) { return StatusFlag(ok); }); + template + auto CancelIfFails(Promise promise) { + return spine_->CancelIfFails(std::move(promise)); } auto PullServerInitialMetadata() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return Map(spine_->server_initial_metadata().receiver.Next(), - [](NextResult md) - -> ValueOrFailure> { - if (!md.has_value()) { - if (md.cancelled()) return Failure{}; - return absl::optional(); - } - return absl::optional(std::move(*md)); - }); - } - - auto PullServerTrailingMetadata() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return PrioritizedRace( - Seq(spine_->server_trailing_metadata().receiver.Next(), - [spine = spine_](NextResult md) mutable { - return [md = std::move(md), - spine]() mutable -> Poll { - // If the pipe was closed at cancellation time, we'll see no - // value here. Return pending and allow the cancellation to win - // the race. - if (!md.has_value()) return Pending{}; - spine->server_trailing_metadata().sender.Close(); - return std::move(*md); - }; - }), - Map(spine_->WaitForCancel(), - [spine = spine_](ServerMetadataHandle md) -> ServerMetadataHandle { - spine->server_trailing_metadata().sender.CloseWithError(); - return md; - })); - } - - auto PullMessage() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return spine_->server_to_client_messages().receiver.Next(); + return spine_->PullServerInitialMetadata(); } auto PushMessage(MessageHandle message) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return Map( - spine_->client_to_server_messages().sender.Push(std::move(message)), - [](bool r) { return StatusFlag(r); }); + return spine_->PushClientToServerMessage(std::move(message)); } - void FinishSends() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - spine_->client_to_server_messages().sender.Close(); - } + void FinishSends() { spine_->FinishSends(); } - template - auto CancelIfFails(Promise promise) { - return spine_->CancelIfFails(std::move(promise)); + auto PullMessage() { return spine_->PullServerToClientMessage(); } + + auto PullServerTrailingMetadata() { + return spine_->PullServerTrailingMetadata(); } void Cancel() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - std::ignore = - spine_->Cancel(ServerMetadataFromStatus(absl::CancelledError())); + auto status = ServerMetadataFromStatus(absl::CancelledError()); + status->Set(GrpcCallWasCancelled(), true); + spine_->PushServerTrailingMetadata(std::move(status)); } void OnDone(absl::AnyInvocable fn) { spine_->OnDone(std::move(fn)); } @@ -327,55 +404,59 @@ class CallHandler { : spine_(std::move(spine)) {} auto PullClientInitialMetadata() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return Map(spine_->client_initial_metadata().receiver.Next(), - [](NextResult md) - -> ValueOrFailure { - if (!md.has_value()) return Failure{}; - return std::move(*md); - }); + return spine_->PullClientInitialMetadata(); } auto PushServerInitialMetadata(absl::optional md) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return If( - md.has_value(), - [&md, this]() { - return Map( - spine_->server_initial_metadata().sender.Push(std::move(*md)), - [](bool ok) { return StatusFlag(ok); }); - }, - [this]() { - spine_->server_initial_metadata().sender.Close(); - return []() -> StatusFlag { return Success{}; }; - }); + return spine_->PushServerInitialMetadata(std::move(md)); } - auto PushServerTrailingMetadata(ServerMetadataHandle md) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - spine_->server_initial_metadata().sender.Close(); - spine_->server_to_client_messages().sender.Close(); - spine_->client_to_server_messages().receiver.CloseWithError(); - spine_->CallOnDone(); - return Map(spine_->server_trailing_metadata().sender.Push(std::move(md)), - [](bool ok) { return StatusFlag(ok); }); + void PushServerTrailingMetadata(ServerMetadataHandle status) { + spine_->PushServerTrailingMetadata(std::move(status)); } - auto PullMessage() { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return spine_->client_to_server_messages().receiver.Next(); + void OnDone(absl::AnyInvocable fn) { spine_->OnDone(std::move(fn)); } + + template + auto CancelIfFails(Promise promise) { + return spine_->CancelIfFails(std::move(promise)); } auto PushMessage(MessageHandle message) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - return Map( - spine_->server_to_client_messages().sender.Push(std::move(message)), - [](bool ok) { return StatusFlag(ok); }); + return spine_->PushServerToClientMessage(std::move(message)); + } + + auto PullMessage() { return spine_->PullClientToServerMessage(); } + + template + void SpawnGuarded(absl::string_view name, PromiseFactory promise_factory, + DebugLocation whence = {}) { + spine_->SpawnGuarded(name, std::move(promise_factory), whence); } - void Cancel(ServerMetadataHandle status) { - GPR_DEBUG_ASSERT(GetContext() == &spine_->party()); - std::ignore = spine_->Cancel(std::move(status)); + template + void SpawnInfallible(absl::string_view name, PromiseFactory promise_factory) { + spine_->SpawnInfallible(name, std::move(promise_factory)); + } + + template + auto SpawnWaitable(absl::string_view name, PromiseFactory promise_factory) { + return spine_->party().SpawnWaitable(name, std::move(promise_factory)); + } + + Arena* arena() { return spine_->arena(); } + + private: + RefCountedPtr spine_; +}; + +class UnstartedCallHandler { + public: + explicit UnstartedCallHandler(RefCountedPtr spine) + : spine_(std::move(spine)) {} + + void PushServerTrailingMetadata(ServerMetadataHandle status) { + spine_->PushServerTrailingMetadata(std::move(status)); } void OnDone(absl::AnyInvocable fn) { spine_->OnDone(std::move(fn)); } @@ -386,8 +467,9 @@ class CallHandler { } template - void SpawnGuarded(absl::string_view name, PromiseFactory promise_factory) { - spine_->SpawnGuarded(name, std::move(promise_factory)); + void SpawnGuarded(absl::string_view name, PromiseFactory promise_factory, + DebugLocation whence = {}) { + spine_->SpawnGuarded(name, std::move(promise_factory), whence); } template @@ -400,6 +482,11 @@ class CallHandler { return spine_->party().SpawnWaitable(name, std::move(promise_factory)); } + CallHandler V2HackToStartCallWithoutACallFilterStack() { + GPR_ASSERT(DownCast(spine_.get()) != nullptr); + return CallHandler(std::move(spine_)); + } + Arena* arena() { return spine_->arena(); } private: @@ -408,11 +495,13 @@ class CallHandler { struct CallInitiatorAndHandler { CallInitiator initiator; - CallHandler handler; + UnstartedCallHandler handler; }; CallInitiatorAndHandler MakeCall( - grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena); + ClientMetadataHandle client_initial_metadata, + grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena, + bool is_arena_owned); template auto OutgoingMessages(CallHalf h) { @@ -425,8 +514,7 @@ auto OutgoingMessages(CallHalf h) { // Forward a call from `call_handler` to `call_initiator` (with initial metadata // `client_initial_metadata`) -void ForwardCall(CallHandler call_handler, CallInitiator call_initiator, - ClientMetadataHandle client_initial_metadata); +void ForwardCall(CallHandler call_handler, CallInitiator call_initiator); } // namespace grpc_core diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 9a89def3a8e..c824f0ae05c 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -559,7 +559,7 @@ class ServerTransport { // Create a call at the server (or fail) // arena must have been previously allocated by CreateArena() virtual absl::StatusOr CreateCall( - ClientMetadata& client_initial_metadata, Arena* arena) = 0; + ClientMetadataHandle client_initial_metadata, Arena* arena) = 0; protected: ~Acceptor() = default; diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc index ba73b4c581f..dc7fdafc667 100644 --- a/test/core/end2end/tests/filter_causes_close.cc +++ b/test/core/end2end/tests/filter_causes_close.cc @@ -102,13 +102,8 @@ const grpc_channel_filter test_filter = { return Immediate(ServerMetadataFromStatus( absl::PermissionDeniedError("Failure that's not preventable."))); }, - [](grpc_channel_element*, CallSpineInterface* args) { - args->client_initial_metadata().receiver.InterceptAndMap( - [args](ClientMetadataHandle) { - return args->Cancel( - ServerMetadataFromStatus(absl::PermissionDeniedError( - "Failure that's not preventable."))); - }); + [](grpc_channel_element*, CallSpineInterface*) { + Crash("Should never be called"); }, grpc_channel_next_op, sizeof(call_data), diff --git a/test/core/transport/chaotic_good/client_transport_error_test.cc b/test/core/transport/chaotic_good/client_transport_error_test.cc index 453e99a3663..bd1e1b77f7a 100644 --- a/test/core/transport/chaotic_good/client_transport_error_test.cc +++ b/test/core/transport/chaotic_good/client_transport_error_test.cc @@ -105,22 +105,21 @@ struct MockPromiseEndpoint { auto SendClientToServerMessages(CallInitiator initiator, int num_messages) { return Loop([initiator, num_messages]() mutable { bool has_message = (num_messages > 0); - return If( - has_message, - Seq(initiator.PushMessage(GetContext()->MakePooled()), - [&num_messages]() -> LoopCtl { - --num_messages; - return Continue(); - }), - [initiator]() mutable -> LoopCtl { - initiator.FinishSends(); - return absl::OkStatus(); - }); + return If(has_message, + Seq(initiator.PushMessage(Arena::MakePooled()), + [&num_messages]() -> LoopCtl { + --num_messages; + return Continue(); + }), + [initiator]() mutable -> LoopCtl { + initiator.FinishSends(); + return absl::OkStatus(); + }); }); } ClientMetadataHandle TestInitialMetadata() { - auto md = GetContext()->MakePooled(); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/test")); return md; } @@ -178,14 +177,13 @@ TEST_F(ClientTransportTest, AddOneStreamWithWriteFailed) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call.handler)); - call.initiator.SpawnGuarded("test-send", [initiator = - call.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); + auto call = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall(call.handler.V2HackToStartCallWithoutACallFilterStack()); + call.initiator.SpawnGuarded("test-send", + [initiator = call.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); StrictMock> on_done; EXPECT_CALL(on_done, Call()); call.initiator.SpawnInfallible( @@ -193,7 +191,7 @@ TEST_F(ClientTransportTest, AddOneStreamWithWriteFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), @@ -224,14 +222,13 @@ TEST_F(ClientTransportTest, AddOneStreamWithReadFailed) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call.handler)); - call.initiator.SpawnGuarded("test-send", [initiator = - call.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); + auto call = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall(call.handler.V2HackToStartCallWithoutACallFilterStack()); + call.initiator.SpawnGuarded("test-send", + [initiator = call.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); StrictMock> on_done; EXPECT_CALL(on_done, Call()); call.initiator.SpawnInfallible( @@ -239,7 +236,7 @@ TEST_F(ClientTransportTest, AddOneStreamWithReadFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), @@ -278,22 +275,22 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithWriteFailed) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call1 = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call1.handler)); - auto call2 = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call2.handler)); - call1.initiator.SpawnGuarded("test-send-1", [initiator = - call1.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); - call2.initiator.SpawnGuarded("test-send-2", [initiator = - call2.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); + auto call1 = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall( + call1.handler.V2HackToStartCallWithoutACallFilterStack()); + auto call2 = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall( + call2.handler.V2HackToStartCallWithoutACallFilterStack()); + call1.initiator.SpawnGuarded( + "test-send-1", [initiator = call1.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); + call2.initiator.SpawnGuarded( + "test-send-2", [initiator = call2.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); StrictMock> on_done1; EXPECT_CALL(on_done1, Call()); StrictMock> on_done2; @@ -303,7 +300,7 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithWriteFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), @@ -319,7 +316,7 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithWriteFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), @@ -350,22 +347,22 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithReadFailed) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call1 = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call1.handler)); - auto call2 = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call2.handler)); - call1.initiator.SpawnGuarded("test-send", [initiator = - call1.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); - call2.initiator.SpawnGuarded("test-send", [initiator = - call2.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); + auto call1 = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall( + call1.handler.V2HackToStartCallWithoutACallFilterStack()); + auto call2 = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall( + call2.handler.V2HackToStartCallWithoutACallFilterStack()); + call1.initiator.SpawnGuarded( + "test-send", [initiator = call1.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); + call2.initiator.SpawnGuarded( + "test-send", [initiator = call2.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); StrictMock> on_done1; EXPECT_CALL(on_done1, Call()); StrictMock> on_done2; @@ -375,7 +372,7 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithReadFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), @@ -391,7 +388,7 @@ TEST_F(ClientTransportTest, AddMultipleStreamWithReadFailed) { return Seq( initiator.PullServerInitialMetadata(), [](ValueOrFailure> md) { - EXPECT_FALSE(md.ok()); + EXPECT_TRUE(md.ok()); return Empty{}; }, initiator.PullServerTrailingMetadata(), diff --git a/test/core/transport/chaotic_good/client_transport_test.cc b/test/core/transport/chaotic_good/client_transport_test.cc index 387e483fc21..3acd0c0c273 100644 --- a/test/core/transport/chaotic_good/client_transport_test.cc +++ b/test/core/transport/chaotic_good/client_transport_test.cc @@ -67,7 +67,7 @@ const uint8_t kGrpcStatus0[] = {0x10, 0x0b, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x01, 0x30}; ClientMetadataHandle TestInitialMetadata() { - auto md = GetContext()->MakePooled(); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/demo.Service/Step")); return md; } @@ -78,7 +78,7 @@ auto SendClientToServerMessages(CallInitiator initiator, int num_messages) { bool has_message = (i < num_messages); return If( has_message, - Seq(initiator.PushMessage(GetContext()->MakePooled( + Seq(initiator.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString(std::to_string(i))), 0)), [&i]() -> LoopCtl { ++i; @@ -115,9 +115,9 @@ TEST_F(TransportTest, AddOneStream) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call = - MakeCall(event_engine().get(), Arena::Create(1024, memory_allocator())); - transport->StartCall(std::move(call.handler)); + auto call = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(1024, memory_allocator()), true); + transport->StartCall(call.handler.V2HackToStartCallWithoutACallFilterStack()); StrictMock> on_done; EXPECT_CALL(on_done, Call()); control_endpoint.ExpectWrite( @@ -133,11 +133,10 @@ TEST_F(TransportTest, AddOneStream) { {EventEngineSlice::FromCopiedString("0"), Zeros(63)}, nullptr); control_endpoint.ExpectWrite( {SerializedFrameHeader(FrameType::kFragment, 4, 1, 0, 0, 0, 0)}, nullptr); - call.initiator.SpawnGuarded("test-send", [initiator = - call.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 1)); - }); + call.initiator.SpawnGuarded("test-send", + [initiator = call.initiator]() mutable { + return SendClientToServerMessages(initiator, 1); + }); call.initiator.SpawnInfallible( "test-read", [&on_done, initiator = call.initiator]() mutable { return Seq( @@ -152,18 +151,23 @@ TEST_F(TransportTest, AddOneStream) { "/demo.Service/Step"); return Empty{}; }, - initiator.PullMessage(), - [](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "12345678"); + [initiator]() mutable { return initiator.PullMessage(); }, + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "12345678"); return Empty{}; }, - initiator.PullMessage(), - [](NextResult msg) { - EXPECT_FALSE(msg.has_value()); + [initiator]() mutable { return initiator.PullMessage(); }, + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return Empty{}; }, - initiator.PullServerTrailingMetadata(), + [initiator]() mutable { + return initiator.PullServerTrailingMetadata(); + }, [&on_done](ServerMetadataHandle md) { EXPECT_EQ(md->get(GrpcStatusMetadata()).value(), GRPC_STATUS_OK); on_done.Call(); @@ -198,9 +202,9 @@ TEST_F(TransportTest, AddOneStreamMultipleMessages) { std::move(control_endpoint.promise_endpoint), std::move(data_endpoint.promise_endpoint), MakeChannelArgs(), event_engine(), HPackParser(), HPackCompressor()); - auto call = - MakeCall(event_engine().get(), Arena::Create(8192, memory_allocator())); - transport->StartCall(std::move(call.handler)); + auto call = MakeCall(TestInitialMetadata(), event_engine().get(), + Arena::Create(8192, memory_allocator()), true); + transport->StartCall(call.handler.V2HackToStartCallWithoutACallFilterStack()); StrictMock> on_done; EXPECT_CALL(on_done, Call()); control_endpoint.ExpectWrite( @@ -221,11 +225,10 @@ TEST_F(TransportTest, AddOneStreamMultipleMessages) { {EventEngineSlice::FromCopiedString("1"), Zeros(63)}, nullptr); control_endpoint.ExpectWrite( {SerializedFrameHeader(FrameType::kFragment, 4, 1, 0, 0, 0, 0)}, nullptr); - call.initiator.SpawnGuarded("test-send", [initiator = - call.initiator]() mutable { - return TrySeq(initiator.PushClientInitialMetadata(TestInitialMetadata()), - SendClientToServerMessages(initiator, 2)); - }); + call.initiator.SpawnGuarded("test-send", + [initiator = call.initiator]() mutable { + return SendClientToServerMessages(initiator, 2); + }); call.initiator.SpawnInfallible( "test-read", [&on_done, initiator = call.initiator]() mutable { return Seq( @@ -241,20 +244,25 @@ TEST_F(TransportTest, AddOneStreamMultipleMessages) { return Empty{}; }, initiator.PullMessage(), - [](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "12345678"); + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "12345678"); return Empty{}; }, initiator.PullMessage(), - [](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "87654321"); + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "87654321"); return Empty{}; }, initiator.PullMessage(), - [](NextResult msg) { - EXPECT_FALSE(msg.has_value()); + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return Empty{}; }, initiator.PullServerTrailingMetadata(), diff --git a/test/core/transport/chaotic_good/server_transport_test.cc b/test/core/transport/chaotic_good/server_transport_test.cc index 7c21a07c72d..a4e0272b87c 100644 --- a/test/core/transport/chaotic_good/server_transport_test.cc +++ b/test/core/transport/chaotic_good/server_transport_test.cc @@ -71,13 +71,13 @@ const uint8_t kGrpcStatus0[] = {0x40, 0x0b, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x01, 0x30}; ServerMetadataHandle TestInitialMetadata() { - auto md = GetContext()->MakePooled(); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/demo.Service/Step")); return md; } ServerMetadataHandle TestTrailingMetadata() { - auto md = GetContext()->MakePooled(); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_OK); return md; } @@ -87,7 +87,7 @@ class MockAcceptor : public ServerTransport::Acceptor { virtual ~MockAcceptor() = default; MOCK_METHOD(Arena*, CreateArena, (), (override)); MOCK_METHOD(absl::StatusOr, CreateCall, - (ClientMetadata & client_initial_metadata, Arena* arena), + (ClientMetadataHandle client_initial_metadata, Arena* arena), (override)); }; @@ -113,18 +113,59 @@ TEST_F(TransportTest, ReadAndWriteOneMessage) { {EventEngineSlice::FromCopiedString("12345678"), Zeros(56)}, nullptr); // Once that's read we'll create a new call auto* call_arena = Arena::Create(1024, memory_allocator()); - CallInitiatorAndHandler call = MakeCall(event_engine().get(), call_arena); EXPECT_CALL(acceptor, CreateArena).WillOnce(Return(call_arena)); + StrictMock> on_done; EXPECT_CALL(acceptor, CreateCall(_, call_arena)) - .WillOnce(WithArgs<0>([call_initiator = std::move(call.initiator)]( - ClientMetadata& client_initial_metadata) { - EXPECT_EQ(client_initial_metadata.get_pointer(HttpPathMetadata()) + .WillOnce(WithArgs<0>([this, call_arena, &on_done]( + ClientMetadataHandle client_initial_metadata) { + EXPECT_EQ(client_initial_metadata->get_pointer(HttpPathMetadata()) ->as_string_view(), "/demo.Service/Step"); - return call_initiator; + CallInitiatorAndHandler call = + MakeCall(std::move(client_initial_metadata), event_engine().get(), + call_arena, true); + auto handler = call.handler.V2HackToStartCallWithoutACallFilterStack(); + handler.SpawnInfallible("test-io", [&on_done, handler]() mutable { + return Seq( + handler.PullClientInitialMetadata(), + [](ValueOrFailure md) { + EXPECT_TRUE(md.ok()); + EXPECT_EQ(md.value() + ->get_pointer(HttpPathMetadata()) + ->as_string_view(), + "/demo.Service/Step"); + return Empty{}; + }, + [handler]() mutable { return handler.PullMessage(); }, + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "12345678"); + return Empty{}; + }, + [handler]() mutable { return handler.PullMessage(); }, + [](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); + return Empty{}; + }, + [handler]() mutable { + return handler.PushServerInitialMetadata(TestInitialMetadata()); + }, + [handler]() mutable { + return handler.PushMessage(Arena::MakePooled( + SliceBuffer(Slice::FromCopiedString("87654321")), 0)); + }, + [handler, &on_done]() mutable { + handler.PushServerTrailingMetadata(TestTrailingMetadata()); + on_done.Call(); + return Empty{}; + }); + }); + return std::move(call.initiator); })); transport->SetAcceptor(&acceptor); - StrictMock> on_done; EXPECT_CALL(on_done, Call()); EXPECT_CALL(*control_endpoint.endpoint, Read) .InSequence(control_endpoint.read_sequence) @@ -145,39 +186,6 @@ TEST_F(TransportTest, ReadAndWriteOneMessage) { sizeof(kGrpcStatus0)), EventEngineSlice::FromCopiedBuffer(kGrpcStatus0, sizeof(kGrpcStatus0))}, nullptr); - call.handler.SpawnInfallible( - "test-io", [&on_done, handler = call.handler]() mutable { - return Seq( - handler.PullClientInitialMetadata(), - [](ValueOrFailure md) { - EXPECT_TRUE(md.ok()); - EXPECT_EQ( - md.value()->get_pointer(HttpPathMetadata())->as_string_view(), - "/demo.Service/Step"); - return Empty{}; - }, - handler.PullMessage(), - [](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "12345678"); - return Empty{}; - }, - handler.PullMessage(), - [](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - return Empty{}; - }, - handler.PushServerInitialMetadata(TestInitialMetadata()), - handler.PushMessage(Arena::MakePooled( - SliceBuffer(Slice::FromCopiedString("87654321")), 0)), - [handler]() mutable { - return handler.PushServerTrailingMetadata(TestTrailingMetadata()); - }, - [&on_done]() mutable { - on_done.Call(); - return Empty{}; - }); - }); // Wait until ClientTransport's internal activities to finish. event_engine()->TickUntilIdle(); event_engine()->UnsetGlobalHooks(); diff --git a/test/core/transport/test_suite/call_content.cc b/test/core/transport/test_suite/call_content.cc index cea4c5a0aa5..9e334f24fb6 100644 --- a/test/core/transport/test_suite/call_content.cc +++ b/test/core/transport/test_suite/call_content.cc @@ -63,21 +63,17 @@ void FillMetadata(const std::vector>& md, TRANSPORT_TEST(UnaryWithSomeContent) { SetServerAcceptor(); - auto initiator = CreateCall(); const auto client_initial_metadata = RandomMetadata(); const auto server_initial_metadata = RandomMetadata(); const auto server_trailing_metadata = RandomMetadata(); const auto client_payload = RandomMessage(); const auto server_payload = RandomMessage(); + auto md = Arena::MakePooled(); + FillMetadata(client_initial_metadata, *md); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - FillMetadata(client_initial_metadata, *md); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { return initiator.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString(client_payload)), 0)); }, @@ -93,14 +89,16 @@ TRANSPORT_TEST(UnaryWithSomeContent) { UnorderedElementsAreArray(server_initial_metadata)); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), server_payload); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + server_payload); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [&](ValueOrFailure md) { @@ -118,14 +116,16 @@ TRANSPORT_TEST(UnaryWithSomeContent) { UnorderedElementsAreArray(client_initial_metadata)); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), client_payload); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + client_payload); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); auto md = Arena::MakePooled(); FillMetadata(server_initial_metadata, *md); return handler.PushServerInitialMetadata(std::move(md)); @@ -139,10 +139,7 @@ TRANSPORT_TEST(UnaryWithSomeContent) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); FillMetadata(server_trailing_metadata, *md); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); diff --git a/test/core/transport/test_suite/call_shapes.cc b/test/core/transport/test_suite/call_shapes.cc index acfa0ffb741..fdae653119d 100644 --- a/test/core/transport/test_suite/call_shapes.cc +++ b/test/core/transport/test_suite/call_shapes.cc @@ -18,16 +18,12 @@ namespace grpc_core { TRANSPORT_TEST(MetadataOnlyRequest) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { initiator.FinishSends(); return initiator.PullServerInitialMetadata(); }, @@ -53,8 +49,9 @@ TRANSPORT_TEST(MetadataOnlyRequest) { "/foo/bar"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); @@ -63,10 +60,7 @@ TRANSPORT_TEST(MetadataOnlyRequest) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -79,16 +73,12 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsAfterInitialMetadata) { "rolling out soon, so leaving this disabled."; SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { // We don't close the sending stream here. return initiator.PullServerInitialMetadata(); }, @@ -123,10 +113,7 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsAfterInitialMetadata) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -139,16 +126,12 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsImmediately) { "rolling out soon, so leaving this disabled."; SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { // We don't close the sending stream here. return initiator.PullServerInitialMetadata(); }, @@ -175,10 +158,7 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsImmediately) { // and don't send initial metadata - just trailing metadata. auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -186,18 +166,9 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsImmediately) { TRANSPORT_TEST(CanCreateCallThenAbandonIt) { SetServerAcceptor(); - auto initiator = CreateCall(); - SpawnTestSeq( - initiator, "start-call", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); - return Empty{}; - }); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); auto handler = TickUntilServerCall(); SpawnTestSeq(initiator, "end-call", [&]() { initiator.Cancel(); @@ -208,16 +179,12 @@ TRANSPORT_TEST(CanCreateCallThenAbandonIt) { TRANSPORT_TEST(UnaryRequest) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { return initiator.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString("hello world")), 0)); }, @@ -233,15 +200,16 @@ TRANSPORT_TEST(UnaryRequest) { ContentTypeMetadata::kApplicationGrpc); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [&](ValueOrFailure md) { @@ -259,14 +227,16 @@ TRANSPORT_TEST(UnaryRequest) { "/foo/bar"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); @@ -280,10 +250,7 @@ TRANSPORT_TEST(UnaryRequest) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -291,16 +258,12 @@ TRANSPORT_TEST(UnaryRequest) { TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [&]() mutable { return initiator.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString("hello world")), 0)); }, @@ -316,9 +279,10 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { ContentTypeMetadata::kApplicationGrpc); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor"); return initiator.PullServerTrailingMetadata(); }, @@ -337,9 +301,11 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { "/foo/bar"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world"); auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); @@ -353,10 +319,7 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -364,18 +327,12 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); - return initiator.PullServerInitialMetadata(); - }, + [&]() mutable { return initiator.PullServerInitialMetadata(); }, [&](ValueOrFailure> md) { EXPECT_TRUE(md.ok()); EXPECT_TRUE(md.value().has_value()); @@ -389,15 +346,16 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { initiator.FinishSends(); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [&](ValueOrFailure md) { @@ -422,14 +380,16 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { EXPECT_TRUE(result.ok()); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return handler.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString("why hello neighbor")), 0)); }, @@ -437,10 +397,7 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -448,18 +405,12 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { TRANSPORT_TEST(ClientStreamingRequest) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); - return initiator.PullServerInitialMetadata(); - }, + [&]() mutable { return initiator.PullServerInitialMetadata(); }, [&](ValueOrFailure> md) { EXPECT_TRUE(md.ok()); EXPECT_TRUE(md.value().has_value()); @@ -493,9 +444,9 @@ TRANSPORT_TEST(ClientStreamingRequest) { initiator.FinishSends(); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [&](ValueOrFailure md) { @@ -520,40 +471,47 @@ TRANSPORT_TEST(ClientStreamingRequest) { EXPECT_TRUE(result.ok()); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world (2)"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world (2)"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world (3)"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world (3)"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world (4)"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world (4)"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world (5)"); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), + "hello world (5)"); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); @@ -561,18 +519,12 @@ TRANSPORT_TEST(ClientStreamingRequest) { TRANSPORT_TEST(ServerStreamingRequest) { SetServerAcceptor(); - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); + auto initiator = CreateCall(std::move(md)); SpawnTestSeq( initiator, "initiator", - [&]() { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [&](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); - return initiator.PullServerInitialMetadata(); - }, + [&]() mutable { return initiator.PullServerInitialMetadata(); }, [&](ValueOrFailure> md) { EXPECT_TRUE(md.ok()); EXPECT_TRUE(md.value().has_value()); @@ -581,45 +533,51 @@ TRANSPORT_TEST(ServerStreamingRequest) { initiator.FinishSends(); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor (2)"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor (3)"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor (4)"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor (5)"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), "why hello neighbor (6)"); return initiator.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [&](ValueOrFailure md) { @@ -644,9 +602,9 @@ TRANSPORT_TEST(ServerStreamingRequest) { EXPECT_TRUE(result.ok()); return handler.PullMessage(); }, - [&](NextResult msg) { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [&](ValueOrFailure> msg) { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return handler.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString("why hello neighbor")), 0)); }, @@ -679,10 +637,7 @@ TRANSPORT_TEST(ServerStreamingRequest) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [&](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); WaitForAllPendingWork(); diff --git a/test/core/transport/test_suite/stress.cc b/test/core/transport/test_suite/stress.cc index 54e34ba98d5..ca20fb7ff3f 100644 --- a/test/core/transport/test_suite/stress.cc +++ b/test/core/transport/test_suite/stress.cc @@ -30,19 +30,14 @@ TRANSPORT_TEST(ManyUnaryRequests) { std::map client_messages; std::map server_messages; for (int i = 0; i < kNumRequests; i++) { - auto initiator = CreateCall(); + auto md = Arena::MakePooled(); + md->Set(HttpPathMetadata(), Slice::FromCopiedString(std::to_string(i))); + auto initiator = CreateCall(std::move(md)); client_messages[i] = RandomMessage(); server_messages[i] = RandomMessage(); SpawnTestSeq( initiator, make_call_name(i, "initiator"), - [initiator, i]() mutable { - auto md = Arena::MakePooled(); - md->Set(HttpPathMetadata(), - Slice::FromCopiedString(std::to_string(i))); - return initiator.PushClientInitialMetadata(std::move(md)); - }, - [initiator, i, &client_messages](StatusFlag status) mutable { - EXPECT_TRUE(status.ok()); + [initiator, i, &client_messages]() mutable { return initiator.PushMessage(Arena::MakePooled( SliceBuffer(Slice::FromCopiedString(client_messages[i])), 0)); }, @@ -59,16 +54,17 @@ TRANSPORT_TEST(ManyUnaryRequests) { ContentTypeMetadata::kApplicationGrpc); return initiator.PullMessage(); }, - [initiator, i, - &server_messages](NextResult msg) mutable { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [initiator, i, &server_messages]( + ValueOrFailure> msg) mutable { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), server_messages[i]); return initiator.PullMessage(); }, - [initiator](NextResult msg) mutable { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [initiator](ValueOrFailure> msg) mutable { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); return initiator.PullServerTrailingMetadata(); }, [initiator](ValueOrFailure md) mutable { @@ -92,16 +88,17 @@ TRANSPORT_TEST(ManyUnaryRequests) { &*this_call_index)); return handler.PullMessage(); }, - [handler, this_call_index, - &client_messages](NextResult msg) mutable { - EXPECT_TRUE(msg.has_value()); - EXPECT_EQ(msg.value()->payload()->JoinIntoString(), + [handler, this_call_index, &client_messages]( + ValueOrFailure> msg) mutable { + EXPECT_TRUE(msg.ok()); + EXPECT_TRUE(msg.value().has_value()); + EXPECT_EQ(msg.value().value()->payload()->JoinIntoString(), client_messages[*this_call_index]); return handler.PullMessage(); }, - [handler](NextResult msg) mutable { - EXPECT_FALSE(msg.has_value()); - EXPECT_FALSE(msg.cancelled()); + [handler](ValueOrFailure> msg) mutable { + EXPECT_TRUE(msg.ok()); + EXPECT_FALSE(msg.value().has_value()); auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); @@ -118,10 +115,7 @@ TRANSPORT_TEST(ManyUnaryRequests) { EXPECT_TRUE(result.ok()); auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); - return handler.PushServerTrailingMetadata(std::move(md)); - }, - [handler](StatusFlag result) mutable { - EXPECT_TRUE(result.ok()); + handler.PushServerTrailingMetadata(std::move(md)); return Empty{}; }); } diff --git a/test/core/transport/test_suite/test.cc b/test/core/transport/test_suite/test.cc index 6d48a5712fa..7dc767810d7 100644 --- a/test/core/transport/test_suite/test.cc +++ b/test/core/transport/test_suite/test.cc @@ -56,12 +56,16 @@ void TransportTest::SetServerAcceptor() { transport_pair_.server->server_transport()->SetAcceptor(&acceptor_); } -CallInitiator TransportTest::CreateCall() { - auto call = MakeCall(event_engine_.get(), Arena::Create(1024, &allocator_)); - call.handler.SpawnInfallible("start-call", [this, handler = call.handler]() { - transport_pair_.client->client_transport()->StartCall(handler); - return Empty{}; - }); +CallInitiator TransportTest::CreateCall( + ClientMetadataHandle client_initial_metadata) { + auto call = MakeCall(std::move(client_initial_metadata), event_engine_.get(), + Arena::Create(1024, &allocator_), true); + call.handler.SpawnInfallible( + "start-call", [this, handler = call.handler]() mutable { + transport_pair_.client->client_transport()->StartCall( + handler.V2HackToStartCallWithoutACallFilterStack()); + return Empty{}; + }); return std::move(call.initiator); } @@ -231,9 +235,10 @@ Arena* TransportTest::Acceptor::CreateArena() { } absl::StatusOr TransportTest::Acceptor::CreateCall( - ClientMetadata&, Arena* arena) { - auto call = MakeCall(event_engine_, arena); - handlers_.push(std::move(call.handler)); + ClientMetadataHandle client_initial_metadata, Arena* arena) { + auto call = + MakeCall(std::move(client_initial_metadata), event_engine_, arena, true); + handlers_.push(call.handler.V2HackToStartCallWithoutACallFilterStack()); return std::move(call.initiator); } diff --git a/test/core/transport/test_suite/test.h b/test/core/transport/test_suite/test.h index 6981d5ca51f..f0451a4488d 100644 --- a/test/core/transport/test_suite/test.h +++ b/test/core/transport/test_suite/test.h @@ -221,7 +221,7 @@ class TransportTest : public ::testing::Test { rng_(rng) {} void SetServerAcceptor(); - CallInitiator CreateCall(); + CallInitiator CreateCall(ClientMetadataHandle client_initial_metadata); std::string RandomString(int min_length, int max_length, absl::string_view character_set); @@ -272,7 +272,7 @@ class TransportTest : public ::testing::Test { Arena* CreateArena() override; absl::StatusOr CreateCall( - ClientMetadata& client_initial_metadata, Arena* arena) override; + ClientMetadataHandle client_initial_metadata, Arena* arena) override; absl::optional PopHandler(); private: From 38fd697579e5a64d55d8e025d42dfd11d7e2970d Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:53:15 -0700 Subject: [PATCH 04/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36359) Closes #36359 PiperOrigin-RevId: 625183028 --- examples/cpp/csm/BUILD | 1 + examples/cpp/csm/csm_greeter_server.cc | 3 ++- examples/cpp/helloworld/BUILD | 1 + examples/cpp/helloworld/CMakeLists.txt | 1 + examples/cpp/helloworld/xds_greeter_server.cc | 8 ++++---- examples/cpp/xds/BUILD | 1 + examples/cpp/xds/xds_greeter_server.cc | 8 ++++---- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/cpp/csm/BUILD b/examples/cpp/csm/BUILD index 836abbab310..7f1bf30d836 100644 --- a/examples/cpp/csm/BUILD +++ b/examples/cpp/csm/BUILD @@ -41,6 +41,7 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log", "@io_opentelemetry_cpp//exporters/prometheus:prometheus_exporter", "@io_opentelemetry_cpp//sdk/src/metrics", ], diff --git a/examples/cpp/csm/csm_greeter_server.cc b/examples/cpp/csm/csm_greeter_server.cc index c5d7857e7fa..910e3f65749 100644 --- a/examples/cpp/csm/csm_greeter_server.cc +++ b/examples/cpp/csm/csm_greeter_server.cc @@ -22,6 +22,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "opentelemetry/exporters/prometheus/exporter_factory.h" #include "opentelemetry/exporters/prometheus/exporter_options.h" @@ -91,7 +92,7 @@ void RunServer(const char* hostname) { xds_builder.AddListeningPort(absl::StrCat("0.0.0.0:", port), grpc::InsecureServerCredentials()); xds_enabled_server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port); + LOG(INFO) << "Server starting on 0.0.0.0:" << port; // Wait for the server to shutdown. Note that some other thread must be // responsible for shutting down the server for this call to ever return. diff --git a/examples/cpp/helloworld/BUILD b/examples/cpp/helloworld/BUILD index 3c01b6ce1c3..1bcee389efb 100644 --- a/examples/cpp/helloworld/BUILD +++ b/examples/cpp/helloworld/BUILD @@ -129,5 +129,6 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log", ], ) diff --git a/examples/cpp/helloworld/CMakeLists.txt b/examples/cpp/helloworld/CMakeLists.txt index 73ad4877483..defe3064b14 100644 --- a/examples/cpp/helloworld/CMakeLists.txt +++ b/examples/cpp/helloworld/CMakeLists.txt @@ -68,6 +68,7 @@ foreach(_target absl::check absl::flags absl::flags_parse + absl::log ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF}) diff --git a/examples/cpp/helloworld/xds_greeter_server.cc b/examples/cpp/helloworld/xds_greeter_server.cc index 9e4ca2a0549..c0bed68ff7a 100644 --- a/examples/cpp/helloworld/xds_greeter_server.cc +++ b/examples/cpp/helloworld/xds_greeter_server.cc @@ -22,6 +22,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include @@ -79,21 +80,20 @@ void RunServer() { absl::StrCat("0.0.0.0:", port), grpc::XdsServerCredentials(grpc::InsecureServerCredentials())); xds_enabled_server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port); + LOG(INFO) << "Server starting on 0.0.0.0:" << port; grpc::AddAdminServices(&builder); // For the maintenance server, do not use any authentication mechanism. builder.AddListeningPort(absl::StrCat("0.0.0.0:", maintenance_port), grpc::InsecureServerCredentials()); server = builder.BuildAndStart(); - gpr_log(GPR_INFO, "Maintenance server listening on 0.0.0.0:%d", - maintenance_port); + LOG(INFO) << "Maintenance server listening on 0.0.0.0:" << maintenance_port; } else { grpc::AddAdminServices(&xds_builder); // Listen on the given address without any authentication mechanism. builder.AddListeningPort(absl::StrCat("0.0.0.0:", port), grpc::InsecureServerCredentials()); server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server listening on 0.0.0.0:%d", port); + LOG(INFO) << "Server listening on 0.0.0.0:" << port; } // Wait for the server to shutdown. Note that some other thread must be diff --git a/examples/cpp/xds/BUILD b/examples/cpp/xds/BUILD index 6657b1cbbf6..bf5abfd1807 100644 --- a/examples/cpp/xds/BUILD +++ b/examples/cpp/xds/BUILD @@ -37,5 +37,6 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log", ], ) diff --git a/examples/cpp/xds/xds_greeter_server.cc b/examples/cpp/xds/xds_greeter_server.cc index bc4fe66c0f5..c35166c819e 100644 --- a/examples/cpp/xds/xds_greeter_server.cc +++ b/examples/cpp/xds/xds_greeter_server.cc @@ -22,6 +22,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include @@ -84,21 +85,20 @@ void RunServer() { absl::StrCat("0.0.0.0:", port), grpc::XdsServerCredentials(grpc::InsecureServerCredentials())); xds_enabled_server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port); + LOG(INFO) << "Server starting on 0.0.0.0:" << port; grpc::AddAdminServices(&builder); // For the maintenance server, do not use any authentication mechanism. builder.AddListeningPort(absl::StrCat("0.0.0.0:", maintenance_port), grpc::InsecureServerCredentials()); server = builder.BuildAndStart(); - gpr_log(GPR_INFO, "Maintenance server listening on 0.0.0.0:%d", - maintenance_port); + LOG(INFO) << "Maintenance server listening on 0.0.0.0:" << maintenance_port; } else { grpc::AddAdminServices(&xds_builder); // Listen on the given address without any authentication mechanism. builder.AddListeningPort(absl::StrCat("0.0.0.0:", port), grpc::InsecureServerCredentials()); server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server listening on 0.0.0.0:%d", port); + LOG(INFO) << "Server listening on 0.0.0.0:" << port; } // Wait for the server to shutdown. Note that some other thread must be From 648415ee888f5e7f6fee7cc790c2e9a9c47b85c6 Mon Sep 17 00:00:00 2001 From: Vishwanath Sastry Date: Mon, 15 Apr 2024 23:24:16 -0700 Subject: [PATCH 05/45] [grpc][grpc_fuzzers] Fix for the crash reported in the bug https://buganizer.corp.google.com/issues/331838963 PiperOrigin-RevId: 625212041 --- test/core/end2end/fuzzers/api_fuzzer.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 98dd58e7df5..ab506cc54fc 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -32,6 +32,8 @@ #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" #include "absl/types/optional.h" #include @@ -157,9 +159,18 @@ class FuzzerDNSResolver : public grpc_core::DNSResolver { } absl::StatusOr> LookupHostnameBlocking( - absl::string_view /* name */, - absl::string_view /* default_port */) override { - GPR_ASSERT(0); + absl::string_view name, absl::string_view default_port) override { + // To mimic the resolution delay + absl::SleepFor(absl::Seconds(1)); + if (name == "server") { + std::vector addrs; + grpc_resolved_address addr; + memset(&addr, 0, sizeof(addr)); + addrs.push_back(addr); + return addrs; + } else { + return absl::UnknownError("Resolution failed"); + } } TaskHandle LookupSRV( From 40d1776e0761e85c2d5b0215460ddd79122e142b Mon Sep 17 00:00:00 2001 From: Matthew Stevenson Date: Tue, 16 Apr 2024 07:35:21 -0700 Subject: [PATCH 06/45] ssl: More comprehensive testing of SSL credentials, part 1. (#35433) First of several PRs to improve the e2e testing for the SSL credentials API. Closes #35433 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35433 from matthewstevenson88:more-ssl-testing 2a0db7624eff02d292d9d247b635c9a614e6fc18 PiperOrigin-RevId: 625326074 --- src/core/tsi/ssl_transport_security.cc | 4 + src/core/tsi/ssl_transport_security.h | 3 + test/cpp/end2end/BUILD | 1 + test/cpp/end2end/ssl_credentials_test.cc | 497 ++++++++++++++++++++--- 4 files changed, 441 insertions(+), 64 deletions(-) diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 9235782bb29..d705abc1c2c 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -1282,6 +1282,10 @@ void tsi_ssl_session_cache_unref(tsi_ssl_session_cache* cache) { tsi::SslSessionLRUCache::FromC(cache)->Unref(); } +size_t tsi_ssl_session_cache_size(tsi_ssl_session_cache* cache) { + return tsi::SslSessionLRUCache::FromC(cache)->Size(); +} + // --- tsi_frame_protector methods implementation. --- static tsi_result ssl_protector_protect(tsi_frame_protector* self, diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index da3b260adbd..d925f08840b 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -81,6 +81,9 @@ void tsi_ssl_session_cache_ref(tsi_ssl_session_cache* cache); // Decrement reference counter of \a cache. void tsi_ssl_session_cache_unref(tsi_ssl_session_cache* cache); +// Returns the size of the cache. +size_t tsi_ssl_session_cache_size(tsi_ssl_session_cache* cache); + // --- tsi_ssl_key_logger object --- // Experimental SSL Key logging functionality to enable decryption of diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index d8a09d6d3c0..36125889baa 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -1068,6 +1068,7 @@ grpc_cc_test( grpc_cc_test( name = "ssl_credentials_test", + timeout = "long", srcs = ["ssl_credentials_test.cc"], data = [ "//src/core/tsi/test_creds:ca.pem", diff --git a/test/cpp/end2end/ssl_credentials_test.cc b/test/cpp/end2end/ssl_credentials_test.cc index a0b8d5c0dd2..f8b73ae952e 100644 --- a/test/cpp/end2end/ssl_credentials_test.cc +++ b/test/cpp/end2end/ssl_credentials_test.cc @@ -15,7 +15,11 @@ // limitations under the License. // // +#include "src/core/lib/security/credentials/ssl/ssl_credentials.h" + #include +#include +#include #include #include @@ -29,34 +33,67 @@ #include #include +#include "src/core/lib/gprpp/cpp_impl_of.h" +#include "src/core/tsi/ssl_transport_security.h" +#include "src/cpp/client/secure_credentials.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" +// TODO(matthewstevenson88): More test cases to add: +// - Use P256, P384, P512 credentials. +// - Use a long certificate chain. +// - Use a large certificate. +// - Large trust bundle. +// - Bad ALPN. +// - More failure modes. +// - Certs containing more SANs. +// - Copy all of this over to tls_credentials_test.cc. +// - Client doesn't have cert but server requests one. +// - Bad session ticket in cache. +// - Use same channel creds object on sequential/concurrent handshakes. +// - Do successful handshake with a localhost server cert. +// - Missing or malformed roots on both sides. + namespace grpc { namespace testing { namespace { +using ::grpc_core::testing::GetFileContents; +using ::testing::HasSubstr; +using ::testing::IsEmpty; +using ::testing::UnorderedElementsAre; + 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"; constexpr char kMessage[] = "Hello"; +constexpr char kTargetNameOverride[] = "foo.test.google.fr"; + +std::size_t GetSessionCacheSize(grpc_ssl_session_cache* cache) { + tsi_ssl_session_cache* tsi_cache = + reinterpret_cast(cache); + return tsi_ssl_session_cache_size(tsi_cache); +} + +struct SslOptions { + grpc_ssl_client_certificate_request_type request_type = + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE; + bool use_session_cache; +}; -class SslCredentialsTest : public ::testing::Test { +class SslCredentialsTest : public ::testing::TestWithParam { protected: - void RunServer(absl::Notification* notification) { - std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); + void RunServer(absl::Notification* notification, + absl::string_view pem_root_certs) { grpc::SslServerCredentialsOptions::PemKeyCertPair key_cert_pair = { - grpc_core::testing::GetFileContents(kServerKeyPath), - grpc_core::testing::GetFileContents(kServerCertPath)}; - // TODO(gtcooke94) Parametrize this test for TLS and mTLS as well - grpc::SslServerCredentialsOptions ssl_options; + GetFileContents(kServerKeyPath), GetFileContents(kServerCertPath)}; + grpc::SslServerCredentialsOptions ssl_options(GetParam().request_type); ssl_options.pem_key_cert_pairs.push_back(key_cert_pair); - ssl_options.pem_root_certs = root_cert; - ssl_options.force_client_auth = true; + ssl_options.pem_root_certs = std::string(pem_root_certs); grpc::ServerBuilder builder; TestServiceImpl service_; @@ -77,57 +114,226 @@ class SslCredentialsTest : public ::testing::Test { } } + absl::StatusOr> DoRpc( + const SslCredentialsOptions& options, grpc_ssl_session_cache* cache, + bool override_ssl_target_name = true) { + ChannelArguments channel_args; + if (GetParam().use_session_cache) { + channel_args.SetPointer(std::string(GRPC_SSL_SESSION_CACHE_ARG), cache); + } + if (override_ssl_target_name) { + channel_args.SetSslTargetNameOverride(kTargetNameOverride); + } + + auto creds = SslCredentials(options); + std::shared_ptr channel = + grpc::CreateCustomChannel(server_addr_, creds, channel_args); + + auto stub = grpc::testing::EchoTestService::NewStub(channel); + grpc::testing::EchoRequest request; + grpc::testing::EchoResponse response; + request.set_message(kMessage); + ClientContext context; + context.set_deadline(grpc_timeout_seconds_to_deadline(/*time_s=*/10)); + grpc::Status result = stub->Echo(&context, request, &response); + if (!result.ok()) { + return absl::Status(static_cast(result.error_code()), + result.error_message()); + } + EXPECT_EQ(response.message(), kMessage); + return context.auth_context(); + } + + static std::vector GetAuthContextPropertyAsList( + const AuthContext& auth_context, const std::string& property) { + std::vector properties; + for (const grpc::string_ref& property : + auth_context.FindPropertyValues(property)) { + properties.push_back(absl::string_view(property.data(), property.size())); + } + return properties; + } + + static absl::string_view GetAuthContextProperty( + const AuthContext& auth_context, const std::string& property) { + std::vector properties = + GetAuthContextPropertyAsList(auth_context, property); + return properties.size() == 1 ? properties[0] : ""; + } + TestServiceImpl service_; std::unique_ptr server_ = nullptr; std::thread* server_thread_ = nullptr; std::string server_addr_; }; -void DoRpc(const std::string& server_addr, - const SslCredentialsOptions& ssl_options, - grpc_ssl_session_cache* cache, bool expect_session_reuse) { - ChannelArguments channel_args; - channel_args.SetPointer(std::string(GRPC_SSL_SESSION_CACHE_ARG), cache); - channel_args.SetSslTargetNameOverride("foo.test.google.fr"); - - std::shared_ptr channel = grpc::CreateCustomChannel( - server_addr, grpc::SslCredentials(ssl_options), channel_args); - - auto stub = grpc::testing::EchoTestService::NewStub(channel); - grpc::testing::EchoRequest request; - grpc::testing::EchoResponse response; - request.set_message(kMessage); - ClientContext context; - context.set_deadline(grpc_timeout_seconds_to_deadline(/*time_s=*/10)); - grpc::Status result = stub->Echo(&context, request, &response); - EXPECT_TRUE(result.ok()); - if (!result.ok()) { - gpr_log(GPR_ERROR, "%s, %s", result.error_message().c_str(), - result.error_details().c_str()); - } - EXPECT_EQ(response.message(), kMessage); - std::shared_ptr auth_context = context.auth_context(); - std::vector properties = - auth_context->FindPropertyValues(GRPC_SSL_SESSION_REUSED_PROPERTY); - ASSERT_EQ(properties.size(), 1u); - if (expect_session_reuse) { - EXPECT_EQ("true", ToString(properties[0])); - } else { - EXPECT_EQ("false", ToString(properties[0])); +TEST_P(SslCredentialsTest, FullHandshake) { + server_addr_ = absl::StrCat("localhost:", + std::to_string(grpc_pick_unused_port_or_die())); + absl::Notification notification; + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); + notification.WaitForNotification(); + + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); + grpc::SslCredentialsOptions ssl_options; + ssl_options.pem_root_certs = root_cert; + ssl_options.pem_private_key = client_key; + ssl_options.pem_cert_chain = client_cert; + + grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); + + auto full_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "false"); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME), + GRPC_SSL_TRANSPORT_SECURITY_TYPE); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME), + "TSI_PRIVACY_AND_INTEGRITY"); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_X509_CN_PROPERTY_NAME), + "*.test.google.com"); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_X509_SUBJECT_PROPERTY_NAME), + "CN=*.test.google.com,O=Example\\, Co.,L=Chicago,ST=Illinois,C=US"); + EXPECT_THAT( + GetAuthContextPropertyAsList(**full_handshake_context, + GRPC_X509_SAN_PROPERTY_NAME), + UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", + "*.test.youtube.com", "192.168.1.3")); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_X509_PEM_CERT_PROPERTY_NAME), + GetFileContents(kServerCertPath)); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME), + GetFileContents(kServerCertPath)); + EXPECT_THAT( + GetAuthContextPropertyAsList(**full_handshake_context, + GRPC_PEER_DNS_PROPERTY_NAME), + UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", + "*.test.youtube.com")); + EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, + GRPC_PEER_URI_PROPERTY_NAME), + IsEmpty()); + EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, + GRPC_PEER_EMAIL_PROPERTY_NAME), + IsEmpty()); + EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, + GRPC_PEER_IP_PROPERTY_NAME), + UnorderedElementsAre("192.168.1.3")); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_PEER_SPIFFE_ID_PROPERTY_NAME), + ""); + if (GetParam().use_session_cache) { + EXPECT_EQ(GetSessionCacheSize(cache), 1); } + + grpc_ssl_session_cache_destroy(cache); +} + +TEST_P(SslCredentialsTest, ResumedHandshake) { + // Skip this test if session caching is disabled. + if (!GetParam().use_session_cache) return; + + server_addr_ = absl::StrCat("localhost:", + std::to_string(grpc_pick_unused_port_or_die())); + absl::Notification notification; + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); + notification.WaitForNotification(); + + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); + grpc::SslCredentialsOptions ssl_options; + ssl_options.pem_root_certs = root_cert; + ssl_options.pem_private_key = client_key; + ssl_options.pem_cert_chain = client_cert; + + grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); + + auto full_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "false"); + + auto resumed_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "true"); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME), + GRPC_SSL_TRANSPORT_SECURITY_TYPE); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME), + "TSI_PRIVACY_AND_INTEGRITY"); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_X509_CN_PROPERTY_NAME), + "*.test.google.com"); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_X509_SUBJECT_PROPERTY_NAME), + "CN=*.test.google.com,O=Example\\, Co.,L=Chicago,ST=Illinois,C=US"); + EXPECT_THAT( + GetAuthContextPropertyAsList(**resumed_handshake_context, + GRPC_X509_SAN_PROPERTY_NAME), + UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", + "*.test.youtube.com", "192.168.1.3")); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_X509_PEM_CERT_PROPERTY_NAME), + GetFileContents(kServerCertPath)); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME), + GetFileContents(kServerCertPath)); + EXPECT_THAT( + GetAuthContextPropertyAsList(**resumed_handshake_context, + GRPC_PEER_DNS_PROPERTY_NAME), + UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", + "*.test.youtube.com")); + EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, + GRPC_PEER_URI_PROPERTY_NAME), + IsEmpty()); + EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, + GRPC_PEER_EMAIL_PROPERTY_NAME), + IsEmpty()); + EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, + GRPC_PEER_IP_PROPERTY_NAME), + UnorderedElementsAre("192.168.1.3")); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_PEER_SPIFFE_ID_PROPERTY_NAME), + ""); + EXPECT_EQ(GetSessionCacheSize(cache), 1); + + grpc_ssl_session_cache_destroy(cache); } -TEST_F(SslCredentialsTest, SequentialResumption) { +TEST_P(SslCredentialsTest, SequentialResumption) { + // Skip this test if session caching is disabled. + if (!GetParam().use_session_cache) return; + server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { RunServer(¬ification); }); + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); notification.WaitForNotification(); - std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); - std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); - std::string client_cert = - grpc_core::testing::GetFileContents(kClientCertPath); + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -135,25 +341,38 @@ TEST_F(SslCredentialsTest, SequentialResumption) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); + auto full_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "false"); for (int i = 0; i < 10; i++) { - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/true); + auto resumed_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "true"); } grpc_ssl_session_cache_destroy(cache); } -TEST_F(SslCredentialsTest, ConcurrentResumption) { +TEST_P(SslCredentialsTest, ConcurrentResumption) { + // Skip this test if session caching is disabled. + if (!GetParam().use_session_cache) return; + server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { RunServer(¬ification); }); + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); notification.WaitForNotification(); - std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); - std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); - std::string client_cert = - grpc_core::testing::GetFileContents(kClientCertPath); + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -161,12 +380,20 @@ TEST_F(SslCredentialsTest, ConcurrentResumption) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); + auto full_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "false"); std::vector threads; threads.reserve(10); for (int i = 0; i < 10; i++) { threads.push_back(std::thread([&]() { - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/true); + auto resumed_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "true"); })); } for (auto& t : threads) { @@ -176,17 +403,19 @@ TEST_F(SslCredentialsTest, ConcurrentResumption) { grpc_ssl_session_cache_destroy(cache); } -TEST_F(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { +TEST_P(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { RunServer(¬ification); }); + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); notification.WaitForNotification(); - std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); - std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); - std::string client_cert = - grpc_core::testing::GetFileContents(kClientCertPath); + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -194,12 +423,152 @@ TEST_F(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); - DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); + for (int i = 0; i < 2; ++i) { + auto full_handshake_context = DoRpc(ssl_options, cache); + EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); + EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, + GRPC_SSL_SESSION_REUSED_PROPERTY), + "false"); + } grpc_ssl_session_cache_destroy(cache); } +TEST_P(SslCredentialsTest, ServerCertificateIsUntrusted) { + server_addr_ = absl::StrCat("localhost:", + std::to_string(grpc_pick_unused_port_or_die())); + absl::Notification notification; + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); + notification.WaitForNotification(); + + // Use the client's own leaf cert as the root cert, so that the server's cert + // will not be trusted by the client. + std::string root_cert = GetFileContents(kClientCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); + grpc::SslCredentialsOptions ssl_options; + ssl_options.pem_root_certs = root_cert; + ssl_options.pem_private_key = client_key; + ssl_options.pem_cert_chain = client_cert; + + grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); + + auto auth_context = DoRpc(ssl_options, cache); + EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); + EXPECT_THAT(auth_context.status().message(), + HasSubstr("CERTIFICATE_VERIFY_FAILED")); + EXPECT_EQ(GetSessionCacheSize(cache), 0); + + grpc_ssl_session_cache_destroy(cache); +} + +TEST_P(SslCredentialsTest, ClientCertificateIsUntrusted) { + // Skip this test if the client certificate is not requested. + if (GetParam().request_type == grpc_ssl_client_certificate_request_type:: + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) { + return; + } + + server_addr_ = absl::StrCat("localhost:", + std::to_string(grpc_pick_unused_port_or_die())); + absl::Notification notification; + server_thread_ = new std::thread([&]() { + // Use the server's own leaf cert as the root cert, so that the client's + // cert will not be trusted by the server. + std::string root_cert = GetFileContents(kServerCertPath); + RunServer(¬ification, root_cert); + }); + notification.WaitForNotification(); + + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); + grpc::SslCredentialsOptions ssl_options; + ssl_options.pem_root_certs = root_cert; + ssl_options.pem_private_key = client_key; + ssl_options.pem_cert_chain = client_cert; + + grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); + + auto auth_context = DoRpc(ssl_options, cache); + if (GetParam().request_type == + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY || + GetParam().request_type == + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY) { + EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); + // TODO(matthewstevenson88): Investigate having a more descriptive error + // message for the client. + EXPECT_THAT(auth_context.status().message(), + HasSubstr("failed to connect")); + EXPECT_EQ(GetSessionCacheSize(cache), 0); + } else { + // TODO(matthewstevenson88): The handshake fails with a certificate + // verification error in these cases. This is a bug. Fix this. + } + + grpc_ssl_session_cache_destroy(cache); +} + +TEST_P(SslCredentialsTest, ServerHostnameVerificationFails) { + server_addr_ = absl::StrCat("localhost:", + std::to_string(grpc_pick_unused_port_or_die())); + absl::Notification notification; + server_thread_ = new std::thread([&]() { + std::string root_cert = GetFileContents(kCaCertPath); + RunServer(¬ification, root_cert); + }); + notification.WaitForNotification(); + + std::string root_cert = GetFileContents(kCaCertPath); + std::string client_key = GetFileContents(kClientKeyPath); + std::string client_cert = GetFileContents(kClientCertPath); + grpc::SslCredentialsOptions ssl_options; + ssl_options.pem_root_certs = root_cert; + ssl_options.pem_private_key = client_key; + ssl_options.pem_cert_chain = client_cert; + + grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); + + auto auth_context = + DoRpc(ssl_options, cache, /*override_ssl_target_name=*/false); + EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); + // TODO(matthewstevenson88): Logs say "No match found for server name: + // localhost." but this error is not propagated to the user. Fix this. + EXPECT_FALSE(auth_context.status().message().empty()); + EXPECT_EQ(GetSessionCacheSize(cache), 0); + + grpc_ssl_session_cache_destroy(cache); +} + +std::vector GetSslOptions() { + std::vector ssl_options; + for (grpc_ssl_client_certificate_request_type type : + {grpc_ssl_client_certificate_request_type:: + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY, + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, + grpc_ssl_client_certificate_request_type:: + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY}) { + for (bool use_session_cache : {false, true}) { + SslOptions option = {type, use_session_cache}; + ssl_options.push_back(option); + } + } + return ssl_options; +} + +INSTANTIATE_TEST_SUITE_P(SslCredentials, SslCredentialsTest, + ::testing::ValuesIn(GetSslOptions())); + } // namespace } // namespace testing } // namespace grpc From 7561250649fb5dc01040b8ade45328750993feac Mon Sep 17 00:00:00 2001 From: gRPC Team Bot Date: Tue, 16 Apr 2024 15:55:31 +0000 Subject: [PATCH 07/45] Enable GRPC OTel Plugin PiperOrigin-RevId: 625347240 --- src/cpp/ext/otel/BUILD | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/ext/otel/BUILD b/src/cpp/ext/otel/BUILD index 588c769652d..fe5cb0bd478 100644 --- a/src/cpp/ext/otel/BUILD +++ b/src/cpp/ext/otel/BUILD @@ -55,9 +55,13 @@ grpc_cc_library( "absl/types:optional", "absl/types:span", "otel/api", + "otel/sdk", ], language = "c++", - visibility = ["//:__subpackages__"], + visibility = [ + "//:__subpackages__", + "//blockchain/research/falcon/monitoring:__subpackages__", + ], deps = [ "//:call_tracer", "//:config", From 58b254dacfcdaed354fe067c9948f569751ccc45 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 16 Apr 2024 18:06:50 +0000 Subject: [PATCH 08/45] [call-v3] Channel filter construction returns pointers (#36355) Currently channel filter construction returns a `StatusOr`, this change makes it return a `StatusOr>` where P is `unique_ptr`, `OrphanablePtr`, `RefCountedPtr`, `DualRefCountedPtr`, etc (most of the code really doesn't need to know, so I'm choosing to leave the flexibility). That smart pointer is then stored in the channel stack instance, and dereferenced when needed. This means that channel filters no longer need to be movable (which is a nice simplification), and puts these level-1 filters on a similar memory management track as the level-2 filters we have planned. (this change also converts client load reporting to v3 apis -- it's a bit accidentally picked up, but seems ok to pull through too) Closes #36355 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36355 from ctiller:objectify-me 0eb054b74826d3b04a5af420c8b7ec73e3fa12c2 PiperOrigin-RevId: 625390977 --- .../backend_metrics/backend_metric_filter.cc | 7 ++- .../backend_metrics/backend_metric_filter.h | 4 +- .../legacy_channel_idle_filter.cc | 18 +++--- .../channel_idle/legacy_channel_idle_filter.h | 21 +++---- .../fault_injection/fault_injection_filter.cc | 13 ++-- .../fault_injection/fault_injection_filter.h | 8 +-- .../filters/http/client/http_client_filter.cc | 9 +-- .../filters/http/client/http_client_filter.h | 10 +-- .../filters/http/client_authority_filter.cc | 7 ++- .../filters/http/client_authority_filter.h | 9 +-- .../message_compress/compression_filter.cc | 12 ++-- .../message_compress/compression_filter.h | 16 ++--- .../filters/http/server/http_server_filter.cc | 4 +- .../filters/http/server/http_server_filter.h | 10 +-- .../server_load_reporting_filter.cc | 9 +-- .../server_load_reporting_filter.h | 2 +- .../ext/filters/logging/logging_filter.cc | 19 +++--- src/core/ext/filters/logging/logging_filter.h | 11 ++-- .../message_size/message_size_filter.cc | 14 ++--- .../message_size/message_size_filter.h | 14 +++-- src/core/ext/filters/rbac/rbac_filter.cc | 15 +++-- src/core/ext/filters/rbac/rbac_filter.h | 10 +-- .../server_config_selector_filter.cc | 63 +++++++++---------- .../stateful_session_filter.cc | 7 ++- .../stateful_session_filter.h | 5 +- src/core/lib/channel/promise_based_filter.cc | 6 +- src/core/lib/channel/promise_based_filter.h | 46 ++++++++------ .../lib/channel/server_call_tracer_filter.cc | 10 +-- .../authorization/grpc_server_authz_filter.cc | 6 +- .../authorization/grpc_server_authz_filter.h | 12 ++-- .../lib/security/transport/auth_filters.h | 22 +++---- .../security/transport/client_auth_filter.cc | 7 ++- .../security/transport/server_auth_filter.cc | 5 +- src/core/lib/surface/channel_init.h | 15 +++-- src/core/lib/surface/lame_client.cc | 18 +++--- src/core/lib/surface/lame_client.h | 14 ++--- .../grpclb/client_load_reporting_filter.cc | 58 +++++++++-------- .../grpclb/client_load_reporting_filter.h | 27 +++++--- src/core/resolver/xds/xds_resolver.cc | 13 ++-- .../service_config_channel_arg_filter.cc | 13 ++-- src/cpp/ext/filters/census/client_filter.cc | 8 ++- src/cpp/ext/filters/census/client_filter.h | 7 ++- test/core/filters/filter_test.h | 2 +- test/core/filters/filter_test_test.cc | 27 ++++---- test/core/surface/channel_init_test.cc | 6 +- test/core/util/fake_stats_plugin.cc | 15 +++-- test/cpp/ext/otel/otel_test_library.cc | 16 ++--- 47 files changed, 354 insertions(+), 316 deletions(-) diff --git a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc index 33566871cdf..e2caef67939 100644 --- a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +++ b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc @@ -25,6 +25,7 @@ #include #include "absl/strings/string_view.h" +#include "third_party/grpc/src/core/lib/channel/promise_based_filter.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" @@ -121,9 +122,9 @@ const grpc_channel_filter BackendMetricFilter::kFilter = MakePromiseBasedFilter( "backend_metric"); -absl::StatusOr BackendMetricFilter::Create( - const ChannelArgs&, ChannelFilter::Args) { - return BackendMetricFilter(); +absl::StatusOr> +BackendMetricFilter::Create(const ChannelArgs&, ChannelFilter::Args) { + return std::make_unique(); } void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) { diff --git a/src/core/ext/filters/backend_metrics/backend_metric_filter.h b/src/core/ext/filters/backend_metrics/backend_metric_filter.h index 2c71a9d19cb..d97b0c8cb65 100644 --- a/src/core/ext/filters/backend_metrics/backend_metric_filter.h +++ b/src/core/ext/filters/backend_metrics/backend_metric_filter.h @@ -35,8 +35,8 @@ class BackendMetricFilter : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args); + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args); class Call { public: diff --git a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc index 7d7757ac081..d189d4080a7 100644 --- a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +++ b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc @@ -25,6 +25,7 @@ #include "absl/base/thread_annotations.h" #include "absl/meta/type_traits.h" #include "absl/random/random.h" +#include "absl/status/statusor.h" #include "absl/types/optional.h" #include @@ -133,18 +134,17 @@ struct LegacyMaxAgeFilter::Config { // will be removed at that time also, so just disable the deprecation warning // for now. ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING -absl::StatusOr LegacyClientIdleFilter::Create( - const ChannelArgs& args, ChannelFilter::Args filter_args) { - LegacyClientIdleFilter filter(filter_args.channel_stack(), - GetClientIdleTimeout(args)); - return absl::StatusOr(std::move(filter)); +absl::StatusOr> +LegacyClientIdleFilter::Create(const ChannelArgs& args, + ChannelFilter::Args filter_args) { + return std::make_unique(filter_args.channel_stack(), + GetClientIdleTimeout(args)); } -absl::StatusOr LegacyMaxAgeFilter::Create( +absl::StatusOr> LegacyMaxAgeFilter::Create( const ChannelArgs& args, ChannelFilter::Args filter_args) { - LegacyMaxAgeFilter filter(filter_args.channel_stack(), - Config::FromChannelArgs(args)); - return absl::StatusOr(std::move(filter)); + return std::make_unique(filter_args.channel_stack(), + Config::FromChannelArgs(args)); } ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING diff --git a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h index 8e06505d732..8e6215cebba 100644 --- a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h +++ b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h @@ -42,6 +42,11 @@ namespace grpc_core { class LegacyChannelIdleFilter : public ChannelFilter { public: + LegacyChannelIdleFilter(grpc_channel_stack* channel_stack, + Duration client_idle_timeout) + : channel_stack_(channel_stack), + client_idle_timeout_(client_idle_timeout) {} + ~LegacyChannelIdleFilter() override = default; LegacyChannelIdleFilter(const LegacyChannelIdleFilter&) = delete; @@ -59,11 +64,6 @@ class LegacyChannelIdleFilter : public ChannelFilter { using SingleSetActivityPtr = SingleSetPtr; - LegacyChannelIdleFilter(grpc_channel_stack* channel_stack, - Duration client_idle_timeout) - : channel_stack_(channel_stack), - client_idle_timeout_(client_idle_timeout) {} - grpc_channel_stack* channel_stack() { return channel_stack_; }; virtual void Shutdown(); @@ -94,10 +94,9 @@ class LegacyClientIdleFilter final : public LegacyChannelIdleFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); - private: using LegacyChannelIdleFilter::LegacyChannelIdleFilter; }; @@ -106,9 +105,12 @@ class LegacyMaxAgeFilter final : public LegacyChannelIdleFilter { static const grpc_channel_filter kFilter; struct Config; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + LegacyMaxAgeFilter(grpc_channel_stack* channel_stack, + const Config& max_age_config); + void PostInit() override; private: @@ -128,9 +130,6 @@ class LegacyMaxAgeFilter final : public LegacyChannelIdleFilter { LegacyMaxAgeFilter* filter_; }; - LegacyMaxAgeFilter(grpc_channel_stack* channel_stack, - const Config& max_age_config); - void Shutdown() override; SingleSetActivityPtr max_age_activity_; diff --git a/src/core/ext/filters/fault_injection/fault_injection_filter.cc b/src/core/ext/filters/fault_injection/fault_injection_filter.cc index 2464d01d7db..87d5a4d2f1f 100644 --- a/src/core/ext/filters/fault_injection/fault_injection_filter.cc +++ b/src/core/ext/filters/fault_injection/fault_injection_filter.cc @@ -29,6 +29,7 @@ #include "absl/meta/type_traits.h" #include "absl/status/status.h" +#include "absl/status/statusor.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -135,16 +136,16 @@ class FaultInjectionFilter::InjectionDecision { FaultHandle active_fault_{false}; }; -absl::StatusOr FaultInjectionFilter::Create( - const ChannelArgs&, ChannelFilter::Args filter_args) { - return FaultInjectionFilter(filter_args); +absl::StatusOr> +FaultInjectionFilter::Create(const ChannelArgs&, + ChannelFilter::Args filter_args) { + return std::make_unique(filter_args); } FaultInjectionFilter::FaultInjectionFilter(ChannelFilter::Args filter_args) : index_(filter_args.instance_id()), service_config_parser_index_( - FaultInjectionServiceConfigParser::ParserIndex()), - mu_(new Mutex) {} + FaultInjectionServiceConfigParser::ParserIndex()) {} // Construct a promise for one call. ArenaPromise FaultInjectionFilter::Call::OnClientInitialMetadata( @@ -226,7 +227,7 @@ FaultInjectionFilter::MakeInjectionDecision( bool delay_request = delay != Duration::Zero(); bool abort_request = abort_code != GRPC_STATUS_OK; if (delay_request || abort_request) { - MutexLock lock(mu_.get()); + MutexLock lock(&mu_); if (delay_request) { delay_request = UnderFraction(&delay_rand_generator_, delay_percentage_numerator, diff --git a/src/core/ext/filters/fault_injection/fault_injection_filter.h b/src/core/ext/filters/fault_injection/fault_injection_filter.h index e2918e854f5..b6b1b811cde 100644 --- a/src/core/ext/filters/fault_injection/fault_injection_filter.h +++ b/src/core/ext/filters/fault_injection/fault_injection_filter.h @@ -45,9 +45,11 @@ class FaultInjectionFilter public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit FaultInjectionFilter(ChannelFilter::Args filter_args); + // Construct a promise for one call. class Call { public: @@ -61,8 +63,6 @@ class FaultInjectionFilter }; private: - explicit FaultInjectionFilter(ChannelFilter::Args filter_args); - class InjectionDecision; InjectionDecision MakeInjectionDecision( const ClientMetadata& initial_metadata); @@ -70,7 +70,7 @@ class FaultInjectionFilter // The relative index of instances of the same filter. size_t index_; const size_t service_config_parser_index_; - std::unique_ptr mu_; + Mutex mu_; absl::InsecureBitGen abort_rand_generator_ ABSL_GUARDED_BY(mu_); absl::InsecureBitGen delay_rand_generator_ ABSL_GUARDED_BY(mu_); }; diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index ac8004cdd3e..390df545efe 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -27,6 +27,7 @@ #include #include "absl/status/status.h" +#include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" @@ -136,16 +137,16 @@ HttpClientFilter::HttpClientFilter(HttpSchemeMetadata::ValueType scheme, Slice user_agent, bool test_only_use_put_requests) : scheme_(scheme), - user_agent_(std::move(user_agent)), - test_only_use_put_requests_(test_only_use_put_requests) {} + test_only_use_put_requests_(test_only_use_put_requests), + user_agent_(std::move(user_agent)) {} -absl::StatusOr HttpClientFilter::Create( +absl::StatusOr> HttpClientFilter::Create( const ChannelArgs& args, ChannelFilter::Args) { auto* transport = args.GetObject(); if (transport == nullptr) { return absl::InvalidArgumentError("HttpClientFilter needs a transport"); } - return HttpClientFilter( + return std::make_unique( SchemeFromArgs(args), UserAgentFromArgs(args, transport->GetTransportName()), args.GetInt(GRPC_ARG_TEST_ONLY_USE_PUT_REQUESTS).value_or(false)); diff --git a/src/core/ext/filters/http/client/http_client_filter.h b/src/core/ext/filters/http/client/http_client_filter.h index dbfa9f7f2d0..f5d7875da5e 100644 --- a/src/core/ext/filters/http/client/http_client_filter.h +++ b/src/core/ext/filters/http/client/http_client_filter.h @@ -35,9 +35,12 @@ class HttpClientFilter : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + HttpClientFilter(HttpSchemeMetadata::ValueType scheme, Slice user_agent, + bool test_only_use_put_requests); + class Call { public: void OnClientInitialMetadata(ClientMetadata& md, HttpClientFilter* filter); @@ -49,12 +52,9 @@ class HttpClientFilter : public ImplementChannelFilter { }; private: - HttpClientFilter(HttpSchemeMetadata::ValueType scheme, Slice user_agent, - bool test_only_use_put_requests); - HttpSchemeMetadata::ValueType scheme_; - Slice user_agent_; bool test_only_use_put_requests_; + Slice user_agent_; }; // A test-only channel arg to allow testing gRPC Core server behavior on PUT diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 3df6d275f6a..1d5258493e4 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -43,8 +43,8 @@ const NoInterceptor ClientAuthorityFilter::Call::OnClientToServerMessage; const NoInterceptor ClientAuthorityFilter::Call::OnServerToClientMessage; const NoInterceptor ClientAuthorityFilter::Call::OnFinalize; -absl::StatusOr ClientAuthorityFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { +absl::StatusOr> +ClientAuthorityFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { absl::optional default_authority = args.GetString(GRPC_ARG_DEFAULT_AUTHORITY); if (!default_authority.has_value()) { @@ -52,7 +52,8 @@ absl::StatusOr ClientAuthorityFilter::Create( "GRPC_ARG_DEFAULT_AUTHORITY string channel arg. not found. Note that " "direct channels must explicitly specify a value for this argument."); } - return ClientAuthorityFilter(Slice::FromCopiedString(*default_authority)); + return std::make_unique( + Slice::FromCopiedString(*default_authority)); } void ClientAuthorityFilter::Call::OnClientInitialMetadata( diff --git a/src/core/ext/filters/http/client_authority_filter.h b/src/core/ext/filters/http/client_authority_filter.h index 064e0a0a450..44229c6cdde 100644 --- a/src/core/ext/filters/http/client_authority_filter.h +++ b/src/core/ext/filters/http/client_authority_filter.h @@ -39,8 +39,11 @@ class ClientAuthorityFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args); + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args); + + explicit ClientAuthorityFilter(Slice default_authority) + : default_authority_(std::move(default_authority)) {} class Call { public: @@ -54,8 +57,6 @@ class ClientAuthorityFilter final }; private: - explicit ClientAuthorityFilter(Slice default_authority) - : default_authority_(std::move(default_authority)) {} Slice default_authority_; }; diff --git a/src/core/ext/filters/http/message_compress/compression_filter.cc b/src/core/ext/filters/http/message_compress/compression_filter.cc index c9b3acaf1f7..1ad6081ffac 100644 --- a/src/core/ext/filters/http/message_compress/compression_filter.cc +++ b/src/core/ext/filters/http/message_compress/compression_filter.cc @@ -72,14 +72,14 @@ const grpc_channel_filter ServerCompressionFilter::kFilter = kFilterExaminesInboundMessages | kFilterExaminesOutboundMessages>("compression"); -absl::StatusOr ClientCompressionFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { - return ClientCompressionFilter(args); +absl::StatusOr> +ClientCompressionFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { + return std::make_unique(args); } -absl::StatusOr ServerCompressionFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { - return ServerCompressionFilter(args); +absl::StatusOr> +ServerCompressionFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { + return std::make_unique(args); } ChannelCompression::ChannelCompression(const ChannelArgs& args) diff --git a/src/core/ext/filters/http/message_compress/compression_filter.h b/src/core/ext/filters/http/message_compress/compression_filter.h index adf9fb49355..99e57a0ac1d 100644 --- a/src/core/ext/filters/http/message_compress/compression_filter.h +++ b/src/core/ext/filters/http/message_compress/compression_filter.h @@ -110,9 +110,12 @@ class ClientCompressionFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit ClientCompressionFilter(const ChannelArgs& args) + : compression_engine_(args) {} + // Construct a promise for one call. class Call { public: @@ -135,9 +138,6 @@ class ClientCompressionFilter final }; private: - explicit ClientCompressionFilter(const ChannelArgs& args) - : compression_engine_(args) {} - ChannelCompression compression_engine_; }; @@ -146,9 +146,12 @@ class ServerCompressionFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit ServerCompressionFilter(const ChannelArgs& args) + : compression_engine_(args) {} + // Construct a promise for one call. class Call { public: @@ -171,9 +174,6 @@ class ServerCompressionFilter final }; private: - explicit ServerCompressionFilter(const ChannelArgs& args) - : compression_engine_(args) {} - ChannelCompression compression_engine_; }; diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 775eebcb1d3..925cc73c23e 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -152,9 +152,9 @@ void HttpServerFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) { FilterOutgoingMetadata(&md); } -absl::StatusOr HttpServerFilter::Create( +absl::StatusOr> HttpServerFilter::Create( const ChannelArgs& args, ChannelFilter::Args) { - return HttpServerFilter( + return std::make_unique( args.GetBool(GRPC_ARG_SURFACE_USER_AGENT).value_or(true), args.GetBool( GRPC_ARG_DO_NOT_USE_UNLESS_YOU_HAVE_PERMISSION_FROM_GRPC_TEAM_ALLOW_BROKEN_PUT_REQUESTS) diff --git a/src/core/ext/filters/http/server/http_server_filter.h b/src/core/ext/filters/http/server/http_server_filter.h index a87c83518ee..282973ddecd 100644 --- a/src/core/ext/filters/http/server/http_server_filter.h +++ b/src/core/ext/filters/http/server/http_server_filter.h @@ -36,9 +36,13 @@ class HttpServerFilter : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + HttpServerFilter(bool surface_user_agent, bool allow_put_requests) + : surface_user_agent_(surface_user_agent), + allow_put_requests_(allow_put_requests) {} + class Call { public: ServerMetadataHandle OnClientInitialMetadata(ClientMetadata& md, @@ -51,10 +55,6 @@ class HttpServerFilter : public ImplementChannelFilter { }; private: - HttpServerFilter(bool surface_user_agent, bool allow_put_requests) - : surface_user_agent_(surface_user_agent), - allow_put_requests_(allow_put_requests) {} - bool surface_user_agent_; bool allow_put_requests_; }; diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index 624ca70e79e..7937ab6fe74 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -76,10 +76,11 @@ const NoInterceptor ServerLoadReportingFilter::Call::OnServerInitialMetadata; const NoInterceptor ServerLoadReportingFilter::Call::OnClientToServerMessage; const NoInterceptor ServerLoadReportingFilter::Call::OnServerToClientMessage; -absl::StatusOr ServerLoadReportingFilter::Create( - const ChannelArgs& channel_args, ChannelFilter::Args) { +absl::StatusOr> +ServerLoadReportingFilter::Create(const ChannelArgs& channel_args, + ChannelFilter::Args) { // Find and record the peer_identity. - ServerLoadReportingFilter filter; + auto filter = std::make_unique(); const auto* auth_context = channel_args.GetObject(); if (auth_context != nullptr && grpc_auth_context_peer_is_authenticated(auth_context)) { @@ -88,7 +89,7 @@ absl::StatusOr ServerLoadReportingFilter::Create( const grpc_auth_property* auth_property = grpc_auth_property_iterator_next(&auth_it); if (auth_property != nullptr) { - filter.peer_identity_ = + filter->peer_identity_ = std::string(auth_property->value, auth_property->value_length); } } diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.h b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h index ddb8d0f2482..f11c8c38bcf 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h @@ -39,7 +39,7 @@ class ServerLoadReportingFilter public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args); // Getters. diff --git a/src/core/ext/filters/logging/logging_filter.cc b/src/core/ext/filters/logging/logging_filter.cc index 89fe46bcb66..1c76e64b06a 100644 --- a/src/core/ext/filters/logging/logging_filter.cc +++ b/src/core/ext/filters/logging/logging_filter.cc @@ -342,21 +342,23 @@ class CallData { } // namespace -absl::StatusOr ClientLoggingFilter::Create( - const ChannelArgs& args, ChannelFilter::Args /*filter_args*/) { +absl::StatusOr> +ClientLoggingFilter::Create(const ChannelArgs& args, + ChannelFilter::Args /*filter_args*/) { absl::optional default_authority = args.GetString(GRPC_ARG_DEFAULT_AUTHORITY); if (default_authority.has_value()) { - return ClientLoggingFilter(std::string(default_authority.value())); + return std::make_unique( + std::string(default_authority.value())); } absl::optional server_uri = args.GetOwnedString(GRPC_ARG_SERVER_URI); if (server_uri.has_value()) { - return ClientLoggingFilter( + return std::make_unique( CoreConfiguration::Get().resolver_registry().GetDefaultAuthority( *server_uri)); } - return ClientLoggingFilter(""); + return std::make_unique(""); } // Construct a promise for one call. @@ -445,9 +447,10 @@ const grpc_channel_filter ClientLoggingFilter::kFilter = kFilterExaminesInboundMessages | kFilterExaminesOutboundMessages>("logging"); -absl::StatusOr ServerLoggingFilter::Create( - const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/) { - return ServerLoggingFilter(); +absl::StatusOr> +ServerLoggingFilter::Create(const ChannelArgs& /*args*/, + ChannelFilter::Args /*filter_args*/) { + return std::make_unique(); } // Construct a promise for one call. diff --git a/src/core/ext/filters/logging/logging_filter.h b/src/core/ext/filters/logging/logging_filter.h index 6a27a653860..7d42abbc337 100644 --- a/src/core/ext/filters/logging/logging_filter.h +++ b/src/core/ext/filters/logging/logging_filter.h @@ -39,24 +39,25 @@ class ClientLoggingFilter final : public ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args /*filter_args*/); + explicit ClientLoggingFilter(std::string default_authority) + : default_authority_(std::move(default_authority)) {} + // Construct a promise for one call. ArenaPromise MakeCallPromise( CallArgs call_args, NextPromiseFactory next_promise_factory) override; private: - explicit ClientLoggingFilter(std::string default_authority) - : default_authority_(std::move(default_authority)) {} - std::string default_authority_; + const std::string default_authority_; }; class ServerLoggingFilter final : public ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args /*filter_args*/); // Construct a promise for one call. diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index d975282432a..379d4944788 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -25,7 +25,6 @@ #include "absl/strings/str_format.h" -#include #include #include #include @@ -142,19 +141,20 @@ const grpc_channel_filter ClientMessageSizeFilter::kFilter = MakePromiseBasedFilter("message_size"); + const grpc_channel_filter ServerMessageSizeFilter::kFilter = MakePromiseBasedFilter("message_size"); -absl::StatusOr ClientMessageSizeFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { - return ClientMessageSizeFilter(args); +absl::StatusOr> +ClientMessageSizeFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { + return std::make_unique(args); } -absl::StatusOr ServerMessageSizeFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { - return ServerMessageSizeFilter(args); +absl::StatusOr> +ServerMessageSizeFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { + return std::make_unique(args); } namespace { diff --git a/src/core/ext/filters/message_size/message_size_filter.h b/src/core/ext/filters/message_size/message_size_filter.h index 3a9ea1f2064..89d21201a5c 100644 --- a/src/core/ext/filters/message_size/message_size_filter.h +++ b/src/core/ext/filters/message_size/message_size_filter.h @@ -91,9 +91,12 @@ class ServerMessageSizeFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit ServerMessageSizeFilter(const ChannelArgs& args) + : parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {} + class Call { public: static const NoInterceptor OnClientInitialMetadata; @@ -107,8 +110,6 @@ class ServerMessageSizeFilter final }; private: - explicit ServerMessageSizeFilter(const ChannelArgs& args) - : parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {} const MessageSizeParsedConfig parsed_config_; }; @@ -117,9 +118,12 @@ class ClientMessageSizeFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit ClientMessageSizeFilter(const ChannelArgs& args) + : parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {} + class Call { public: explicit Call(ClientMessageSizeFilter* filter); @@ -136,8 +140,6 @@ class ClientMessageSizeFilter final }; private: - explicit ClientMessageSizeFilter(const ChannelArgs& args) - : parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {} const size_t service_config_parser_index_{MessageSizeParser::ParserIndex()}; const MessageSizeParsedConfig parsed_config_; }; diff --git a/src/core/ext/filters/rbac/rbac_filter.cc b/src/core/ext/filters/rbac/rbac_filter.cc index 68c5e3d7699..7c75f46ae7d 100644 --- a/src/core/ext/filters/rbac/rbac_filter.cc +++ b/src/core/ext/filters/rbac/rbac_filter.cc @@ -82,14 +82,21 @@ RbacFilter::RbacFilter(size_t index, service_config_parser_index_(RbacServiceConfigParser::ParserIndex()), per_channel_evaluate_args_(std::move(per_channel_evaluate_args)) {} -absl::StatusOr RbacFilter::Create(const ChannelArgs& args, - ChannelFilter::Args filter_args) { +absl::StatusOr> RbacFilter::Create( + const ChannelArgs& args, ChannelFilter::Args filter_args) { auto* auth_context = args.GetObject(); if (auth_context == nullptr) { return GRPC_ERROR_CREATE("No auth context found"); } - return RbacFilter(filter_args.instance_id(), - EvaluateArgs::PerChannelArgs(auth_context, args)); + auto* transport = args.GetObject(); + if (transport == nullptr) { + // This should never happen since the transport is always set on the server + // side. + return GRPC_ERROR_CREATE("No transport configured"); + } + return std::make_unique( + filter_args.instance_id(), + EvaluateArgs::PerChannelArgs(auth_context, args)); } void RbacFilterRegister(CoreConfiguration::Builder* builder) { diff --git a/src/core/ext/filters/rbac/rbac_filter.h b/src/core/ext/filters/rbac/rbac_filter.h index f2208753b6b..a4c41cbdd0b 100644 --- a/src/core/ext/filters/rbac/rbac_filter.h +++ b/src/core/ext/filters/rbac/rbac_filter.h @@ -42,8 +42,11 @@ class RbacFilter : public ImplementChannelFilter { // and enforces the RBAC policy. static const grpc_channel_filter kFilterVtable; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args filter_args); + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args filter_args); + + RbacFilter(size_t index, + EvaluateArgs::PerChannelArgs per_channel_evaluate_args); class Call { public: @@ -57,9 +60,6 @@ class RbacFilter : public ImplementChannelFilter { }; private: - RbacFilter(size_t index, - EvaluateArgs::PerChannelArgs per_channel_evaluate_args); - // The index of this filter instance among instances of the same filter. size_t index_; // Assigned index for service config data from the parser. diff --git a/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc b/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc index 0be80a238a0..0d37c5c646c 100644 --- a/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +++ b/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc @@ -49,19 +49,22 @@ namespace grpc_core { namespace { class ServerConfigSelectorFilter final - : public ImplementChannelFilter { + : public ImplementChannelFilter, + public InternallyRefCounted { public: - ~ServerConfigSelectorFilter() override; + explicit ServerConfigSelectorFilter( + RefCountedPtr + server_config_selector_provider); ServerConfigSelectorFilter(const ServerConfigSelectorFilter&) = delete; ServerConfigSelectorFilter& operator=(const ServerConfigSelectorFilter&) = delete; - ServerConfigSelectorFilter(ServerConfigSelectorFilter&&) = default; - ServerConfigSelectorFilter& operator=(ServerConfigSelectorFilter&&) = default; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args); + void Orphan() override; + class Call { public: absl::Status OnClientInitialMetadata(ClientMetadata& md, @@ -74,70 +77,66 @@ class ServerConfigSelectorFilter final }; absl::StatusOr> config_selector() { - MutexLock lock(&state_->mu); - return state_->config_selector.value(); + MutexLock lock(&mu_); + return config_selector_.value(); } private: - struct State { - Mutex mu; - absl::optional>> - config_selector ABSL_GUARDED_BY(mu); - }; class ServerConfigSelectorWatcher : public ServerConfigSelectorProvider::ServerConfigSelectorWatcher { public: - explicit ServerConfigSelectorWatcher(std::shared_ptr state) - : state_(state) {} + explicit ServerConfigSelectorWatcher( + RefCountedPtr filter) + : filter_(filter) {} void OnServerConfigSelectorUpdate( absl::StatusOr> update) override { - MutexLock lock(&state_->mu); - state_->config_selector = std::move(update); + MutexLock lock(&filter_->mu_); + filter_->config_selector_ = std::move(update); } private: - std::shared_ptr state_; + RefCountedPtr filter_; }; - explicit ServerConfigSelectorFilter( - RefCountedPtr - server_config_selector_provider); - RefCountedPtr server_config_selector_provider_; - std::shared_ptr state_; + Mutex mu_; + absl::optional>> + config_selector_ ABSL_GUARDED_BY(mu_); }; -absl::StatusOr ServerConfigSelectorFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { +absl::StatusOr> +ServerConfigSelectorFilter::Create(const ChannelArgs& args, + ChannelFilter::Args) { ServerConfigSelectorProvider* server_config_selector_provider = args.GetObject(); if (server_config_selector_provider == nullptr) { return absl::UnknownError("No ServerConfigSelectorProvider object found"); } - return ServerConfigSelectorFilter(server_config_selector_provider->Ref()); + return MakeOrphanable( + server_config_selector_provider->Ref()); } ServerConfigSelectorFilter::ServerConfigSelectorFilter( RefCountedPtr server_config_selector_provider) : server_config_selector_provider_( - std::move(server_config_selector_provider)), - state_(std::make_shared()) { + std::move(server_config_selector_provider)) { GPR_ASSERT(server_config_selector_provider_ != nullptr); auto server_config_selector_watcher = - std::make_unique(state_); + std::make_unique(Ref()); auto config_selector = server_config_selector_provider_->Watch( std::move(server_config_selector_watcher)); - MutexLock lock(&state_->mu); + MutexLock lock(&mu_); // It's possible for the watcher to have already updated config_selector_ - if (!state_->config_selector.has_value()) { - state_->config_selector = std::move(config_selector); + if (!config_selector_.has_value()) { + config_selector_ = std::move(config_selector); } } -ServerConfigSelectorFilter::~ServerConfigSelectorFilter() { +void ServerConfigSelectorFilter::Orphan() { if (server_config_selector_provider_ != nullptr) { server_config_selector_provider_->CancelWatch(); } + Unref(); } absl::Status ServerConfigSelectorFilter::Call::OnClientInitialMetadata( diff --git a/src/core/ext/filters/stateful_session/stateful_session_filter.cc b/src/core/ext/filters/stateful_session/stateful_session_filter.cc index 9345edeed7d..b64affbb61f 100644 --- a/src/core/ext/filters/stateful_session/stateful_session_filter.cc +++ b/src/core/ext/filters/stateful_session/stateful_session_filter.cc @@ -72,9 +72,10 @@ const grpc_channel_filter StatefulSessionFilter::kFilter = kFilterExaminesServerInitialMetadata>( "stateful_session_filter"); -absl::StatusOr StatefulSessionFilter::Create( - const ChannelArgs&, ChannelFilter::Args filter_args) { - return StatefulSessionFilter(filter_args); +absl::StatusOr> +StatefulSessionFilter::Create(const ChannelArgs&, + ChannelFilter::Args filter_args) { + return std::make_unique(filter_args); } StatefulSessionFilter::StatefulSessionFilter(ChannelFilter::Args filter_args) diff --git a/src/core/ext/filters/stateful_session/stateful_session_filter.h b/src/core/ext/filters/stateful_session/stateful_session_filter.h index 1fc27e1508b..5cd534843aa 100644 --- a/src/core/ext/filters/stateful_session/stateful_session_filter.h +++ b/src/core/ext/filters/stateful_session/stateful_session_filter.h @@ -74,9 +74,11 @@ class StatefulSessionFilter public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); + explicit StatefulSessionFilter(ChannelFilter::Args filter_args); + class Call { public: void OnClientInitialMetadata(ClientMetadata& md, @@ -97,7 +99,6 @@ class StatefulSessionFilter }; private: - explicit StatefulSessionFilter(ChannelFilter::Args filter_args); // The relative index of instances of the same filter. const size_t index_; // Index of the service config parser. diff --git a/src/core/lib/channel/promise_based_filter.cc b/src/core/lib/channel/promise_based_filter.cc index 746e171334b..9e47aacae55 100644 --- a/src/core/lib/channel/promise_based_filter.cc +++ b/src/core/lib/channel/promise_based_filter.cc @@ -106,7 +106,7 @@ BaseCallData::BaseCallData( ? arena_->New(this, make_recv_interceptor()) : nullptr), event_engine_( - static_cast(elem->channel_data) + ChannelFilterFromElem(elem) ->hack_until_per_channel_stack_event_engines_land_get_event_engine()) { } @@ -1572,7 +1572,7 @@ void ClientCallData::Cancel(grpc_error_handle error, Flusher* flusher) { // metadata and return some trailing metadata. void ClientCallData::StartPromise(Flusher* flusher) { GPR_ASSERT(send_initial_state_ == SendInitialState::kQueued); - ChannelFilter* filter = static_cast(elem()->channel_data); + ChannelFilter* filter = promise_filter_detail::ChannelFilterFromElem(elem()); // Construct the promise. PollContext ctx(this, flusher); @@ -2369,7 +2369,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) { // Start the promise. ScopedContext context(this); // Construct the promise. - ChannelFilter* filter = static_cast(elem()->channel_data); + ChannelFilter* filter = promise_filter_detail::ChannelFilterFromElem(elem()); FakeActivity(this).Run([this, filter] { promise_ = filter->MakeCallPromise( CallArgs{WrapMetadata(recv_initial_metadata_), diff --git a/src/core/lib/channel/promise_based_filter.h b/src/core/lib/channel/promise_based_filter.h index 347f2004b8c..491cbe9c144 100644 --- a/src/core/lib/channel/promise_based_filter.h +++ b/src/core/lib/channel/promise_based_filter.h @@ -1841,6 +1841,15 @@ struct BaseCallDataMethods { } }; +// The type of object returned by a filter's Create method. +template +using CreatedType = typename decltype(T::Create(ChannelArgs(), {}))::value_type; + +template +inline ChannelFilter* ChannelFilterFromElem(GrpcChannelOrCallElement* elem) { + return *static_cast(elem->channel_data); +} + template struct CallDataFilterWithFlagsMethods { static absl::Status InitCallElem(grpc_call_element* elem, @@ -1865,32 +1874,25 @@ struct ChannelFilterMethods { static ArenaPromise MakeCallPromise( grpc_channel_element* elem, CallArgs call_args, NextPromiseFactory next_promise_factory) { - return static_cast(elem->channel_data) - ->MakeCallPromise(std::move(call_args), - std::move(next_promise_factory)); + return ChannelFilterFromElem(elem)->MakeCallPromise( + std::move(call_args), std::move(next_promise_factory)); } static void StartTransportOp(grpc_channel_element* elem, grpc_transport_op* op) { - if (!static_cast(elem->channel_data) - ->StartTransportOp(op)) { + if (!ChannelFilterFromElem(elem)->StartTransportOp(op)) { grpc_channel_next_op(elem, op); } } static void PostInitChannelElem(grpc_channel_stack*, grpc_channel_element* elem) { - static_cast(elem->channel_data)->PostInit(); - } - - static void DestroyChannelElem(grpc_channel_element* elem) { - static_cast(elem->channel_data)->~ChannelFilter(); + ChannelFilterFromElem(elem)->PostInit(); } static void GetChannelInfo(grpc_channel_element* elem, const grpc_channel_info* info) { - if (!static_cast(elem->channel_data) - ->GetChannelInfo(info)) { + if (!ChannelFilterFromElem(elem)->GetChannelInfo(info)) { grpc_channel_next_get_info(elem, info); } } @@ -1904,15 +1906,16 @@ struct ChannelFilterWithFlagsMethods { auto status = F::Create(args->channel_args, ChannelFilter::Args(args->channel_stack, elem)); if (!status.ok()) { - static_assert( - sizeof(promise_filter_detail::InvalidChannelFilter) <= sizeof(F), - "InvalidChannelFilter must fit in F"); - new (elem->channel_data) promise_filter_detail::InvalidChannelFilter(); + new (elem->channel_data) F*(nullptr); return absl_status_to_grpc_error(status.status()); } - new (elem->channel_data) F(std::move(*status)); + new (elem->channel_data) F*(status->release()); return absl::OkStatus(); } + + static void DestroyChannelElem(grpc_channel_element* elem) { + CreatedType channel_elem(DownCast(ChannelFilterFromElem(elem))); + } }; } // namespace promise_filter_detail @@ -1958,7 +1961,8 @@ MakePromiseBasedFilter(const char* name) { // post_init_channel_elem promise_filter_detail::ChannelFilterMethods::PostInitChannelElem, // destroy_channel_elem - promise_filter_detail::ChannelFilterMethods::DestroyChannelElem, + promise_filter_detail::ChannelFilterWithFlagsMethods< + F, kFlags>::DestroyChannelElem, // get_channel_info promise_filter_detail::ChannelFilterMethods::GetChannelInfo, // name @@ -2004,7 +2008,8 @@ MakePromiseBasedFilter(const char* name) { // post_init_channel_elem promise_filter_detail::ChannelFilterMethods::PostInitChannelElem, // destroy_channel_elem - promise_filter_detail::ChannelFilterMethods::DestroyChannelElem, + promise_filter_detail::ChannelFilterWithFlagsMethods< + F, kFlags>::DestroyChannelElem, // get_channel_info promise_filter_detail::ChannelFilterMethods::GetChannelInfo, // name @@ -2046,7 +2051,8 @@ MakePromiseBasedFilter(const char* name) { // post_init_channel_elem promise_filter_detail::ChannelFilterMethods::PostInitChannelElem, // destroy_channel_elem - promise_filter_detail::ChannelFilterMethods::DestroyChannelElem, + promise_filter_detail::ChannelFilterWithFlagsMethods< + F, kFlags>::DestroyChannelElem, // get_channel_info promise_filter_detail::ChannelFilterMethods::GetChannelInfo, // name diff --git a/src/core/lib/channel/server_call_tracer_filter.cc b/src/core/lib/channel/server_call_tracer_filter.cc index 982f160468e..5effe8f8538 100644 --- a/src/core/lib/channel/server_call_tracer_filter.cc +++ b/src/core/lib/channel/server_call_tracer_filter.cc @@ -17,6 +17,7 @@ #include "src/core/lib/channel/server_call_tracer_filter.h" #include +#include #include #include "absl/status/status.h" @@ -49,7 +50,7 @@ class ServerCallTracerFilter public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/); class Call { @@ -98,9 +99,10 @@ const grpc_channel_filter ServerCallTracerFilter::kFilter = kFilterExaminesServerInitialMetadata>( "server_call_tracer"); -absl::StatusOr ServerCallTracerFilter::Create( - const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/) { - return ServerCallTracerFilter(); +absl::StatusOr> +ServerCallTracerFilter::Create(const ChannelArgs& /*args*/, + ChannelFilter::Args /*filter_args*/) { + return std::make_unique(); } } // namespace diff --git a/src/core/lib/security/authorization/grpc_server_authz_filter.cc b/src/core/lib/security/authorization/grpc_server_authz_filter.cc index 199c0a8fa5b..5474847701a 100644 --- a/src/core/lib/security/authorization/grpc_server_authz_filter.cc +++ b/src/core/lib/security/authorization/grpc_server_authz_filter.cc @@ -51,14 +51,14 @@ GrpcServerAuthzFilter::GrpcServerAuthzFilter( per_channel_evaluate_args_(auth_context_.get(), args), provider_(std::move(provider)) {} -absl::StatusOr GrpcServerAuthzFilter::Create( - const ChannelArgs& args, ChannelFilter::Args) { +absl::StatusOr> +GrpcServerAuthzFilter::Create(const ChannelArgs& args, ChannelFilter::Args) { auto* auth_context = args.GetObject(); auto* provider = args.GetObject(); if (provider == nullptr) { return absl::InvalidArgumentError("Failed to get authorization provider."); } - return GrpcServerAuthzFilter( + return std::make_unique( auth_context != nullptr ? auth_context->Ref() : nullptr, args, provider->Ref()); } diff --git a/src/core/lib/security/authorization/grpc_server_authz_filter.h b/src/core/lib/security/authorization/grpc_server_authz_filter.h index fd29197a3bf..b4b0a7463cd 100644 --- a/src/core/lib/security/authorization/grpc_server_authz_filter.h +++ b/src/core/lib/security/authorization/grpc_server_authz_filter.h @@ -37,8 +37,12 @@ class GrpcServerAuthzFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args); + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args); + + GrpcServerAuthzFilter( + RefCountedPtr auth_context, const ChannelArgs& args, + RefCountedPtr provider); class Call { public: @@ -52,10 +56,6 @@ class GrpcServerAuthzFilter final }; private: - GrpcServerAuthzFilter( - RefCountedPtr auth_context, const ChannelArgs& args, - RefCountedPtr provider); - bool IsAuthorized(ClientMetadata& initial_metadata); RefCountedPtr auth_context_; diff --git a/src/core/lib/security/transport/auth_filters.h b/src/core/lib/security/transport/auth_filters.h index e4e80909526..ced5319bb55 100644 --- a/src/core/lib/security/transport/auth_filters.h +++ b/src/core/lib/security/transport/auth_filters.h @@ -42,18 +42,18 @@ class ClientAuthFilter final : public ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args); + ClientAuthFilter( + RefCountedPtr security_connector, + RefCountedPtr auth_context); + + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args); // Construct a promise for one call. ArenaPromise MakeCallPromise( CallArgs call_args, NextPromiseFactory next_promise_factory) override; private: - ClientAuthFilter( - RefCountedPtr security_connector, - RefCountedPtr auth_context); - ArenaPromise> GetCallCredsMetadata( CallArgs call_args); @@ -63,9 +63,6 @@ class ClientAuthFilter final : public ChannelFilter { class ServerAuthFilter final : public ImplementChannelFilter { private: - ServerAuthFilter(RefCountedPtr server_credentials, - RefCountedPtr auth_context); - class RunApplicationCode { public: RunApplicationCode(ServerAuthFilter* filter, ClientMetadata& metadata); @@ -98,8 +95,11 @@ class ServerAuthFilter final : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create(const ChannelArgs& args, - ChannelFilter::Args); + ServerAuthFilter(RefCountedPtr server_credentials, + RefCountedPtr auth_context); + + static absl::StatusOr> Create( + const ChannelArgs& args, ChannelFilter::Args); class Call { public: diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 1840522e6c7..400087dcedd 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -203,7 +203,7 @@ ArenaPromise ClientAuthFilter::MakeCallPromise( next_promise_factory); } -absl::StatusOr ClientAuthFilter::Create( +absl::StatusOr> ClientAuthFilter::Create( const ChannelArgs& args, ChannelFilter::Args) { auto* sc = args.GetObject(); if (sc == nullptr) { @@ -215,8 +215,9 @@ absl::StatusOr ClientAuthFilter::Create( return absl::InvalidArgumentError( "Auth context missing from client auth filter args"); } - return ClientAuthFilter(sc->RefAsSubclass(), - auth_context->Ref()); + return std::make_unique( + sc->RefAsSubclass(), + auth_context->Ref()); } const grpc_channel_filter ClientAuthFilter::kFilter = diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 0354398684a..f2e403b329f 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -212,12 +212,13 @@ ServerAuthFilter::ServerAuthFilter( RefCountedPtr auth_context) : server_credentials_(server_credentials), auth_context_(auth_context) {} -absl::StatusOr ServerAuthFilter::Create( +absl::StatusOr> ServerAuthFilter::Create( const ChannelArgs& args, ChannelFilter::Args) { auto auth_context = args.GetObjectRef(); GPR_ASSERT(auth_context != nullptr); auto creds = args.GetObjectRef(); - return ServerAuthFilter(std::move(creds), std::move(auth_context)); + return std::make_unique(std::move(creds), + std::move(auth_context)); } } // namespace grpc_core diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h index 48de857f76d..5f1bacdeff1 100644 --- a/src/core/lib/surface/channel_init.h +++ b/src/core/lib/surface/channel_init.h @@ -285,6 +285,11 @@ class ChannelInit { grpc_channel_stack_type type, const ChannelArgs& args) const; private: + // The type of object returned by a filter's Create method. + template + using CreatedType = + typename decltype(T::Create(ChannelArgs(), {}))::value_type; + struct Filter { Filter(const grpc_channel_filter* filter, const ChannelFilterVtable* vtable, std::vector predicates, bool skip_v3, @@ -328,17 +333,17 @@ class ChannelInit { template const ChannelInit::ChannelFilterVtable ChannelInit::VtableForType>::kVtable = { - sizeof(T), alignof(T), + sizeof(CreatedType), alignof(CreatedType), [](void* data, const ChannelArgs& args) -> absl::Status { // TODO(ctiller): fill in ChannelFilter::Args (2nd arg) - absl::StatusOr r = T::Create(args, {}); + absl::StatusOr> r = T::Create(args, {}); if (!r.ok()) return r.status(); - new (data) T(std::move(*r)); + new (data) CreatedType(std::move(*r)); return absl::OkStatus(); }, - [](void* data) { static_cast(data)->~T(); }, + [](void* data) { Destruct(static_cast*>(data)); }, [](void* data, CallFilters::StackBuilder& builder) { - builder.Add(static_cast(data)); + builder.Add(static_cast*>(data)->get()); }}; } // namespace grpc_core diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index ce8a4ea1880..8966f34ebf7 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -59,17 +59,15 @@ const grpc_channel_filter LameClientFilter::kFilter = MakePromiseBasedFilter("lame-client"); -absl::StatusOr LameClientFilter::Create( +absl::StatusOr> LameClientFilter::Create( const ChannelArgs& args, ChannelFilter::Args) { - return LameClientFilter( + return std::make_unique( *args.GetPointer(GRPC_ARG_LAME_FILTER_ERROR)); } LameClientFilter::LameClientFilter(absl::Status error) - : error_(std::move(error)), state_(std::make_unique()) {} - -LameClientFilter::State::State() - : state_tracker("lame_client", GRPC_CHANNEL_SHUTDOWN) {} + : error_(std::move(error)), + state_tracker_("lame_client", GRPC_CHANNEL_SHUTDOWN) {} ArenaPromise LameClientFilter::MakeCallPromise( CallArgs args, NextPromiseFactory) { @@ -92,13 +90,13 @@ bool LameClientFilter::GetChannelInfo(const grpc_channel_info*) { return true; } bool LameClientFilter::StartTransportOp(grpc_transport_op* op) { { - MutexLock lock(&state_->mu); + MutexLock lock(&mu_); if (op->start_connectivity_watch != nullptr) { - state_->state_tracker.AddWatcher(op->start_connectivity_watch_state, - std::move(op->start_connectivity_watch)); + state_tracker_.AddWatcher(op->start_connectivity_watch_state, + std::move(op->start_connectivity_watch)); } if (op->stop_connectivity_watch != nullptr) { - state_->state_tracker.RemoveWatcher(op->stop_connectivity_watch); + state_tracker_.RemoveWatcher(op->stop_connectivity_watch); } } if (op->send_ping.on_initiate != nullptr) { diff --git a/src/core/lib/surface/lame_client.h b/src/core/lib/surface/lame_client.h index a8464fc9b96..1f8d323d352 100644 --- a/src/core/lib/surface/lame_client.h +++ b/src/core/lib/surface/lame_client.h @@ -47,7 +47,9 @@ class LameClientFilter : public ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + explicit LameClientFilter(absl::Status error); + + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); ArenaPromise MakeCallPromise( CallArgs call_args, NextPromiseFactory next_promise_factory) override; @@ -55,15 +57,9 @@ class LameClientFilter : public ChannelFilter { bool GetChannelInfo(const grpc_channel_info*) override; private: - explicit LameClientFilter(absl::Status error); - absl::Status error_; - struct State { - State(); - Mutex mu; - ConnectivityStateTracker state_tracker ABSL_GUARDED_BY(mu); - }; - std::unique_ptr state_; + Mutex mu_; + ConnectivityStateTracker state_tracker_ ABSL_GUARDED_BY(mu_); }; extern const grpc_arg_pointer_vtable kLameFilterErrorArgVtable; diff --git a/src/core/load_balancing/grpclb/client_load_reporting_filter.cc b/src/core/load_balancing/grpclb/client_load_reporting_filter.cc index 3b139fa8a4c..c3de43e4b94 100644 --- a/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +++ b/src/core/load_balancing/grpclb/client_load_reporting_filter.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/load_balancing/grpclb/client_load_reporting_filter.h" #include @@ -27,7 +25,8 @@ #include "absl/types/optional.h" -#include "src/core/load_balancing/grpclb/grpclb_client_stats.h" +#include + #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/promise/context.h" @@ -36,48 +35,47 @@ #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +#include "src/core/load_balancing/grpclb/grpclb_client_stats.h" namespace grpc_core { + +const NoInterceptor ClientLoadReportingFilter::Call::OnServerToClientMessage; +const NoInterceptor ClientLoadReportingFilter::Call::OnClientToServerMessage; +const NoInterceptor ClientLoadReportingFilter::Call::OnFinalize; + const grpc_channel_filter ClientLoadReportingFilter::kFilter = MakePromiseBasedFilter( "client_load_reporting"); -absl::StatusOr ClientLoadReportingFilter::Create( - const ChannelArgs&, ChannelFilter::Args) { - return ClientLoadReportingFilter(); +absl::StatusOr> +ClientLoadReportingFilter::Create(const ChannelArgs&, ChannelFilter::Args) { + return std::make_unique(); } -ArenaPromise ClientLoadReportingFilter::MakeCallPromise( - CallArgs call_args, NextPromiseFactory next_promise_factory) { - // Stats object to update. - RefCountedPtr client_stats; - +void ClientLoadReportingFilter::Call::OnClientInitialMetadata( + ClientMetadata& client_initial_metadata) { // Handle client initial metadata. // Grab client stats object from metadata. auto client_stats_md = - call_args.client_initial_metadata->Take(GrpcLbClientStatsMetadata()); + client_initial_metadata.Take(GrpcLbClientStatsMetadata()); if (client_stats_md.has_value()) { - client_stats.reset(*client_stats_md); + client_stats_.reset(*client_stats_md); } +} - auto* saw_initial_metadata = GetContext()->New(false); - call_args.server_initial_metadata->InterceptAndMap( - [saw_initial_metadata](ServerMetadataHandle md) { - *saw_initial_metadata = true; - return md; - }); +void ClientLoadReportingFilter::Call::OnServerInitialMetadata(ServerMetadata&) { + saw_initial_metadata_ = true; +} - return Map(next_promise_factory(std::move(call_args)), - [saw_initial_metadata, client_stats = std::move(client_stats)]( - ServerMetadataHandle trailing_metadata) { - if (client_stats != nullptr) { - client_stats->AddCallFinished( - trailing_metadata->get(GrpcStreamNetworkState()) == - GrpcStreamNetworkState::kNotSentOnWire, - *saw_initial_metadata); - } - return trailing_metadata; - }); +void ClientLoadReportingFilter::Call::OnServerTrailingMetadata( + ServerMetadata& server_trailing_metadata) { + if (client_stats_ != nullptr) { + client_stats_->AddCallFinished( + server_trailing_metadata.get(GrpcStreamNetworkState()) == + GrpcStreamNetworkState::kNotSentOnWire, + saw_initial_metadata_); + } } + } // namespace grpc_core diff --git a/src/core/load_balancing/grpclb/client_load_reporting_filter.h b/src/core/load_balancing/grpclb/client_load_reporting_filter.h index 57e89251d0b..941b97abf99 100644 --- a/src/core/load_balancing/grpclb/client_load_reporting_filter.h +++ b/src/core/load_balancing/grpclb/client_load_reporting_filter.h @@ -19,10 +19,10 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H #define GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H -#include - #include "absl/status/statusor.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -31,16 +31,27 @@ namespace grpc_core { -class ClientLoadReportingFilter final : public ChannelFilter { +class ClientLoadReportingFilter final + : public ImplementChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + class Call { + public: + void OnClientInitialMetadata(ClientMetadata& client_initial_metadata); + void OnServerInitialMetadata(ServerMetadata& server_initial_metadata); + void OnServerTrailingMetadata(ServerMetadata& server_trailing_metadata); + static const NoInterceptor OnServerToClientMessage; + static const NoInterceptor OnClientToServerMessage; + static const NoInterceptor OnFinalize; + + private: + RefCountedPtr client_stats_; + bool saw_initial_metadata_ = false; + }; + + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args filter_args); - - // Construct a promise for one call. - ArenaPromise MakeCallPromise( - CallArgs call_args, NextPromiseFactory next_promise_factory) override; }; } // namespace grpc_core diff --git a/src/core/resolver/xds/xds_resolver.cc b/src/core/resolver/xds/xds_resolver.cc index 6fc59c59113..13efe8a5099 100644 --- a/src/core/resolver/xds/xds_resolver.cc +++ b/src/core/resolver/xds/xds_resolver.cc @@ -317,9 +317,10 @@ class XdsResolver final : public Resolver { public: const static grpc_channel_filter kFilter; - static absl::StatusOr Create( - const ChannelArgs& /* unused */, ChannelFilter::Args filter_args) { - return ClusterSelectionFilter(filter_args); + static absl::StatusOr> Create( + const ChannelArgs& /* unused */, + ChannelFilter::Args /* filter_args */) { + return std::make_unique(); } // Construct a promise for one call. @@ -332,12 +333,6 @@ class XdsResolver final : public Resolver { static const NoInterceptor OnServerToClientMessage; static const NoInterceptor OnFinalize; }; - - private: - explicit ClusterSelectionFilter(ChannelFilter::Args filter_args) - : filter_args_(filter_args) {} - - ChannelFilter::Args filter_args_; }; RefCountedPtr GetOrCreateClusterRef( diff --git a/src/core/service_config/service_config_channel_arg_filter.cc b/src/core/service_config/service_config_channel_arg_filter.cc index 43069611022..a2c9a973129 100644 --- a/src/core/service_config/service_config_channel_arg_filter.cc +++ b/src/core/service_config/service_config_channel_arg_filter.cc @@ -17,8 +17,6 @@ // This filter reads GRPC_ARG_SERVICE_CONFIG and populates ServiceConfigCallData // in the call context per call for direct channels. -#include - #include #include #include @@ -30,6 +28,7 @@ #include #include +#include #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/channel/channel_args.h" @@ -42,13 +41,13 @@ #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/resource_quota/arena.h" +#include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/transport/metadata_batch.h" +#include "src/core/lib/transport/transport.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_call_data.h" #include "src/core/service_config/service_config_impl.h" #include "src/core/service_config/service_config_parser.h" -#include "src/core/lib/surface/channel_stack_type.h" -#include "src/core/lib/transport/metadata_batch.h" -#include "src/core/lib/transport/transport.h" namespace grpc_core { @@ -59,9 +58,9 @@ class ServiceConfigChannelArgFilter final public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs& args, ChannelFilter::Args) { - return ServiceConfigChannelArgFilter(args); + return std::make_unique(args); } explicit ServiceConfigChannelArgFilter(const ChannelArgs& args) { diff --git a/src/cpp/ext/filters/census/client_filter.cc b/src/cpp/ext/filters/census/client_filter.cc index 8dbc0959bd7..16131ce8af4 100644 --- a/src/cpp/ext/filters/census/client_filter.cc +++ b/src/cpp/ext/filters/census/client_filter.cc @@ -84,11 +84,13 @@ const grpc_channel_filter OpenCensusClientFilter::kFilter = grpc_core::FilterEndpoint::kClient, 0>( "opencensus_client"); -absl::StatusOr OpenCensusClientFilter::Create( - const grpc_core::ChannelArgs& args, ChannelFilter::Args /*filter_args*/) { +absl::StatusOr> +OpenCensusClientFilter::Create(const grpc_core::ChannelArgs& args, + ChannelFilter::Args /*filter_args*/) { bool observability_enabled = args.GetInt(GRPC_ARG_ENABLE_OBSERVABILITY).value_or(true); - return OpenCensusClientFilter(/*tracing_enabled=*/observability_enabled); + return std::make_unique( + /*tracing_enabled=*/observability_enabled); } grpc_core::ArenaPromise diff --git a/src/cpp/ext/filters/census/client_filter.h b/src/cpp/ext/filters/census/client_filter.h index 011a22e58a1..a549510bbe2 100644 --- a/src/cpp/ext/filters/census/client_filter.h +++ b/src/cpp/ext/filters/census/client_filter.h @@ -38,16 +38,17 @@ class OpenCensusClientFilter : public grpc_core::ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + static absl::StatusOr> Create( const grpc_core::ChannelArgs& args, ChannelFilter::Args /*filter_args*/); + explicit OpenCensusClientFilter(bool tracing_enabled) + : tracing_enabled_(tracing_enabled) {} + grpc_core::ArenaPromise MakeCallPromise( grpc_core::CallArgs call_args, grpc_core::NextPromiseFactory next_promise_factory) override; private: - explicit OpenCensusClientFilter(bool tracing_enabled) - : tracing_enabled_(tracing_enabled) {} bool tracing_enabled_ = true; }; diff --git a/test/core/filters/filter_test.h b/test/core/filters/filter_test.h index 796b0a22213..c557e6aee16 100644 --- a/test/core/filters/filter_test.h +++ b/test/core/filters/filter_test.h @@ -231,7 +231,7 @@ class FilterTest : public FilterTestBase { absl::StatusOr MakeChannel(const ChannelArgs& args) { auto filter = Filter::Create(args, ChannelFilter::Args()); if (!filter.ok()) return filter.status(); - return Channel(std::make_unique(std::move(*filter)), this); + return Channel(std::move(*filter), this); } }; diff --git a/test/core/filters/filter_test_test.cc b/test/core/filters/filter_test_test.cc index e0dad7ad671..ec836316f86 100644 --- a/test/core/filters/filter_test_test.cc +++ b/test/core/filters/filter_test_test.cc @@ -49,9 +49,9 @@ class NoOpFilter final : public ChannelFilter { return next(std::move(args)); } - static absl::StatusOr Create(const ChannelArgs&, - ChannelFilter::Args) { - return NoOpFilter(); + static absl::StatusOr> Create( + const ChannelArgs&, ChannelFilter::Args) { + return std::make_unique(); } }; using NoOpFilterTest = FilterTest; @@ -70,9 +70,9 @@ class DelayStartFilter final : public ChannelFilter { next); } - static absl::StatusOr Create(const ChannelArgs&, - ChannelFilter::Args) { - return DelayStartFilter(); + static absl::StatusOr> Create( + const ChannelArgs&, ChannelFilter::Args) { + return std::make_unique(); } }; using DelayStartFilterTest = FilterTest; @@ -86,9 +86,9 @@ class AddClientInitialMetadataFilter final : public ChannelFilter { return next(std::move(args)); } - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs&, ChannelFilter::Args) { - return AddClientInitialMetadataFilter(); + return absl::make_unique(); } }; using AddClientInitialMetadataFilterTest = @@ -104,9 +104,9 @@ class AddServerTrailingMetadataFilter final : public ChannelFilter { }); } - static absl::StatusOr Create( - const ChannelArgs&, ChannelFilter::Args) { - return AddServerTrailingMetadataFilter(); + static absl::StatusOr> + Create(const ChannelArgs&, ChannelFilter::Args) { + return absl::make_unique(); } }; using AddServerTrailingMetadataFilterTest = @@ -122,10 +122,9 @@ class AddServerInitialMetadataFilter final : public ChannelFilter { }); return next(std::move(args)); } - - static absl::StatusOr Create( + static absl::StatusOr> Create( const ChannelArgs&, ChannelFilter::Args) { - return AddServerInitialMetadataFilter(); + return absl::make_unique(); } }; using AddServerInitialMetadataFilterTest = diff --git a/test/core/surface/channel_init_test.cc b/test/core/surface/channel_init_test.cc index cd7bfc7f347..4986cc3a839 100644 --- a/test/core/surface/channel_init_test.cc +++ b/test/core/surface/channel_init_test.cc @@ -15,6 +15,7 @@ #include "src/core/lib/surface/channel_init.h" #include +#include #include #include "absl/strings/string_view.h" @@ -206,9 +207,10 @@ class TestFilter1 { public: explicit TestFilter1(int* p) : p_(p) {} - static absl::StatusOr Create(const ChannelArgs& args, Empty) { + static absl::StatusOr> Create( + const ChannelArgs& args, Empty) { EXPECT_EQ(args.GetInt("foo"), 1); - return TestFilter1(args.GetPointer("p")); + return std::make_unique(args.GetPointer("p")); } static const grpc_channel_filter kFilter; diff --git a/test/core/util/fake_stats_plugin.cc b/test/core/util/fake_stats_plugin.cc index 2ef159d5b75..00055d06d94 100644 --- a/test/core/util/fake_stats_plugin.cc +++ b/test/core/util/fake_stats_plugin.cc @@ -22,15 +22,16 @@ class FakeStatsClientFilter : public ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + explicit FakeStatsClientFilter( + FakeClientCallTracerFactory* fake_client_call_tracer_factory); + + static absl::StatusOr> Create( const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/); ArenaPromise MakeCallPromise( CallArgs call_args, NextPromiseFactory next_promise_factory) override; private: - explicit FakeStatsClientFilter( - FakeClientCallTracerFactory* fake_client_call_tracer_factory); FakeClientCallTracerFactory* const fake_client_call_tracer_factory_; }; @@ -38,13 +39,15 @@ const grpc_channel_filter FakeStatsClientFilter::kFilter = MakePromiseBasedFilter( "fake_stats_client"); -absl::StatusOr FakeStatsClientFilter::Create( - const ChannelArgs& args, ChannelFilter::Args /*filter_args*/) { +absl::StatusOr> +FakeStatsClientFilter::Create(const ChannelArgs& args, + ChannelFilter::Args /*filter_args*/) { auto* fake_client_call_tracer_factory = args.GetPointer( GRPC_ARG_INJECT_FAKE_CLIENT_CALL_TRACER_FACTORY); GPR_ASSERT(fake_client_call_tracer_factory != nullptr); - return FakeStatsClientFilter(fake_client_call_tracer_factory); + return std::make_unique( + fake_client_call_tracer_factory); } ArenaPromise FakeStatsClientFilter::MakeCallPromise( diff --git a/test/cpp/ext/otel/otel_test_library.cc b/test/cpp/ext/otel/otel_test_library.cc index 0aac08a4da3..81ab0842128 100644 --- a/test/cpp/ext/otel/otel_test_library.cc +++ b/test/cpp/ext/otel/otel_test_library.cc @@ -50,9 +50,15 @@ class AddLabelsFilter : public grpc_core::ChannelFilter { public: static const grpc_channel_filter kFilter; - static absl::StatusOr Create( + explicit AddLabelsFilter( + std::map + labels_to_inject) + : labels_to_inject_(std::move(labels_to_inject)) {} + + static absl::StatusOr> Create( const grpc_core::ChannelArgs& args, ChannelFilter::Args /*filter_args*/) { - return AddLabelsFilter( + return absl::make_unique( *args.GetPointer>(GRPC_ARG_LABELS_TO_INJECT)); @@ -73,12 +79,6 @@ class AddLabelsFilter : public grpc_core::ChannelFilter { } private: - explicit AddLabelsFilter( - std::map - labels_to_inject) - : labels_to_inject_(std::move(labels_to_inject)) {} - const std::map< grpc_core::ClientCallTracer::CallAttemptTracer::OptionalLabelKey, grpc_core::RefCountedStringValue> From 1a8b22f2de549b4ae3a2aafc1237e0e280ba5c65 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Tue, 16 Apr 2024 20:00:39 +0000 Subject: [PATCH 09/45] [build] Restrict visibility for creating core credentials types. (#36216) Closes #36216 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36216 from drfloob:conceal-core-cred-creation a44a2992736c2c45c044452ec892e6ac4d173b7b PiperOrigin-RevId: 625425746 --- BUILD | 17 + CMakeLists.txt | 3 + Makefile | 1 + Package.swift | 1 + bazel/grpc_build_system.bzl | 1 + build_autogenerated.yaml | 3 + gRPC-Core.podspec | 1 + grpc.def | 130 +- grpc.gemspec | 1 + include/grpc/credentials.h | 1223 +++++++++++++++++ include/grpc/grpc.h | 7 + include/grpc/grpc_crl_provider.h | 1 + include/grpc/grpc_security.h | 1171 ---------------- include/grpc/module.modulemap | 1 + .../security/tls_certificate_provider.h | 1 + package.xml | 1 + src/core/BUILD | 15 + src/core/ext/gcp/metadata_query.cc | 1 + src/core/ext/xds/xds_server_config_fetcher.cc | 1 + .../lib/http/httpcli_security_connector.cc | 1 + .../certificate_provider_factory.h | 1 + .../lib/security/context/security_context.cc | 1 + .../lib/security/context/security_context.h | 1 + .../credentials/alts/alts_credentials.h | 1 + .../alts/grpc_alts_credentials_options.h | 1 + .../security/credentials/call_creds_util.h | 1 + .../channel_creds_registry_init.cc | 1 + .../composite/composite_credentials.h | 1 + .../lib/security/credentials/credentials.h | 1 + .../aws_external_account_credentials.cc | 1 + .../external/external_account_credentials.cc | 1 + .../url_external_account_credentials.cc | 1 + .../credentials/fake/fake_credentials.h | 1 + .../google_default_credentials.cc | 3 +- .../google_default_credentials.h | 1 + .../credentials/iam/iam_credentials.h | 1 + .../insecure/insecure_credentials.h | 1 + .../security/credentials/jwt/json_token.cc | 1 + .../credentials/jwt/jwt_credentials.cc | 1 + .../credentials/jwt/jwt_credentials.h | 1 + .../credentials/local/local_credentials.h | 1 + .../credentials/oauth2/oauth2_credentials.cc | 1 + .../credentials/oauth2/oauth2_credentials.h | 1 + .../credentials/plugin/plugin_credentials.h | 1 + .../credentials/ssl/ssl_credentials.h | 1 + .../tls/grpc_tls_certificate_distributor.cc | 1 + .../tls/grpc_tls_certificate_provider.cc | 1 + .../tls/grpc_tls_certificate_verifier.h | 1 + .../tls/grpc_tls_credentials_options.h | 1 + .../credentials/tls/tls_credentials.h | 1 + .../credentials/xds/xds_credentials.h | 1 + .../alts/alts_security_connector.h | 1 + .../fake/fake_security_connector.h | 1 + .../insecure/insecure_security_connector.h | 1 + .../local/local_security_connector.h | 1 + .../security_connector/security_connector.h | 1 + .../ssl/ssl_security_connector.h | 1 + .../security/security_connector/ssl_utils.cc | 1 + .../tls/tls_security_connector.h | 1 + .../lib/security/transport/auth_filters.h | 1 + .../security/transport/client_auth_filter.cc | 1 + .../security/transport/server_auth_filter.cc | 1 + .../alts/handshaker/alts_tsi_handshaker.cc | 1 + src/cpp/client/create_channel_posix.cc | 1 + src/cpp/common/tls_certificate_provider.cc | 1 + src/cpp/common/tls_certificate_verifier.cc | 1 + src/cpp/common/tls_credentials_options.cc | 1 + src/cpp/server/server_posix.cc | 1 + .../GRPCCore/GRPCInsecureChannelFactory.mm | 1 + .../GRPCCore/GRPCSecureChannelFactory.mm | 1 + src/php/ext/grpc/call_credentials.h | 1 + src/php/ext/grpc/channel.c | 1 + src/php/ext/grpc/channel_credentials.h | 1 + src/php/ext/grpc/php_grpc.c | 1 + src/php/ext/grpc/server.c | 1 + src/php/ext/grpc/server_credentials.h | 1 + .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 153 ++- src/ruby/ext/grpc/rb_call_credentials.c | 1 + src/ruby/ext/grpc/rb_call_credentials.h | 1 + src/ruby/ext/grpc/rb_channel.c | 1 + src/ruby/ext/grpc/rb_channel_credentials.c | 1 + src/ruby/ext/grpc/rb_grpc_imports.generated.c | 260 ++-- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 391 +++--- src/ruby/ext/grpc/rb_server.c | 1 + src/ruby/ext/grpc/rb_server_credentials.c | 1 + src/ruby/ext/grpc/rb_server_credentials.h | 1 + .../ext/grpc/rb_xds_channel_credentials.c | 1 + src/ruby/ext/grpc/rb_xds_server_credentials.c | 1 + src/ruby/ext/grpc/rb_xds_server_credentials.h | 1 + test/core/bad_ssl/bad_ssl_test.cc | 1 + test/core/bad_ssl/servers/alpn.cc | 1 + test/core/bad_ssl/servers/cert.cc | 1 + test/core/channel/channel_args_test.cc | 1 + test/core/channel/channel_trace_test.cc | 1 + test/core/channel/channelz_test.cc | 1 + test/core/end2end/bad_server_response_test.cc | 1 + test/core/end2end/connection_refused_test.cc | 1 + test/core/end2end/dualstack_socket_test.cc | 1 + test/core/end2end/end2end_test_suites.cc | 1 + test/core/end2end/end2end_tests.h | 1 + test/core/end2end/fixtures/h2_oauth2_common.h | 1 + .../fixtures/h2_ssl_cred_reload_fixture.h | 1 + .../core/end2end/fixtures/h2_ssl_tls_common.h | 1 + test/core/end2end/fixtures/h2_tls_common.h | 1 + test/core/end2end/fixtures/local_util.cc | 1 + test/core/end2end/fixtures/secure_fixture.h | 1 + test/core/end2end/fuzzers/api_fuzzer.cc | 1 + .../end2end/fuzzers/server_fuzzer_chttp2.cc | 1 + test/core/end2end/goaway_server_test.cc | 1 + test/core/end2end/h2_ssl_cert_test.cc | 1 + .../core/end2end/h2_ssl_session_reuse_test.cc | 1 + ...ls_peer_property_external_verifier_test.cc | 1 + .../end2end/invalid_call_argument_test.cc | 1 + .../end2end/multiple_server_queues_test.cc | 1 + test/core/end2end/no_server_test.cc | 1 + test/core/end2end/tests/call_creds.cc | 1 + test/core/filters/client_auth_filter_test.cc | 1 + test/core/handshake/client_ssl.cc | 1 + test/core/handshake/server_ssl_common.cc | 1 + test/core/handshake/verify_peer_options.cc | 1 + test/core/http/httpcli_test.cc | 1 + test/core/memory_usage/client.cc | 1 + test/core/memory_usage/server.cc | 1 + test/core/security/alts_credentials_fuzzer.cc | 1 + test/core/security/create_jwt.cc | 1 + test/core/security/credentials_test.cc | 1 + test/core/security/fetch_oauth2.cc | 1 + ...tls_credentials_options_comparator_test.cc | 2 + .../grpc_tls_credentials_options_test.cc | 1 + test/core/security/json_token_test.cc | 1 + test/core/security/oauth2_utils.cc | 1 + .../print_google_default_creds_token.cc | 1 + test/core/security/security_connector_test.cc | 1 + test/core/security/ssl_server_fuzzer.cc | 1 + .../security/tls_security_connector_test.cc | 1 + .../surface/concurrent_connectivity_test.cc | 1 + ...num_external_connectivity_watchers_test.cc | 1 + .../surface/sequential_connectivity_test.cc | 1 + test/core/surface/server_chttp2_test.cc | 1 + test/core/surface/server_test.cc | 1 + .../remove_stream_from_stalled_lists_test.cc | 1 + .../transport/chttp2/settings_timeout_test.cc | 1 + ...ak_with_queued_flow_control_update_test.cc | 1 + .../transport/chttp2/streams_not_seen_test.cc | 1 + .../transport/chttp2/too_many_pings_test.cc | 1 + .../alts_concurrent_connectivity_test.cc | 1 + .../handshaker/alts_handshaker_client_test.cc | 1 + test/core/util/port_server_client.cc | 1 + test/cpp/end2end/grpclb_end2end_test.cc | 1 + test/cpp/end2end/rls_end2end_test.cc | 1 + test/cpp/end2end/ssl_credentials_test.cc | 1 + test/cpp/interop/client_helper.cc | 1 + test/cpp/microbenchmarks/bm_channel.cc | 1 + test/cpp/naming/cancel_ares_query_test.cc | 1 + .../core/gen_grpc_tls_credentials_options.py | 3 + tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 159 files changed, 1892 insertions(+), 1634 deletions(-) create mode 100644 include/grpc/credentials.h diff --git a/BUILD b/BUILD index 0298f22bc82..894186b35f2 100644 --- a/BUILD +++ b/BUILD @@ -1243,6 +1243,7 @@ grpc_cc_library( "gpr", "grpc++_base_unsecure", "grpc++_codegen_proto", + "grpc_core_credentials_header", "grpc_public_hdrs", "grpc_security_base", "grpc_unsecure", @@ -2267,6 +2268,7 @@ grpc_cc_library( "exec_ctx", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_public_hdrs", "grpc_trace", "handshaker", @@ -2328,6 +2330,14 @@ grpc_cc_library( ], ) +# TODO(hork): split credentials types into their own source files and targets. +grpc_cc_library( + name = "grpc_core_credentials_header", + hdrs = ["include/grpc/credentials.h"], + language = "c++", + visibility = ["@grpc:core_credentials"], +) + grpc_cc_library( name = "alts_util", srcs = [ @@ -2355,6 +2365,7 @@ grpc_cc_library( deps = [ "alts_upb", "gpr", + "grpc_core_credentials_header", "grpc_public_hdrs", ], ) @@ -2428,6 +2439,7 @@ grpc_cc_library( "grpc", "grpc++_codegen_proto", "grpc_base", + "grpc_core_credentials_header", "grpc_credentials_util", "grpc_health_upb", "grpc_public_hdrs", @@ -2509,6 +2521,7 @@ grpc_cc_library( "exec_ctx", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_health_upb", "grpc_public_hdrs", "grpc_security_base", @@ -3860,6 +3873,7 @@ grpc_cc_library( "exec_ctx", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_public_hdrs", "grpc_security_base", "handshaker", @@ -3929,6 +3943,7 @@ grpc_cc_library( "exec_ctx", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_credentials_util", "grpc_security_base", "grpc_trace", @@ -4017,6 +4032,7 @@ grpc_cc_library( "exec_ctx", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_security_base", "tsi_alts_frame_protector", "tsi_base", @@ -4134,6 +4150,7 @@ grpc_cc_library( "config_vars", "gpr", "grpc_base", + "grpc_core_credentials_header", "grpc_credentials_util", "grpc_public_hdrs", "grpc_security_base", diff --git a/CMakeLists.txt b/CMakeLists.txt index b8ea2f99e2f..0ec682d102a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2694,6 +2694,7 @@ foreach(_hdr include/grpc/byte_buffer_reader.h include/grpc/census.h include/grpc/compression.h + include/grpc/credentials.h include/grpc/event_engine/endpoint_config.h include/grpc/event_engine/event_engine.h include/grpc/event_engine/extensible.h @@ -3395,6 +3396,7 @@ foreach(_hdr include/grpc/byte_buffer_reader.h include/grpc/census.h include/grpc/compression.h + include/grpc/credentials.h include/grpc/event_engine/endpoint_config.h include/grpc/event_engine/event_engine.h include/grpc/event_engine/extensible.h @@ -5452,6 +5454,7 @@ foreach(_hdr include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h + include/grpc/credentials.h include/grpc/event_engine/endpoint_config.h include/grpc/event_engine/event_engine.h include/grpc/event_engine/extensible.h diff --git a/Makefile b/Makefile index ac23dd86dc3..30be778e03d 100644 --- a/Makefile +++ b/Makefile @@ -1728,6 +1728,7 @@ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer_reader.h \ include/grpc/census.h \ include/grpc/compression.h \ + include/grpc/credentials.h \ include/grpc/event_engine/endpoint_config.h \ include/grpc/event_engine/event_engine.h \ include/grpc/event_engine/extensible.h \ diff --git a/Package.swift b/Package.swift index 651d0d3822c..ce9e5e1bed5 100644 --- a/Package.swift +++ b/Package.swift @@ -45,6 +45,7 @@ let package = Package( "include/grpc/byte_buffer_reader.h", "include/grpc/census.h", "include/grpc/compression.h", + "include/grpc/credentials.h", "include/grpc/event_engine/endpoint_config.h", "include/grpc/event_engine/event_engine.h", "include/grpc/event_engine/extensible.h", diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 1da3bac40ab..784547dc230 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -102,6 +102,7 @@ def _update_visibility(visibility): "chaotic_good": PRIVATE, "client_channel": PRIVATE, "cli": PRIVATE, + "core_credentials": PRIVATE, "debug_location": PRIVATE, "endpoint_tests": PRIVATE, "exec_ctx": PRIVATE, diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 6716d165cec..2084da2d886 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -149,6 +149,7 @@ libs: - include/grpc/byte_buffer_reader.h - include/grpc/census.h - include/grpc/compression.h + - include/grpc/credentials.h - include/grpc/event_engine/endpoint_config.h - include/grpc/event_engine/event_engine.h - include/grpc/event_engine/extensible.h @@ -2136,6 +2137,7 @@ libs: - include/grpc/byte_buffer_reader.h - include/grpc/census.h - include/grpc/compression.h + - include/grpc/credentials.h - include/grpc/event_engine/endpoint_config.h - include/grpc/event_engine/event_engine.h - include/grpc/event_engine/extensible.h @@ -4321,6 +4323,7 @@ libs: - include/grpc/byte_buffer.h - include/grpc/byte_buffer_reader.h - include/grpc/compression.h + - include/grpc/credentials.h - include/grpc/event_engine/endpoint_config.h - include/grpc/event_engine/event_engine.h - include/grpc/event_engine/extensible.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 46f43b36dfb..1624bceaeb2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -119,6 +119,7 @@ Pod::Spec.new do |s| 'include/grpc/byte_buffer_reader.h', 'include/grpc/census.h', 'include/grpc/compression.h', + 'include/grpc/credentials.h', 'include/grpc/event_engine/endpoint_config.h', 'include/grpc/event_engine/event_engine.h', 'include/grpc/event_engine/extensible.h', diff --git a/grpc.def b/grpc.def index 41ad2dd61df..154e8eee94d 100644 --- a/grpc.def +++ b/grpc.def @@ -19,6 +19,70 @@ EXPORTS grpc_compression_options_enable_algorithm grpc_compression_options_disable_algorithm grpc_compression_options_is_algorithm_enabled + grpc_service_account_jwt_access_credentials_create + grpc_external_account_credentials_create + grpc_google_refresh_token_credentials_create + grpc_access_token_credentials_create + grpc_google_iam_credentials_create + grpc_sts_credentials_create + grpc_auth_metadata_context_copy + grpc_auth_metadata_context_reset + grpc_metadata_credentials_create_from_plugin + grpc_call_credentials_release + grpc_google_default_credentials_create + grpc_ssl_server_certificate_config_create + grpc_ssl_server_certificate_config_destroy + grpc_ssl_credentials_create + grpc_ssl_credentials_create_ex + grpc_ssl_server_credentials_create + grpc_ssl_server_credentials_create_ex + grpc_ssl_server_credentials_create_options_using_config + grpc_ssl_server_credentials_create_options_using_config_fetcher + grpc_ssl_server_credentials_options_destroy + grpc_ssl_server_credentials_create_with_options + grpc_server_credentials_set_auth_metadata_processor + grpc_composite_call_credentials_create + grpc_google_compute_engine_credentials_create + grpc_composite_channel_credentials_create + grpc_alts_credentials_client_options_create + grpc_alts_credentials_server_options_create + grpc_alts_credentials_client_options_add_target_service_account + grpc_alts_credentials_options_destroy + grpc_alts_credentials_create + grpc_alts_server_credentials_create + grpc_tls_identity_pairs_create + grpc_tls_identity_pairs_add_pair + grpc_tls_identity_pairs_destroy + grpc_tls_certificate_provider_static_data_create + grpc_tls_certificate_provider_file_watcher_create + grpc_tls_certificate_provider_release + grpc_tls_credentials_options_create + grpc_tls_credentials_options_set_min_tls_version + grpc_tls_credentials_options_set_max_tls_version + grpc_tls_credentials_options_copy + grpc_tls_credentials_options_destroy + grpc_tls_credentials_options_set_certificate_provider + grpc_tls_credentials_options_watch_root_certs + grpc_tls_credentials_options_set_root_cert_name + grpc_tls_credentials_options_watch_identity_key_cert_pairs + grpc_tls_credentials_options_set_identity_cert_name + grpc_tls_credentials_options_set_cert_request_type + grpc_tls_credentials_options_set_crl_directory + grpc_tls_credentials_options_set_verify_server_cert + grpc_tls_credentials_options_set_send_client_ca_list + grpc_ssl_session_cache_create_lru + grpc_ssl_session_cache_destroy + grpc_ssl_session_cache_create_channel_arg + grpc_set_ssl_roots_override_callback + grpc_max_auth_token_lifetime + grpc_insecure_credentials_create + grpc_insecure_server_credentials_create + grpc_xds_credentials_create + grpc_xds_server_credentials_create + grpc_local_credentials_create + grpc_local_server_credentials_create + grpc_tls_credentials_options_set_check_call_host + grpc_tls_credentials_options_set_tls_session_key_log_file_path grpc_metadata_array_init grpc_metadata_array_destroy grpc_call_details_init @@ -64,6 +128,7 @@ EXPORTS grpc_call_failed_before_recv_message grpc_call_ref grpc_call_unref + grpc_call_set_credentials grpc_server_request_call grpc_server_register_method grpc_server_request_registered_call @@ -110,74 +175,9 @@ EXPORTS grpc_auth_context_add_property grpc_auth_context_add_cstring_property grpc_auth_context_set_peer_identity_property_name - grpc_ssl_session_cache_create_lru - grpc_ssl_session_cache_destroy - grpc_ssl_session_cache_create_channel_arg - grpc_call_credentials_release - grpc_google_default_credentials_create - grpc_set_ssl_roots_override_callback - grpc_ssl_credentials_create - grpc_ssl_credentials_create_ex - grpc_composite_channel_credentials_create - grpc_composite_call_credentials_create - grpc_google_compute_engine_credentials_create - grpc_max_auth_token_lifetime - grpc_service_account_jwt_access_credentials_create - grpc_external_account_credentials_create - grpc_google_refresh_token_credentials_create - grpc_access_token_credentials_create - grpc_google_iam_credentials_create - grpc_sts_credentials_create - grpc_auth_metadata_context_copy - grpc_auth_metadata_context_reset - grpc_metadata_credentials_create_from_plugin - grpc_ssl_server_certificate_config_create - grpc_ssl_server_certificate_config_destroy - grpc_ssl_server_credentials_create - grpc_ssl_server_credentials_create_ex - grpc_ssl_server_credentials_create_options_using_config - grpc_ssl_server_credentials_create_options_using_config_fetcher - grpc_ssl_server_credentials_options_destroy - grpc_ssl_server_credentials_create_with_options - grpc_call_set_credentials - grpc_server_credentials_set_auth_metadata_processor - grpc_alts_credentials_client_options_create - grpc_alts_credentials_server_options_create - grpc_alts_credentials_client_options_add_target_service_account - grpc_alts_credentials_options_destroy - grpc_alts_credentials_create - grpc_alts_server_credentials_create - grpc_local_credentials_create - grpc_local_server_credentials_create - grpc_tls_identity_pairs_create - grpc_tls_identity_pairs_add_pair - grpc_tls_identity_pairs_destroy - grpc_tls_certificate_provider_static_data_create - grpc_tls_certificate_provider_file_watcher_create - grpc_tls_certificate_provider_release - grpc_tls_credentials_options_create - grpc_tls_credentials_options_set_min_tls_version - grpc_tls_credentials_options_set_max_tls_version - grpc_tls_credentials_options_copy - grpc_tls_credentials_options_destroy - grpc_tls_credentials_options_set_certificate_provider - grpc_tls_credentials_options_watch_root_certs - grpc_tls_credentials_options_set_root_cert_name - grpc_tls_credentials_options_watch_identity_key_cert_pairs - grpc_tls_credentials_options_set_identity_cert_name - grpc_tls_credentials_options_set_cert_request_type - grpc_tls_credentials_options_set_crl_directory - grpc_tls_credentials_options_set_verify_server_cert - grpc_tls_credentials_options_set_send_client_ca_list - grpc_tls_credentials_options_set_check_call_host - grpc_insecure_credentials_create - grpc_insecure_server_credentials_create - grpc_xds_credentials_create - grpc_xds_server_credentials_create grpc_authorization_policy_provider_static_data_create grpc_authorization_policy_provider_file_watcher_create grpc_authorization_policy_provider_release - grpc_tls_credentials_options_set_tls_session_key_log_file_path grpc_slice_ref grpc_slice_unref grpc_slice_copy diff --git a/grpc.gemspec b/grpc.gemspec index 73b32228479..3a986b6d65e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -51,6 +51,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/byte_buffer_reader.h ) s.files += %w( include/grpc/census.h ) s.files += %w( include/grpc/compression.h ) + s.files += %w( include/grpc/credentials.h ) s.files += %w( include/grpc/event_engine/endpoint_config.h ) s.files += %w( include/grpc/event_engine/event_engine.h ) s.files += %w( include/grpc/event_engine/extensible.h ) diff --git a/include/grpc/credentials.h b/include/grpc/credentials.h new file mode 100644 index 00000000000..71d1864dc24 --- /dev/null +++ b/include/grpc/credentials.h @@ -0,0 +1,1223 @@ +/* + * + * Copyright 2024 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CREDENTIALS_H +#define GRPC_CREDENTIALS_H + +#include + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** --- grpc_call_credentials object --- + + A call credentials object represents a way to authenticate on a particular + call. These credentials can be composed with a channel credentials object + so that they are sent with every call on this channel. */ + +typedef struct grpc_call_credentials grpc_call_credentials; +typedef struct grpc_auth_context grpc_auth_context; + +/** Creates a JWT credentials object. May return NULL if the input is invalid. + - json_key is the JSON key string containing the client's private key. + - token_lifetime is the lifetime of each Json Web Token (JWT) created with + this credentials. It should not exceed grpc_max_auth_token_lifetime or + will be cropped to this value. */ +GRPCAPI grpc_call_credentials* +grpc_service_account_jwt_access_credentials_create(const char* json_key, + gpr_timespec token_lifetime, + void* reserved); + +/** Builds External Account credentials. + - json_string is the JSON string containing the credentials options. + - scopes_string contains the scopes to be binded with the credentials. + This API is used for experimental purposes for now and may change in the + future. */ +GRPCAPI grpc_call_credentials* grpc_external_account_credentials_create( + const char* json_string, const char* scopes_string); + +/** Creates an Oauth2 Refresh Token credentials object for connecting to Google. + May return NULL if the input is invalid. + WARNING: Do NOT use this credentials to connect to a non-google service as + this could result in an oauth2 token leak. + - json_refresh_token is the JSON string containing the refresh token itself + along with a client_id and client_secret. */ +GRPCAPI grpc_call_credentials* grpc_google_refresh_token_credentials_create( + const char* json_refresh_token, void* reserved); + +/** Creates an Oauth2 Access Token credentials with an access token that was + acquired by an out of band mechanism. */ +GRPCAPI grpc_call_credentials* grpc_access_token_credentials_create( + const char* access_token, void* reserved); + +/** Creates an IAM credentials object for connecting to Google. */ +GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( + const char* authorization_token, const char* authority_selector, + void* reserved); + +/** Options for creating STS Oauth Token Exchange credentials following the IETF + draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + Optional fields may be set to NULL or empty string. It is the responsibility + of the caller to ensure that the subject and actor tokens are refreshed on + disk at the specified paths. This API is used for experimental purposes for + now and may change in the future. */ +typedef struct { + const char* token_exchange_service_uri; /* Required. */ + const char* resource; /* Optional. */ + const char* audience; /* Optional. */ + const char* scope; /* Optional. */ + const char* requested_token_type; /* Optional. */ + const char* subject_token_path; /* Required. */ + const char* subject_token_type; /* Required. */ + const char* actor_token_path; /* Optional. */ + const char* actor_token_type; /* Optional. */ +} grpc_sts_credentials_options; + +/** Creates an STS credentials following the STS Token Exchanged specifi ed in the + IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + This API is used for experimental purposes for now and may change in the + future. */ +GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( + const grpc_sts_credentials_options* options, void* reserved); + +/** Context that can be used by metadata credentials plugin in order to create + auth related metadata. */ +typedef struct { + /** The fully qualifed service url. */ + const char* service_url; + + /** The method name of the RPC being called (not fully qualified). + The fully qualified method name can be built from the service_url: + full_qualified_method_name = ctx->service_url + '/' + ctx->method_name. */ + const char* method_name; + + /** The auth_context of the channel which gives the server's identity. */ + const grpc_auth_context* channel_auth_context; + + /** Reserved for future use. */ + void* reserved; +} grpc_auth_metadata_context; + +/** Performs a deep copy from \a from to \a to. **/ +GRPCAPI void grpc_auth_metadata_context_copy(grpc_auth_metadata_context* from, + grpc_auth_metadata_context* to); + +/** Releases internal resources held by \a context. **/ +GRPCAPI void grpc_auth_metadata_context_reset( + grpc_auth_metadata_context* context); + +/** Callback function to be called by the metadata credentials plugin + implementation when the metadata is ready. + - user_data is the opaque pointer that was passed in the get_metadata method + of the grpc_metadata_credentials_plugin (see below). + - creds_md is an array of credentials metadata produced by the plugin. It + may be set to NULL in case of an error. + - num_creds_md is the number of items in the creds_md array. + - status must be GRPC_STATUS_OK in case of success or another specific error + code otherwise. + - error_details contains details about the error if any. In case of success + it should be NULL and will be otherwise ignored. */ +typedef void (*grpc_credentials_plugin_metadata_cb)( + void* user_data, const grpc_metadata* creds_md, size_t num_creds_md, + grpc_status_code status, const char* error_details); + +/** Maximum number of metadata entries returnable by a credentials plugin via + a synchronous return. */ +#define GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX 4 + +/** grpc_metadata_credentials plugin is an API user provided structure used to + create grpc_credentials objects that can be set on a channel (composed) or + a call. See grpc_credentials_metadata_create_from_plugin below. + The grpc client stack will call the get_metadata method of the plugin for + every call in scope for the credentials created from it. */ +typedef struct { + /** The implementation of this method has to be non-blocking, but can + be performed synchronously or asynchronously. + + If processing occurs synchronously, returns non-zero and populates + creds_md, num_creds_md, status, and error_details. In this case, + the caller takes ownership of the entries in creds_md and of + error_details. Note that if the plugin needs to return more than + GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX entries in creds_md, it must + return asynchronously. + + If processing occurs asynchronously, returns zero and invokes \a cb + when processing is completed. \a user_data will be passed as the + first parameter of the callback. NOTE: \a cb MUST be invoked in a + different thread, not from the thread in which \a get_metadata() is + invoked. + + \a context is the information that can be used by the plugin to create + auth metadata. */ + int (*get_metadata)( + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, + grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], + size_t* num_creds_md, grpc_status_code* status, + const char** error_details); + + /** Implements debug string of the given plugin. This method returns an + * allocated string that the caller needs to free using gpr_free() */ + char* (*debug_string)(void* state); + + /** Destroys the plugin state. */ + void (*destroy)(void* state); + + /** State that will be set as the first parameter of the methods above. */ + void* state; + + /** Type of credentials that this plugin is implementing. */ + const char* type; +} grpc_metadata_credentials_plugin; + +/** Creates a credentials object from a plugin with a specified minimum security + * level. */ +GRPCAPI grpc_call_credentials* grpc_metadata_credentials_create_from_plugin( + grpc_metadata_credentials_plugin plugin, + grpc_security_level min_security_level, void* reserved); + +/** --- channel credentials --- */ + +/** Releases a call credentials object. + The creator of the credentials object is responsible for its release. */ +GRPCAPI void grpc_call_credentials_release(grpc_call_credentials* creds); + +/** Creates default credentials to connect to a google gRPC service. + WARNING: Do NOT use this credentials to connect to a non-google service as + this could result in an oauth2 token leak. The security level of the + resulting connection is GRPC_PRIVACY_AND_INTEGRITY. + + If specified, the supplied call credentials object will be attached to the + returned channel credentials object. The call_credentials object must remain + valid throughout the lifetime of the returned grpc_channel_credentials + object. It is expected that the call credentials object was generated + according to the Application Default Credentials mechanism and asserts the + identity of the default service account of the machine. Supplying any other + sort of call credential will result in undefined behavior, up to and + including the sudden and unexpected failure of RPCs. + + If nullptr is supplied, the returned channel credentials object will use a + call credentials object based on the Application Default Credentials + mechanism. +*/ +GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create( + grpc_call_credentials* call_credentials); + +/** Server certificate config object holds the server's public certificates and + associated private keys, as well as any CA certificates needed for client + certificate validation (if applicable). Create using + grpc_ssl_server_certificate_config_create(). */ +typedef struct grpc_ssl_server_certificate_config + grpc_ssl_server_certificate_config; + +/** Object that holds a private key / certificate chain pair in PEM format. */ +typedef struct { + /** private_key is the NULL-terminated string containing the PEM encoding of + the client's private key. */ + const char* private_key; + + /** cert_chain is the NULL-terminated string containing the PEM encoding of + the client's certificate chain. */ + const char* cert_chain; +} grpc_ssl_pem_key_cert_pair; + +/** Creates a grpc_ssl_server_certificate_config object. + - pem_roots_cert is the NULL-terminated string containing the PEM encoding of + the client root certificates. This parameter may be NULL if the server does + not want the client to be authenticated with SSL. + - pem_key_cert_pairs is an array private key / certificate chains of the + server. This parameter cannot be NULL. + - num_key_cert_pairs indicates the number of items in the private_key_files + and cert_chain_files parameters. It must be at least 1. + - It is the caller's responsibility to free this object via + grpc_ssl_server_certificate_config_destroy(). */ +GRPCAPI grpc_ssl_server_certificate_config* +grpc_ssl_server_certificate_config_create( + const char* pem_root_certs, + const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, + size_t num_key_cert_pairs); + +/** Destroys a grpc_ssl_server_certificate_config object. */ +GRPCAPI void grpc_ssl_server_certificate_config_destroy( + grpc_ssl_server_certificate_config* config); + +/** Callback to retrieve updated SSL server certificates, private keys, and + trusted CAs (for client authentication). + - user_data parameter, if not NULL, contains opaque data to be used by the + callback. + - Use grpc_ssl_server_certificate_config_create to create the config. + - The caller assumes ownership of the config. */ +typedef grpc_ssl_certificate_config_reload_status ( + *grpc_ssl_server_certificate_config_callback)( + void* user_data, grpc_ssl_server_certificate_config** config); + +/** Deprecated in favor of grpc_ssl_verify_peer_options. It will be removed + after all of its call sites are migrated to grpc_ssl_verify_peer_options. + Object that holds additional peer-verification options on a secure + channel. */ +typedef struct { + /** If non-NULL this callback will be invoked with the expected + target_name, the peer's certificate (in PEM format), and whatever + userdata pointer is set below. If a non-zero value is returned by this + callback then it is treated as a verification failure. Invocation of + the callback is blocking, so any implementation should be light-weight. + */ + int (*verify_peer_callback)(const char* target_name, const char* peer_pem, + void* userdata); + /** Arbitrary userdata that will be passed as the last argument to + verify_peer_callback. */ + void* verify_peer_callback_userdata; + /** A destruct callback that will be invoked when the channel is being + cleaned up. The userdata argument will be passed to it. The intent is + to perform any cleanup associated with that userdata. */ + void (*verify_peer_destruct)(void* userdata); +} verify_peer_options; + +/** Object that holds additional peer-verification options on a secure + channel. */ +typedef struct { + /** If non-NULL this callback will be invoked with the expected + target_name, the peer's certificate (in PEM format), and whatever + userdata pointer is set below. If a non-zero value is returned by this + callback then it is treated as a verification failure. Invocation of + the callback is blocking, so any implementation should be light-weight. + */ + int (*verify_peer_callback)(const char* target_name, const char* peer_pem, + void* userdata); + /** Arbitrary userdata that will be passed as the last argument to + verify_peer_callback. */ + void* verify_peer_callback_userdata; + /** A destruct callback that will be invoked when the channel is being + cleaned up. The userdata argument will be passed to it. The intent is + to perform any cleanup associated with that userdata. */ + void (*verify_peer_destruct)(void* userdata); +} grpc_ssl_verify_peer_options; + +/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be + removed after all of its call sites are migrated to + grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object. + The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. + - pem_root_certs is the NULL-terminated string containing the PEM encoding + of the server root certificates. If this parameter is NULL, the + implementation will first try to dereference the file pointed by the + GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, + try to get the roots set by grpc_override_ssl_default_roots. Eventually, + if all these fail, it will try to get the roots from a well-known place on + disk (in the grpc install directory). + + gRPC has implemented root cache if the underlying OpenSSL library supports + it. The gRPC root certificates cache is only applicable on the default + root certificates, which is used when this parameter is nullptr. If user + provides their own pem_root_certs, when creating an SSL credential object, + gRPC would not be able to cache it, and each subchannel will generate a + copy of the root store. So it is recommended to avoid providing large room + pem with pem_root_certs parameter to avoid excessive memory consumption, + particularly on mobile platforms such as iOS. + - pem_key_cert_pair is a pointer on the object containing client's private + key and certificate chain. This parameter can be NULL if the client does + not have such a key/cert pair. + - verify_options is an optional verify_peer_options object which holds + additional options controlling how peer certificates are verified. For + example, you can supply a callback which receives the peer's certificate + with which you can do additional verification. Can be NULL, in which + case verification will retain default behavior. Any settings in + verify_options are copied during this call, so the verify_options + object can be released afterwards. */ +GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + const verify_peer_options* verify_options, void* reserved); + +/* Creates an SSL credentials object. + The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. + - pem_root_certs is the NULL-terminated string containing the PEM encoding + of the server root certificates. If this parameter is NULL, the + implementation will first try to dereference the file pointed by the + GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, + try to get the roots set by grpc_override_ssl_default_roots. Eventually, + if all these fail, it will try to get the roots from a well-known place on + disk (in the grpc install directory). + + gRPC has implemented root cache if the underlying OpenSSL library supports + it. The gRPC root certificates cache is only applicable on the default + root certificates, which is used when this parameter is nullptr. If user + provides their own pem_root_certs, when creating an SSL credential object, + gRPC would not be able to cache it, and each subchannel will generate a + copy of the root store. So it is recommended to avoid providing large room + pem with pem_root_certs parameter to avoid excessive memory consumption, + particularly on mobile platforms such as iOS. + - pem_key_cert_pair is a pointer on the object containing client's private + key and certificate chain. This parameter can be NULL if the client does + not have such a key/cert pair. + - verify_options is an optional verify_peer_options object which holds + additional options controlling how peer certificates are verified. For + example, you can supply a callback which receives the peer's certificate + with which you can do additional verification. Can be NULL, in which + case verification will retain default behavior. Any settings in + verify_options are copied during this call, so the verify_options + object can be released afterwards. */ +GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + const grpc_ssl_verify_peer_options* verify_options, void* reserved); + +/** --- server credentials --- */ + +/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. + Creates an SSL server_credentials object. + - pem_roots_cert is the NULL-terminated string containing the PEM encoding of + the client root certificates. This parameter may be NULL if the server does + not want the client to be authenticated with SSL. + - pem_key_cert_pairs is an array private key / certificate chains of the + server. This parameter cannot be NULL. + - num_key_cert_pairs indicates the number of items in the private_key_files + and cert_chain_files parameters. It should be at least 1. + - force_client_auth, if set to non-zero will force the client to authenticate + with an SSL cert. Note that this option is ignored if pem_root_certs is + NULL. */ +GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, + size_t num_key_cert_pairs, int force_client_auth, void* reserved); + +/** Deprecated in favor of grpc_ssl_server_credentials_create_with_options. + Same as grpc_ssl_server_credentials_create method except uses + grpc_ssl_client_certificate_request_type enum to support more ways to + authenticate client certificates.*/ +GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, + size_t num_key_cert_pairs, + grpc_ssl_client_certificate_request_type client_certificate_request, + void* reserved); + +typedef struct grpc_ssl_server_credentials_options + grpc_ssl_server_credentials_options; + +/** Creates an options object using a certificate config. Use this method when + the certificates and keys of the SSL server will not change during the + server's lifetime. + - Takes ownership of the certificate_config parameter. */ +GRPCAPI grpc_ssl_server_credentials_options* +grpc_ssl_server_credentials_create_options_using_config( + grpc_ssl_client_certificate_request_type client_certificate_request, + grpc_ssl_server_certificate_config* certificate_config); + +/** Creates an options object using a certificate config fetcher. Use this + method to reload the certificates and keys of the SSL server without + interrupting the operation of the server. Initial certificate config will be + fetched during server initialization. + - user_data parameter, if not NULL, contains opaque data which will be passed + to the fetcher (see definition of + grpc_ssl_server_certificate_config_callback). */ +GRPCAPI grpc_ssl_server_credentials_options* +grpc_ssl_server_credentials_create_options_using_config_fetcher( + grpc_ssl_client_certificate_request_type client_certificate_request, + grpc_ssl_server_certificate_config_callback cb, void* user_data); + +/** Destroys a grpc_ssl_server_credentials_options object. */ +GRPCAPI void grpc_ssl_server_credentials_options_destroy( + grpc_ssl_server_credentials_options* options); + +/** Creates an SSL server_credentials object using the provided options struct. + - Takes ownership of the options parameter. */ +GRPCAPI grpc_server_credentials* +grpc_ssl_server_credentials_create_with_options( + grpc_ssl_server_credentials_options* options); + +/** --- Auth Metadata Processing --- */ + +/** Callback function that is called when the metadata processing is done. + - Consumed metadata will be removed from the set of metadata available on the + call. consumed_md may be NULL if no metadata has been consumed. + - Response metadata will be set on the response. response_md may be NULL. + - status is GRPC_STATUS_OK for success or a specific status for an error. + Common error status for auth metadata processing is either + GRPC_STATUS_UNAUTHENTICATED in case of an authentication failure or + GRPC_STATUS PERMISSION_DENIED in case of an authorization failure. + - error_details gives details about the error. May be NULL. */ +typedef void (*grpc_process_auth_metadata_done_cb)( + void* user_data, const grpc_metadata* consumed_md, size_t num_consumed_md, + const grpc_metadata* response_md, size_t num_response_md, + grpc_status_code status, const char* error_details); + +/** Pluggable server-side metadata processor object. */ +typedef struct { + /** The context object is read/write: it contains the properties of the + channel peer and it is the job of the process function to augment it with + properties derived from the passed-in metadata. + The lifetime of these objects is guaranteed until cb is invoked. */ + void (*process)(void* state, grpc_auth_context* context, + const grpc_metadata* md, size_t num_md, + grpc_process_auth_metadata_done_cb cb, void* user_data); + void (*destroy)(void* state); + void* state; +} grpc_auth_metadata_processor; + +GRPCAPI void grpc_server_credentials_set_auth_metadata_processor( + grpc_server_credentials* creds, grpc_auth_metadata_processor processor); + +/** --- composite credentials --- */ + +/** Creates a composite call credentials object. */ +GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create( + grpc_call_credentials* creds1, grpc_call_credentials* creds2, + void* reserved); + +/** Creates a compute engine credentials object for connecting to Google. + WARNING: Do NOT use this credentials to connect to a non-google service as + this could result in an oauth2 token leak. */ +GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create( + void* reserved); + +/** Creates a composite channel credentials object. The security level of + * resulting connection is determined by channel_creds. */ +GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create( + grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, + void* reserved); + +/** --- ALTS channel/server credentials --- **/ + +/** + * Main interface for ALTS credentials options. The options will contain + * information that will be passed from grpc to TSI layer such as RPC protocol + * versions. ALTS client (channel) and server credentials will have their own + * implementation of this interface. The APIs listed in this header are + * thread-compatible. It is used for experimental purpose for now and subject + * to change. + */ +typedef struct grpc_alts_credentials_options grpc_alts_credentials_options; + +/** + * This method creates a grpc ALTS credentials client options instance. + * It is used for experimental purpose for now and subject to change. + */ +GRPCAPI grpc_alts_credentials_options* +grpc_alts_credentials_client_options_create(void); + +/** + * This method creates a grpc ALTS credentials server options instance. + * It is used for experimental purpose for now and subject to change. + */ +GRPCAPI grpc_alts_credentials_options* +grpc_alts_credentials_server_options_create(void); + +/** + * This method adds a target service account to grpc client's ALTS credentials + * options instance. It is used for experimental purpose for now and subject + * to change. + * + * - options: grpc ALTS credentials options instance. + * - service_account: service account of target endpoint. + */ +GRPCAPI void grpc_alts_credentials_client_options_add_target_service_account( + grpc_alts_credentials_options* options, const char* service_account); + +/** + * This method destroys a grpc_alts_credentials_options instance by + * de-allocating all of its occupied memory. It is used for experimental purpose + * for now and subject to change. + * + * - options: a grpc_alts_credentials_options instance that needs to be + * destroyed. + */ +GRPCAPI void grpc_alts_credentials_options_destroy( + grpc_alts_credentials_options* options); + +/** + * This method creates an ALTS channel credential object. The security + * level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. + * It is used for experimental purpose for now and subject to change. + * + * - options: grpc ALTS credentials options instance for client. + * + * It returns the created ALTS channel credential object. + */ +GRPCAPI grpc_channel_credentials* grpc_alts_credentials_create( + const grpc_alts_credentials_options* options); + +/** + * This method creates an ALTS server credential object. It is used for + * experimental purpose for now and subject to change. + * + * - options: grpc ALTS credentials options instance for server. + * + * It returns the created ALTS server credential object. + */ +GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create( + const grpc_alts_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * A struct that can be specified by callers to configure underlying TLS + * behaviors. + */ +typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; + +/** --- TLS channel/server credentials --- + * It is used for experimental purpose for now and subject to change. */ + +/** + * EXPERIMENTAL API - Subject to change + * + * A struct provides ways to gain credential data that will be used in the TLS + * handshake. + */ +typedef struct grpc_tls_certificate_provider grpc_tls_certificate_provider; + +/** + * EXPERIMENTAL API - Subject to change + * + * A struct that stores the credential data presented to the peer in handshake + * to show local identity. + */ +typedef struct grpc_tls_identity_pairs grpc_tls_identity_pairs; + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates a grpc_tls_identity_pairs that stores a list of identity credential + * data, including identity private key and identity certificate chain. + */ +GRPCAPI grpc_tls_identity_pairs* grpc_tls_identity_pairs_create(); + +/** + * EXPERIMENTAL API - Subject to change + * + * Adds a identity private key and a identity certificate chain to + * grpc_tls_identity_pairs. This function will make an internal copy of + * |private_key| and |cert_chain|. + */ +GRPCAPI void grpc_tls_identity_pairs_add_pair(grpc_tls_identity_pairs* pairs, + const char* private_key, + const char* cert_chain); + +/** + * EXPERIMENTAL API - Subject to change + * + * Destroys a grpc_tls_identity_pairs object. If this object is passed to a + * provider initiation function, the ownership is transferred so this function + * doesn't need to be called. Otherwise the creator of the + * grpc_tls_identity_pairs object is responsible for its destruction. + */ +GRPCAPI void grpc_tls_identity_pairs_destroy(grpc_tls_identity_pairs* pairs); + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates a grpc_tls_certificate_provider that will load credential data from + * static string during initialization. This provider will always return the + * same cert data for all cert names. + * root_certificate and pem_key_cert_pairs can be nullptr, indicating the + * corresponding credential data is not needed. + * This function will make a copy of |root_certificate|. + * The ownership of |pem_key_cert_pairs| is transferred. + */ +GRPCAPI grpc_tls_certificate_provider* +grpc_tls_certificate_provider_static_data_create( + const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs); + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates a grpc_tls_certificate_provider that will watch the credential + * changes on the file system. This provider will always return the up-to-date + * cert data for all the cert names callers set through + * |grpc_tls_credentials_options|. Note that this API only supports one key-cert + * file and hence one set of identity key-cert pair, so SNI(Server Name + * Indication) is not supported. + * - private_key_path is the file path of the private key. This must be set if + * |identity_certificate_path| is set. Otherwise, it could be null if no + * identity credentials are needed. + * - identity_certificate_path is the file path of the identity certificate + * chain. This must be set if |private_key_path| is set. Otherwise, it could + * be null if no identity credentials are needed. + * - root_cert_path is the file path to the root certificate bundle. This + * may be null if no root certs are needed. + * - refresh_interval_sec is the refreshing interval that we will check the + * files for updates. + * It does not take ownership of parameters. + */ +GRPCAPI grpc_tls_certificate_provider* +grpc_tls_certificate_provider_file_watcher_create( + const char* private_key_path, const char* identity_certificate_path, + const char* root_cert_path, unsigned int refresh_interval_sec); + +/** + * EXPERIMENTAL API - Subject to change + * + * Releases a grpc_tls_certificate_provider object. The creator of the + * grpc_tls_certificate_provider object is responsible for its release. + */ +GRPCAPI void grpc_tls_certificate_provider_release( + grpc_tls_certificate_provider* provider); + +/** + * EXPERIMENTAL API - Subject to change + * + * The read-only request information exposed in a verification call. + * Callers should not directly manage the ownership of it. We will make sure it + * is always available inside verify() or cancel() call, and will destroy the + * object at the end of custom verification. + */ +typedef struct grpc_tls_custom_verification_check_request { + /* The target name of the server when the client initiates the connection. */ + /* This field will be nullptr if on the server side. */ + const char* target_name; + /* The information contained in the certificate chain sent from the peer. */ + struct peer_info { + /* The Common Name field on the peer leaf certificate. */ + const char* common_name; + /* The list of Subject Alternative Names on the peer leaf certificate. */ + struct san_names { + char** uri_names; + size_t uri_names_size; + char** dns_names; + size_t dns_names_size; + char** email_names; + size_t email_names_size; + char** ip_names; + size_t ip_names_size; + } san_names; + /* The raw peer leaf certificate. */ + const char* peer_cert; + /* The raw peer certificate chain. Note that it is not always guaranteed to + * get the peer full chain. For more, please refer to + * GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME defined in file + * grpc_security_constants.h. + * TODO(ZhenLian): Consider fixing this in the future. */ + const char* peer_cert_full_chain; + /* The verified root cert subject. + * This value will only be filled if the cryptographic peer certificate + * verification was successful */ + const char* verified_root_cert_subject; + } peer_info; +} grpc_tls_custom_verification_check_request; + +/** + * EXPERIMENTAL API - Subject to change + * + * A callback function provided by gRPC as a parameter of the |verify| function + * in grpc_tls_certificate_verifier_external. If |verify| is expected to be run + * asynchronously, the implementer of |verify| will need to invoke this callback + * with |callback_arg| and proper verification status at the end to bring the + * control back to gRPC C core. + */ +typedef void (*grpc_tls_on_custom_verification_check_done_cb)( + grpc_tls_custom_verification_check_request* request, void* callback_arg, + grpc_status_code status, const char* error_details); + +/** + * EXPERIMENTAL API - Subject to change + * + * The internal verifier type that will be used inside core. + */ +typedef struct grpc_tls_certificate_verifier grpc_tls_certificate_verifier; + +/** + * EXPERIMENTAL API - Subject to change + * + * A struct containing all the necessary functions a custom external verifier + * needs to implement to be able to be converted to an internal verifier. + */ +typedef struct grpc_tls_certificate_verifier_external { + void* user_data; + /** + * A function pointer containing the verification logic that will be + * performed after the TLS handshake is done. It could be processed + * synchronously or asynchronously. + * - If expected to be processed synchronously, the implementer should + * populate the verification result through |sync_status| and + * |sync_error_details|, and then return true. + * - If expected to be processed asynchronously, the implementer should return + * false immediately, and then in the asynchronous thread invoke |callback| + * with the verification result. The implementer MUST NOT invoke the async + * |callback| in the same thread before |verify| returns, otherwise it can + * lead to deadlocks. + * + * user_data: any argument that is passed in the user_data of + * grpc_tls_certificate_verifier_external during construction time + * can be retrieved later here. + * request: request information exposed to the function implementer. + * callback: the callback that the function implementer needs to invoke, if + * return a non-zero value. It is usually invoked when the + * asynchronous verification is done, and serves to bring the + * control back to gRPC. + * callback_arg: A pointer to the internal ExternalVerifier instance. This is + * mainly used as an argument in |callback|, if want to invoke + * |callback| in async mode. + * sync_status: indicates if a connection should be allowed. This should only + * be used if the verification check is done synchronously. + * sync_error_details: the error generated while verifying a connection. This + * should only be used if the verification check is done + * synchronously. the implementation must allocate the + * error string via gpr_malloc() or gpr_strdup(). + * return: return 0 if |verify| is expected to be executed asynchronously, + * otherwise return a non-zero value. + */ + 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); + /** + * A function pointer that cleans up the caller-specified resources when the + * verifier is still running but the whole connection got cancelled. This + * could happen when the verifier is doing some async operations, and the + * whole handshaker object got destroyed because of connection time limit is + * reached, or any other reasons. In such cases, function implementers might + * want to be notified, and properly clean up some resources. + * + * user_data: any argument that is passed in the user_data of + * grpc_tls_certificate_verifier_external during construction time + * can be retrieved later here. + * request: request information exposed to the function implementer. It will + * be the same request object that was passed to verify(), and it + * tells the cancel() which request to cancel. + */ + void (*cancel)(void* user_data, + grpc_tls_custom_verification_check_request* request); + /** + * A function pointer that does some additional destruction work when the + * verifier is destroyed. This is used when the caller wants to associate some + * objects to the lifetime of external_verifier, and destroy them when + * external_verifier got destructed. For example, in C++, the class containing + * user-specified callback functions should not be destroyed before + * external_verifier, since external_verifier will invoke them while being + * used. + * Note that the caller MUST delete the grpc_tls_certificate_verifier_external + * object itself in this function, otherwise it will cause memory leaks. That + * also means the user_data has to carries at least a self pointer, for the + * callers to later delete it in destruct(). + * + * user_data: any argument that is passed in the user_data of + * grpc_tls_certificate_verifier_external during construction time + * can be retrieved later here. + */ + void (*destruct)(void* user_data); +} grpc_tls_certificate_verifier_external; + +/** + * EXPERIMENTAL API - Subject to change + * + * Converts an external verifier to an internal verifier. + * Note that we will not take the ownership of the external_verifier. Callers + * will need to delete external_verifier in its own destruct function. + */ +grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_external_create( + grpc_tls_certificate_verifier_external* external_verifier); + +/** + * EXPERIMENTAL API - Subject to change + * + * Factory function for an internal verifier that won't perform any + * post-handshake verification. Note: using this solely without any other + * authentication mechanisms on the peer identity will leave your applications + * to the MITM(Man-In-The-Middle) attacks. Users should avoid doing so in + * production environments. + */ +grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_no_op_create(); + +/** + * EXPERIMENTAL API - Subject to change + * + * Factory function for an internal verifier that will do the default hostname + * check. + */ +grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_host_name_create(); + +/** + * EXPERIMENTAL API - Subject to change + * + * Releases a grpc_tls_certificate_verifier object. The creator of the + * grpc_tls_certificate_verifier object is responsible for its release. + */ +void grpc_tls_certificate_verifier_release( + grpc_tls_certificate_verifier* verifier); + +/** + * EXPERIMENTAL API - Subject to change + * + * Performs the verification logic of an internal verifier. + * This is typically used when composing the internal verifiers as part of the + * custom verification. + * If |grpc_tls_certificate_verifier_verify| returns true, inspect the + * verification result through request->status and request->error_details. + * Otherwise, inspect through the parameter of |callback|. + */ +int grpc_tls_certificate_verifier_verify( + grpc_tls_certificate_verifier* verifier, + 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); + +/** + * EXPERIMENTAL API - Subject to change + * + * Performs the cancellation logic of an internal verifier. + * This is typically used when composing the internal verifiers as part of the + * custom verification. + */ +void grpc_tls_certificate_verifier_cancel( + grpc_tls_certificate_verifier* verifier, + grpc_tls_custom_verification_check_request* request); + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates an grpc_tls_credentials_options. + */ +GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void); + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates a TLS channel credential object based on the + * grpc_tls_credentials_options specified by callers. The + * grpc_channel_credentials will take the ownership of the |options|. The + * security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. + */ +grpc_channel_credentials* grpc_tls_credentials_create( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * Creates a TLS server credential object based on the + * grpc_tls_credentials_options specified by callers. The + * grpc_server_credentials will take the ownership of the |options|. + */ +grpc_server_credentials* grpc_tls_server_credentials_create( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the minimum TLS version that will be negotiated during the TLS + * handshake. If not set, the underlying SSL library will set it to TLS v1.2. + */ +GRPCAPI void grpc_tls_credentials_options_set_min_tls_version( + grpc_tls_credentials_options* options, grpc_tls_version min_tls_version); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the maximum TLS version that will be negotiated during the TLS + * handshake. If not set, the underlying SSL library will set it to TLS v1.3. + */ +GRPCAPI void grpc_tls_credentials_options_set_max_tls_version( + grpc_tls_credentials_options* options, grpc_tls_version max_tls_version); + +/** + * EXPERIMENTAL API - Subject to change + * + * Copies a grpc_tls_credentials_options. + */ +GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_copy( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * Destroys a grpc_tls_credentials_options. + */ +GRPCAPI void grpc_tls_credentials_options_destroy( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * A struct provides ways to gain credential data that will be used in the TLS + * handshake. + */ +typedef struct grpc_tls_certificate_provider grpc_tls_certificate_provider; + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the credential provider in the options. + * The |options| will implicitly take a new ref to the |provider|. + */ +GRPCAPI void grpc_tls_credentials_options_set_certificate_provider( + grpc_tls_credentials_options* options, + grpc_tls_certificate_provider* provider); + +/** + * EXPERIMENTAL API - Subject to change + * + * If set, gRPC stack will keep watching the root certificates with + * name |root_cert_name|. + * If this is not set on the client side, we will use the root certificates + * stored in the default system location, since client side must provide root + * certificates in TLS. + * If this is not set on the server side, we will not watch any root certificate + * updates, and assume no root certificates needed for the server(single-side + * TLS). Default root certs on the server side is not supported. + */ +GRPCAPI void grpc_tls_credentials_options_watch_root_certs( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the name of the root certificates being watched. + * If not set, We will use a default empty string as the root certificate name. + */ +GRPCAPI void grpc_tls_credentials_options_set_root_cert_name( + grpc_tls_credentials_options* options, const char* root_cert_name); + +/** + * EXPERIMENTAL API - Subject to change + * + * If set, gRPC stack will keep watching the identity key-cert pairs + * with name |identity_cert_name|. + * This is required on the server side, and optional on the client side. + */ +GRPCAPI void grpc_tls_credentials_options_watch_identity_key_cert_pairs( + grpc_tls_credentials_options* options); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the name of the identity certificates being watched. + * If not set, We will use a default empty string as the identity certificate + * name. + */ +GRPCAPI void grpc_tls_credentials_options_set_identity_cert_name( + grpc_tls_credentials_options* options, const char* identity_cert_name); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the options of whether to request and/or verify client certs. This shall + * only be called on the server side. + */ +GRPCAPI void grpc_tls_credentials_options_set_cert_request_type( + grpc_tls_credentials_options* options, + grpc_ssl_client_certificate_request_type type); + +/** Deprecated in favor of grpc_tls_credentials_options_set_crl_provider. The + * crl provider interface provides a significantly more flexible approach to + * using CRLs. See gRFC A69 for details. + * EXPERIMENTAL API - Subject to change + * + * If set, gRPC will read all hashed x.509 CRL files in the directory and + * enforce the CRL files on all TLS handshakes. Only supported for OpenSSL + * version > 1.1. + * It is used for experimental purpose for now and subject to change. + */ +GRPCAPI void grpc_tls_credentials_options_set_crl_directory( + grpc_tls_credentials_options* options, const char* crl_directory); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the options of whether to verify server certs on the client side. + * Passing in a non-zero value indicates verifying the certs. + */ +GRPCAPI void grpc_tls_credentials_options_set_verify_server_cert( + grpc_tls_credentials_options* options, int verify_server_cert); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets whether or not a TLS server should send a list of CA names in the + * ServerHello. This list of CA names is read from the server's trust bundle, so + * that the client can use this list as a hint to know which certificate it + * should send to the server. + * + * WARNING: This API is extremely dangerous and should not be used. If the + * server's trust bundle is too large, then the TLS server will be unable to + * form a ServerHello, and hence will be unusable. The definition of "too large" + * depends on the underlying SSL library being used and on the size of the CN + * fields of the certificates in the trust bundle. + */ +GRPCAPI void grpc_tls_credentials_options_set_send_client_ca_list( + grpc_tls_credentials_options* options, bool send_client_ca_list); + +/** --- SSL Session Cache. --- + + A SSL session cache object represents a way to cache client sessions + between connections. Only ticket-based resumption is supported. */ + +typedef struct grpc_ssl_session_cache grpc_ssl_session_cache; + +/** Create LRU cache for client-side SSL sessions with the given capacity. + If capacity is < 1, a default capacity is used instead. */ +GRPCAPI grpc_ssl_session_cache* grpc_ssl_session_cache_create_lru( + size_t capacity); + +/** Destroy SSL session cache. */ +GRPCAPI void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache); + +/** Create a channel arg with the given cache object. */ +GRPCAPI grpc_arg +grpc_ssl_session_cache_create_channel_arg(grpc_ssl_session_cache* cache); + +/** Callback for getting the SSL roots override from the application. + In case of success, *pem_roots_certs must be set to a NULL terminated string + containing the list of PEM encoded root certificates. The ownership is passed + to the core and freed (laster by the core) with gpr_free. + If this function fails and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is + set to a valid path, it will override the roots specified this func */ +typedef grpc_ssl_roots_override_result (*grpc_ssl_roots_override_callback)( + char** pem_root_certs); + +/** Setup a callback to override the default TLS/SSL roots. + This function is not thread-safe and must be called at initialization time + before any ssl credentials are created to have the desired side effect. + If GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is set to a valid path, the + callback will not be called. */ +GRPCAPI void grpc_set_ssl_roots_override_callback( + grpc_ssl_roots_override_callback cb); + +GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(void); + +/** --- insecure credentials --- */ + +/** + * EXPERIMENTAL API - Subject to change + * + * This method creates an insecure channel credentials object. + */ +GRPCAPI grpc_channel_credentials* grpc_insecure_credentials_create(); + +/** + * EXPERIMENTAL API - Subject to change + * + * This method creates an insecure server credentials object. + */ +GRPCAPI grpc_server_credentials* grpc_insecure_server_credentials_create(); + +/** + * EXPERIMENTAL API - Subject to change + * + * This method creates an xDS channel credentials object. + * + * Creating a channel with credentials of this type indicates that the channel + * should get credentials configuration from the xDS control plane. + * + * \a fallback_credentials are used if the channel target does not have the + * 'xds:///' scheme or if the xDS control plane does not provide information on + * how to fetch credentials dynamically. Does NOT take ownership of the \a + * fallback_credentials. (Internally takes a ref to the object.) + */ +GRPCAPI grpc_channel_credentials* grpc_xds_credentials_create( + grpc_channel_credentials* fallback_credentials); + +/** + * EXPERIMENTAL API - Subject to change + * + * This method creates an xDS server credentials object. + * + * \a fallback_credentials are used if the xDS control plane does not provide + * information on how to fetch credentials dynamically. + * + * Does NOT take ownership of the \a fallback_credentials. (Internally takes + * a ref to the object.) + */ +GRPCAPI grpc_server_credentials* grpc_xds_server_credentials_create( + grpc_server_credentials* fallback_credentials); + +/** --- Local channel/server credentials --- **/ + +/** + * This method creates a local channel credential object. The security level + * of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY for UDS and + * GRPC_SECURITY_NONE for LOCAL_TCP. It is used for experimental purpose + * for now and subject to change. + * + * - type: local connection type + * + * It returns the created local channel credential object. + */ +GRPCAPI grpc_channel_credentials* grpc_local_credentials_create( + grpc_local_connect_type type); + +/** + * This method creates a local server credential object. It is used for + * experimental purpose for now and subject to change. + * + * - type: local connection type + * + * It returns the created local server credential object. + */ +GRPCAPI grpc_server_credentials* grpc_local_server_credentials_create( + grpc_local_connect_type type); + +/** + * EXPERIMENTAL API - Subject to change + * + * The internal verifier type that will be used inside core. + */ +typedef struct grpc_tls_certificate_verifier grpc_tls_certificate_verifier; + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the verifier in options. The |options| will implicitly take a new ref to + * the |verifier|. If not set on the client side, we will verify server's + * certificates, and check the default hostname. If not set on the server side, + * we will verify client's certificates. + */ +void grpc_tls_credentials_options_set_certificate_verifier( + grpc_tls_credentials_options* options, + grpc_tls_certificate_verifier* verifier); + +/** + * EXPERIMENTAL API - Subject to change + * + * Sets the options of whether to check the hostname of the peer on a per-call + * basis. This is usually used in a combination with virtual hosting at the + * client side, where each individual call on a channel can have a different + * host associated with it. + * This check is intended to verify that the host specified for the individual + * call is covered by the cert that the peer presented. + * The default is a non-zero value, which indicates performing such checks. + */ +GRPCAPI void grpc_tls_credentials_options_set_check_call_host( + grpc_tls_credentials_options* options, int check_call_host); + +/** --- TLS session key logging. --- + * Experimental API to control tls session key logging. Tls session key logging + * is expected to be used only for debugging purposes and never in production. + * Tls session key logging is only enabled when: + * At least one grpc_tls_credentials_options object is assigned a tls session + * key logging file path using the API specified below. + */ + +/** + * EXPERIMENTAL API - Subject to change. + * Configures a grpc_tls_credentials_options object with tls session key + * logging capability. TLS channels using these credentials have tls session + * key logging enabled. + * - options is the grpc_tls_credentials_options object + * - path is a string pointing to the location where TLS session keys would be + * stored. + */ +GRPCAPI void grpc_tls_credentials_options_set_tls_session_key_log_file_path( + grpc_tls_credentials_options* options, const char* path); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CREDENTIALS_H */ diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 20527730358..d293907eac0 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -361,6 +361,13 @@ GRPCAPI void grpc_call_ref(grpc_call* call); THREAD SAFETY: grpc_call_unref is thread-compatible */ GRPCAPI void grpc_call_unref(grpc_call* call); +typedef struct grpc_call_credentials grpc_call_credentials; + +/** Sets a credentials to a call. Can only be called on the client side before + grpc_call_start_batch. */ +GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call, + grpc_call_credentials* creds); + /** Request notification of a new call. Once a call is received, a notification tagged with \a tag_new is added to \a cq_for_notification. \a call, \a details and \a request_metadata are diff --git a/include/grpc/grpc_crl_provider.h b/include/grpc/grpc_crl_provider.h index 04e8ffa0901..35d6df6f939 100644 --- a/include/grpc/grpc_crl_provider.h +++ b/include/grpc/grpc_crl_provider.h @@ -25,6 +25,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include #include #include diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 5524170a2ac..11e08a6f4a1 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -101,1157 +101,6 @@ GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context* ctx, GRPCAPI int grpc_auth_context_set_peer_identity_property_name( grpc_auth_context* ctx, const char* name); -/** --- SSL Session Cache. --- - - A SSL session cache object represents a way to cache client sessions - between connections. Only ticket-based resumption is supported. */ - -typedef struct grpc_ssl_session_cache grpc_ssl_session_cache; - -/** Create LRU cache for client-side SSL sessions with the given capacity. - If capacity is < 1, a default capacity is used instead. */ -GRPCAPI grpc_ssl_session_cache* grpc_ssl_session_cache_create_lru( - size_t capacity); - -/** Destroy SSL session cache. */ -GRPCAPI void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache); - -/** Create a channel arg with the given cache object. */ -GRPCAPI grpc_arg -grpc_ssl_session_cache_create_channel_arg(grpc_ssl_session_cache* cache); - -/** --- grpc_call_credentials object. - - A call credentials object represents a way to authenticate on a particular - call. These credentials can be composed with a channel credentials object - so that they are sent with every call on this channel. */ - -typedef struct grpc_call_credentials grpc_call_credentials; - -/** Releases a call credentials object. - The creator of the credentials object is responsible for its release. */ -GRPCAPI void grpc_call_credentials_release(grpc_call_credentials* creds); - -/** Creates default credentials to connect to a google gRPC service. - WARNING: Do NOT use this credentials to connect to a non-google service as - this could result in an oauth2 token leak. The security level of the - resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - - If specified, the supplied call credentials object will be attached to the - returned channel credentials object. The call_credentials object must remain - valid throughout the lifetime of the returned grpc_channel_credentials - object. It is expected that the call credentials object was generated - according to the Application Default Credentials mechanism and asserts the - identity of the default service account of the machine. Supplying any other - sort of call credential will result in undefined behavior, up to and - including the sudden and unexpected failure of RPCs. - - If nullptr is supplied, the returned channel credentials object will use a - call credentials object based on the Application Default Credentials - mechanism. -*/ -GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create( - grpc_call_credentials* call_credentials); - -/** Callback for getting the SSL roots override from the application. - In case of success, *pem_roots_certs must be set to a NULL terminated string - containing the list of PEM encoded root certificates. The ownership is passed - to the core and freed (laster by the core) with gpr_free. - If this function fails and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is - set to a valid path, it will override the roots specified this func */ -typedef grpc_ssl_roots_override_result (*grpc_ssl_roots_override_callback)( - char** pem_root_certs); - -/** Setup a callback to override the default TLS/SSL roots. - This function is not thread-safe and must be called at initialization time - before any ssl credentials are created to have the desired side effect. - If GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is set to a valid path, the - callback will not be called. */ -GRPCAPI void grpc_set_ssl_roots_override_callback( - grpc_ssl_roots_override_callback cb); - -/** Object that holds a private key / certificate chain pair in PEM format. */ -typedef struct { - /** private_key is the NULL-terminated string containing the PEM encoding of - the client's private key. */ - const char* private_key; - - /** cert_chain is the NULL-terminated string containing the PEM encoding of - the client's certificate chain. */ - const char* cert_chain; -} grpc_ssl_pem_key_cert_pair; - -/** Deprecated in favor of grpc_ssl_verify_peer_options. It will be removed - after all of its call sites are migrated to grpc_ssl_verify_peer_options. - Object that holds additional peer-verification options on a secure - channel. */ -typedef struct { - /** If non-NULL this callback will be invoked with the expected - target_name, the peer's certificate (in PEM format), and whatever - userdata pointer is set below. If a non-zero value is returned by this - callback then it is treated as a verification failure. Invocation of - the callback is blocking, so any implementation should be light-weight. - */ - int (*verify_peer_callback)(const char* target_name, const char* peer_pem, - void* userdata); - /** Arbitrary userdata that will be passed as the last argument to - verify_peer_callback. */ - void* verify_peer_callback_userdata; - /** A destruct callback that will be invoked when the channel is being - cleaned up. The userdata argument will be passed to it. The intent is - to perform any cleanup associated with that userdata. */ - void (*verify_peer_destruct)(void* userdata); -} verify_peer_options; - -/** Object that holds additional peer-verification options on a secure - channel. */ -typedef struct { - /** If non-NULL this callback will be invoked with the expected - target_name, the peer's certificate (in PEM format), and whatever - userdata pointer is set below. If a non-zero value is returned by this - callback then it is treated as a verification failure. Invocation of - the callback is blocking, so any implementation should be light-weight. - */ - int (*verify_peer_callback)(const char* target_name, const char* peer_pem, - void* userdata); - /** Arbitrary userdata that will be passed as the last argument to - verify_peer_callback. */ - void* verify_peer_callback_userdata; - /** A destruct callback that will be invoked when the channel is being - cleaned up. The userdata argument will be passed to it. The intent is - to perform any cleanup associated with that userdata. */ - void (*verify_peer_destruct)(void* userdata); -} grpc_ssl_verify_peer_options; - -/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be - removed after all of its call sites are migrated to - grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object. - The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - - pem_root_certs is the NULL-terminated string containing the PEM encoding - of the server root certificates. If this parameter is NULL, the - implementation will first try to dereference the file pointed by the - GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, - try to get the roots set by grpc_override_ssl_default_roots. Eventually, - if all these fail, it will try to get the roots from a well-known place on - disk (in the grpc install directory). - - gRPC has implemented root cache if the underlying OpenSSL library supports - it. The gRPC root certificates cache is only applicable on the default - root certificates, which is used when this parameter is nullptr. If user - provides their own pem_root_certs, when creating an SSL credential object, - gRPC would not be able to cache it, and each subchannel will generate a - copy of the root store. So it is recommended to avoid providing large room - pem with pem_root_certs parameter to avoid excessive memory consumption, - particularly on mobile platforms such as iOS. - - pem_key_cert_pair is a pointer on the object containing client's private - key and certificate chain. This parameter can be NULL if the client does - not have such a key/cert pair. - - verify_options is an optional verify_peer_options object which holds - additional options controlling how peer certificates are verified. For - example, you can supply a callback which receives the peer's certificate - with which you can do additional verification. Can be NULL, in which - case verification will retain default behavior. Any settings in - verify_options are copied during this call, so the verify_options - object can be released afterwards. */ -GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create( - const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const verify_peer_options* verify_options, void* reserved); - -/* Creates an SSL credentials object. - The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - - pem_root_certs is the NULL-terminated string containing the PEM encoding - of the server root certificates. If this parameter is NULL, the - implementation will first try to dereference the file pointed by the - GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, - try to get the roots set by grpc_override_ssl_default_roots. Eventually, - if all these fail, it will try to get the roots from a well-known place on - disk (in the grpc install directory). - - gRPC has implemented root cache if the underlying OpenSSL library supports - it. The gRPC root certificates cache is only applicable on the default - root certificates, which is used when this parameter is nullptr. If user - provides their own pem_root_certs, when creating an SSL credential object, - gRPC would not be able to cache it, and each subchannel will generate a - copy of the root store. So it is recommended to avoid providing large room - pem with pem_root_certs parameter to avoid excessive memory consumption, - particularly on mobile platforms such as iOS. - - pem_key_cert_pair is a pointer on the object containing client's private - key and certificate chain. This parameter can be NULL if the client does - not have such a key/cert pair. - - verify_options is an optional verify_peer_options object which holds - additional options controlling how peer certificates are verified. For - example, you can supply a callback which receives the peer's certificate - with which you can do additional verification. Can be NULL, in which - case verification will retain default behavior. Any settings in - verify_options are copied during this call, so the verify_options - object can be released afterwards. */ -GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create_ex( - const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const grpc_ssl_verify_peer_options* verify_options, void* reserved); - -/** Creates a composite channel credentials object. The security level of - * resulting connection is determined by channel_creds. */ -GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create( - grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, - void* reserved); - -/** --- composite credentials. */ - -/** Creates a composite call credentials object. */ -GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create( - grpc_call_credentials* creds1, grpc_call_credentials* creds2, - void* reserved); - -/** Creates a compute engine credentials object for connecting to Google. - WARNING: Do NOT use this credentials to connect to a non-google service as - this could result in an oauth2 token leak. */ -GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create( - void* reserved); - -GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(void); - -/** Creates a JWT credentials object. May return NULL if the input is invalid. - - json_key is the JSON key string containing the client's private key. - - token_lifetime is the lifetime of each Json Web Token (JWT) created with - this credentials. It should not exceed grpc_max_auth_token_lifetime or - will be cropped to this value. */ -GRPCAPI grpc_call_credentials* -grpc_service_account_jwt_access_credentials_create(const char* json_key, - gpr_timespec token_lifetime, - void* reserved); - -/** Builds External Account credentials. - - json_string is the JSON string containing the credentials options. - - scopes_string contains the scopes to be binded with the credentials. - This API is used for experimental purposes for now and may change in the - future. */ -GRPCAPI grpc_call_credentials* grpc_external_account_credentials_create( - const char* json_string, const char* scopes_string); - -/** Creates an Oauth2 Refresh Token credentials object for connecting to Google. - May return NULL if the input is invalid. - WARNING: Do NOT use this credentials to connect to a non-google service as - this could result in an oauth2 token leak. - - json_refresh_token is the JSON string containing the refresh token itself - along with a client_id and client_secret. */ -GRPCAPI grpc_call_credentials* grpc_google_refresh_token_credentials_create( - const char* json_refresh_token, void* reserved); - -/** Creates an Oauth2 Access Token credentials with an access token that was - acquired by an out of band mechanism. */ -GRPCAPI grpc_call_credentials* grpc_access_token_credentials_create( - const char* access_token, void* reserved); - -/** Creates an IAM credentials object for connecting to Google. */ -GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( - const char* authorization_token, const char* authority_selector, - void* reserved); - -/** Options for creating STS Oauth Token Exchange credentials following the IETF - draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - Optional fields may be set to NULL or empty string. It is the responsibility - of the caller to ensure that the subject and actor tokens are refreshed on - disk at the specified paths. This API is used for experimental purposes for - now and may change in the future. */ -typedef struct { - const char* token_exchange_service_uri; /* Required. */ - const char* resource; /* Optional. */ - const char* audience; /* Optional. */ - const char* scope; /* Optional. */ - const char* requested_token_type; /* Optional. */ - const char* subject_token_path; /* Required. */ - const char* subject_token_type; /* Required. */ - const char* actor_token_path; /* Optional. */ - const char* actor_token_type; /* Optional. */ -} grpc_sts_credentials_options; - -/** Creates an STS credentials following the STS Token Exchanged specifed in the - IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - This API is used for experimental purposes for now and may change in the - future. */ -GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( - const grpc_sts_credentials_options* options, void* reserved); - -/** Callback function to be called by the metadata credentials plugin - implementation when the metadata is ready. - - user_data is the opaque pointer that was passed in the get_metadata method - of the grpc_metadata_credentials_plugin (see below). - - creds_md is an array of credentials metadata produced by the plugin. It - may be set to NULL in case of an error. - - num_creds_md is the number of items in the creds_md array. - - status must be GRPC_STATUS_OK in case of success or another specific error - code otherwise. - - error_details contains details about the error if any. In case of success - it should be NULL and will be otherwise ignored. */ -typedef void (*grpc_credentials_plugin_metadata_cb)( - void* user_data, const grpc_metadata* creds_md, size_t num_creds_md, - grpc_status_code status, const char* error_details); - -/** Context that can be used by metadata credentials plugin in order to create - auth related metadata. */ -typedef struct { - /** The fully qualifed service url. */ - const char* service_url; - - /** The method name of the RPC being called (not fully qualified). - The fully qualified method name can be built from the service_url: - full_qualified_method_name = ctx->service_url + '/' + ctx->method_name. */ - const char* method_name; - - /** The auth_context of the channel which gives the server's identity. */ - const grpc_auth_context* channel_auth_context; - - /** Reserved for future use. */ - void* reserved; -} grpc_auth_metadata_context; - -/** Performs a deep copy from \a from to \a to. **/ -GRPCAPI void grpc_auth_metadata_context_copy(grpc_auth_metadata_context* from, - grpc_auth_metadata_context* to); - -/** Releases internal resources held by \a context. **/ -GRPCAPI void grpc_auth_metadata_context_reset( - grpc_auth_metadata_context* context); - -/** Maximum number of metadata entries returnable by a credentials plugin via - a synchronous return. */ -#define GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX 4 - -/** grpc_metadata_credentials plugin is an API user provided structure used to - create grpc_credentials objects that can be set on a channel (composed) or - a call. See grpc_credentials_metadata_create_from_plugin below. - The grpc client stack will call the get_metadata method of the plugin for - every call in scope for the credentials created from it. */ -typedef struct { - /** The implementation of this method has to be non-blocking, but can - be performed synchronously or asynchronously. - - If processing occurs synchronously, returns non-zero and populates - creds_md, num_creds_md, status, and error_details. In this case, - the caller takes ownership of the entries in creds_md and of - error_details. Note that if the plugin needs to return more than - GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX entries in creds_md, it must - return asynchronously. - - If processing occurs asynchronously, returns zero and invokes \a cb - when processing is completed. \a user_data will be passed as the - first parameter of the callback. NOTE: \a cb MUST be invoked in a - different thread, not from the thread in which \a get_metadata() is - invoked. - - \a context is the information that can be used by the plugin to create - auth metadata. */ - int (*get_metadata)( - void* state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void* user_data, - grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t* num_creds_md, grpc_status_code* status, - const char** error_details); - - /** Implements debug string of the given plugin. This method returns an - * allocated string that the caller needs to free using gpr_free() */ - char* (*debug_string)(void* state); - - /** Destroys the plugin state. */ - void (*destroy)(void* state); - - /** State that will be set as the first parameter of the methods above. */ - void* state; - - /** Type of credentials that this plugin is implementing. */ - const char* type; -} grpc_metadata_credentials_plugin; - -/** Creates a credentials object from a plugin with a specified minimum security - * level. */ -GRPCAPI grpc_call_credentials* grpc_metadata_credentials_create_from_plugin( - grpc_metadata_credentials_plugin plugin, - grpc_security_level min_security_level, void* reserved); - -/** Server certificate config object holds the server's public certificates and - associated private keys, as well as any CA certificates needed for client - certificate validation (if applicable). Create using - grpc_ssl_server_certificate_config_create(). */ -typedef struct grpc_ssl_server_certificate_config - grpc_ssl_server_certificate_config; - -/** Creates a grpc_ssl_server_certificate_config object. - - pem_roots_cert is the NULL-terminated string containing the PEM encoding of - the client root certificates. This parameter may be NULL if the server does - not want the client to be authenticated with SSL. - - pem_key_cert_pairs is an array private key / certificate chains of the - server. This parameter cannot be NULL. - - num_key_cert_pairs indicates the number of items in the private_key_files - and cert_chain_files parameters. It must be at least 1. - - It is the caller's responsibility to free this object via - grpc_ssl_server_certificate_config_destroy(). */ -GRPCAPI grpc_ssl_server_certificate_config* -grpc_ssl_server_certificate_config_create( - const char* pem_root_certs, - const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, - size_t num_key_cert_pairs); - -/** Destroys a grpc_ssl_server_certificate_config object. */ -GRPCAPI void grpc_ssl_server_certificate_config_destroy( - grpc_ssl_server_certificate_config* config); - -/** Callback to retrieve updated SSL server certificates, private keys, and - trusted CAs (for client authentication). - - user_data parameter, if not NULL, contains opaque data to be used by the - callback. - - Use grpc_ssl_server_certificate_config_create to create the config. - - The caller assumes ownership of the config. */ -typedef grpc_ssl_certificate_config_reload_status ( - *grpc_ssl_server_certificate_config_callback)( - void* user_data, grpc_ssl_server_certificate_config** config); - -/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. - Creates an SSL server_credentials object. - - pem_roots_cert is the NULL-terminated string containing the PEM encoding of - the client root certificates. This parameter may be NULL if the server does - not want the client to be authenticated with SSL. - - pem_key_cert_pairs is an array private key / certificate chains of the - server. This parameter cannot be NULL. - - num_key_cert_pairs indicates the number of items in the private_key_files - and cert_chain_files parameters. It should be at least 1. - - force_client_auth, if set to non-zero will force the client to authenticate - with an SSL cert. Note that this option is ignored if pem_root_certs is - NULL. */ -GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create( - const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, - size_t num_key_cert_pairs, int force_client_auth, void* reserved); - -/** Deprecated in favor of grpc_ssl_server_credentials_create_with_options. - Same as grpc_ssl_server_credentials_create method except uses - grpc_ssl_client_certificate_request_type enum to support more ways to - authenticate client certificates.*/ -GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex( - const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, - size_t num_key_cert_pairs, - grpc_ssl_client_certificate_request_type client_certificate_request, - void* reserved); - -typedef struct grpc_ssl_server_credentials_options - grpc_ssl_server_credentials_options; - -/** Creates an options object using a certificate config. Use this method when - the certificates and keys of the SSL server will not change during the - server's lifetime. - - Takes ownership of the certificate_config parameter. */ -GRPCAPI grpc_ssl_server_credentials_options* -grpc_ssl_server_credentials_create_options_using_config( - grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config* certificate_config); - -/** Creates an options object using a certificate config fetcher. Use this - method to reload the certificates and keys of the SSL server without - interrupting the operation of the server. Initial certificate config will be - fetched during server initialization. - - user_data parameter, if not NULL, contains opaque data which will be passed - to the fetcher (see definition of - grpc_ssl_server_certificate_config_callback). */ -GRPCAPI grpc_ssl_server_credentials_options* -grpc_ssl_server_credentials_create_options_using_config_fetcher( - grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config_callback cb, void* user_data); - -/** Destroys a grpc_ssl_server_credentials_options object. */ -GRPCAPI void grpc_ssl_server_credentials_options_destroy( - grpc_ssl_server_credentials_options* options); - -/** Creates an SSL server_credentials object using the provided options struct. - - Takes ownership of the options parameter. */ -GRPCAPI grpc_server_credentials* -grpc_ssl_server_credentials_create_with_options( - grpc_ssl_server_credentials_options* options); - -/** --- Call specific credentials. --- */ - -/** Sets a credentials to a call. Can only be called on the client side before - grpc_call_start_batch. */ -GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call, - grpc_call_credentials* creds); - -/** --- Auth Metadata Processing --- */ - -/** Callback function that is called when the metadata processing is done. - - Consumed metadata will be removed from the set of metadata available on the - call. consumed_md may be NULL if no metadata has been consumed. - - Response metadata will be set on the response. response_md may be NULL. - - status is GRPC_STATUS_OK for success or a specific status for an error. - Common error status for auth metadata processing is either - GRPC_STATUS_UNAUTHENTICATED in case of an authentication failure or - GRPC_STATUS PERMISSION_DENIED in case of an authorization failure. - - error_details gives details about the error. May be NULL. */ -typedef void (*grpc_process_auth_metadata_done_cb)( - void* user_data, const grpc_metadata* consumed_md, size_t num_consumed_md, - const grpc_metadata* response_md, size_t num_response_md, - grpc_status_code status, const char* error_details); - -/** Pluggable server-side metadata processor object. */ -typedef struct { - /** The context object is read/write: it contains the properties of the - channel peer and it is the job of the process function to augment it with - properties derived from the passed-in metadata. - The lifetime of these objects is guaranteed until cb is invoked. */ - void (*process)(void* state, grpc_auth_context* context, - const grpc_metadata* md, size_t num_md, - grpc_process_auth_metadata_done_cb cb, void* user_data); - void (*destroy)(void* state); - void* state; -} grpc_auth_metadata_processor; - -GRPCAPI void grpc_server_credentials_set_auth_metadata_processor( - grpc_server_credentials* creds, grpc_auth_metadata_processor processor); - -/** --- ALTS channel/server credentials --- **/ - -/** - * Main interface for ALTS credentials options. The options will contain - * information that will be passed from grpc to TSI layer such as RPC protocol - * versions. ALTS client (channel) and server credentials will have their own - * implementation of this interface. The APIs listed in this header are - * thread-compatible. It is used for experimental purpose for now and subject - * to change. - */ -typedef struct grpc_alts_credentials_options grpc_alts_credentials_options; - -/** - * This method creates a grpc ALTS credentials client options instance. - * It is used for experimental purpose for now and subject to change. - */ -GRPCAPI grpc_alts_credentials_options* -grpc_alts_credentials_client_options_create(void); - -/** - * This method creates a grpc ALTS credentials server options instance. - * It is used for experimental purpose for now and subject to change. - */ -GRPCAPI grpc_alts_credentials_options* -grpc_alts_credentials_server_options_create(void); - -/** - * This method adds a target service account to grpc client's ALTS credentials - * options instance. It is used for experimental purpose for now and subject - * to change. - * - * - options: grpc ALTS credentials options instance. - * - service_account: service account of target endpoint. - */ -GRPCAPI void grpc_alts_credentials_client_options_add_target_service_account( - grpc_alts_credentials_options* options, const char* service_account); - -/** - * This method destroys a grpc_alts_credentials_options instance by - * de-allocating all of its occupied memory. It is used for experimental purpose - * for now and subject to change. - * - * - options: a grpc_alts_credentials_options instance that needs to be - * destroyed. - */ -GRPCAPI void grpc_alts_credentials_options_destroy( - grpc_alts_credentials_options* options); - -/** - * This method creates an ALTS channel credential object. The security - * level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - * It is used for experimental purpose for now and subject to change. - * - * - options: grpc ALTS credentials options instance for client. - * - * It returns the created ALTS channel credential object. - */ -GRPCAPI grpc_channel_credentials* grpc_alts_credentials_create( - const grpc_alts_credentials_options* options); - -/** - * This method creates an ALTS server credential object. It is used for - * experimental purpose for now and subject to change. - * - * - options: grpc ALTS credentials options instance for server. - * - * It returns the created ALTS server credential object. - */ -GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create( - const grpc_alts_credentials_options* options); - -/** --- Local channel/server credentials --- **/ - -/** - * This method creates a local channel credential object. The security level - * of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY for UDS and - * GRPC_SECURITY_NONE for LOCAL_TCP. It is used for experimental purpose - * for now and subject to change. - * - * - type: local connection type - * - * It returns the created local channel credential object. - */ -GRPCAPI grpc_channel_credentials* grpc_local_credentials_create( - grpc_local_connect_type type); - -/** - * This method creates a local server credential object. It is used for - * experimental purpose for now and subject to change. - * - * - type: local connection type - * - * It returns the created local server credential object. - */ -GRPCAPI grpc_server_credentials* grpc_local_server_credentials_create( - grpc_local_connect_type type); - -/** --- TLS channel/server credentials --- - * It is used for experimental purpose for now and subject to change. */ - -/** - * EXPERIMENTAL API - Subject to change - * - * A struct that can be specified by callers to configure underlying TLS - * behaviors. - */ -typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; - -/** - * EXPERIMENTAL API - Subject to change - * - * A struct provides ways to gain credential data that will be used in the TLS - * handshake. - */ -typedef struct grpc_tls_certificate_provider grpc_tls_certificate_provider; - -/** - * EXPERIMENTAL API - Subject to change - * - * A struct that stores the credential data presented to the peer in handshake - * to show local identity. - */ -typedef struct grpc_tls_identity_pairs grpc_tls_identity_pairs; - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates a grpc_tls_identity_pairs that stores a list of identity credential - * data, including identity private key and identity certificate chain. - */ -GRPCAPI grpc_tls_identity_pairs* grpc_tls_identity_pairs_create(); - -/** - * EXPERIMENTAL API - Subject to change - * - * Adds a identity private key and a identity certificate chain to - * grpc_tls_identity_pairs. This function will make an internal copy of - * |private_key| and |cert_chain|. - */ -GRPCAPI void grpc_tls_identity_pairs_add_pair(grpc_tls_identity_pairs* pairs, - const char* private_key, - const char* cert_chain); - -/** - * EXPERIMENTAL API - Subject to change - * - * Destroys a grpc_tls_identity_pairs object. If this object is passed to a - * provider initiation function, the ownership is transferred so this function - * doesn't need to be called. Otherwise the creator of the - * grpc_tls_identity_pairs object is responsible for its destruction. - */ -GRPCAPI void grpc_tls_identity_pairs_destroy(grpc_tls_identity_pairs* pairs); - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates a grpc_tls_certificate_provider that will load credential data from - * static string during initialization. This provider will always return the - * same cert data for all cert names. - * root_certificate and pem_key_cert_pairs can be nullptr, indicating the - * corresponding credential data is not needed. - * This function will make a copy of |root_certificate|. - * The ownership of |pem_key_cert_pairs| is transferred. - */ -GRPCAPI grpc_tls_certificate_provider* -grpc_tls_certificate_provider_static_data_create( - const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs); - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates a grpc_tls_certificate_provider that will watch the credential - * changes on the file system. This provider will always return the up-to-date - * cert data for all the cert names callers set through - * |grpc_tls_credentials_options|. Note that this API only supports one key-cert - * file and hence one set of identity key-cert pair, so SNI(Server Name - * Indication) is not supported. - * - private_key_path is the file path of the private key. This must be set if - * |identity_certificate_path| is set. Otherwise, it could be null if no - * identity credentials are needed. - * - identity_certificate_path is the file path of the identity certificate - * chain. This must be set if |private_key_path| is set. Otherwise, it could - * be null if no identity credentials are needed. - * - root_cert_path is the file path to the root certificate bundle. This - * may be null if no root certs are needed. - * - refresh_interval_sec is the refreshing interval that we will check the - * files for updates. - * It does not take ownership of parameters. - */ -GRPCAPI grpc_tls_certificate_provider* -grpc_tls_certificate_provider_file_watcher_create( - const char* private_key_path, const char* identity_certificate_path, - const char* root_cert_path, unsigned int refresh_interval_sec); - -/** - * EXPERIMENTAL API - Subject to change - * - * Releases a grpc_tls_certificate_provider object. The creator of the - * grpc_tls_certificate_provider object is responsible for its release. - */ -GRPCAPI void grpc_tls_certificate_provider_release( - grpc_tls_certificate_provider* provider); - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates an grpc_tls_credentials_options. - */ -GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the minimum TLS version that will be negotiated during the TLS - * handshake. If not set, the underlying SSL library will set it to TLS v1.2. - */ -GRPCAPI void grpc_tls_credentials_options_set_min_tls_version( - grpc_tls_credentials_options* options, grpc_tls_version min_tls_version); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the maximum TLS version that will be negotiated during the TLS - * handshake. If not set, the underlying SSL library will set it to TLS v1.3. - */ -GRPCAPI void grpc_tls_credentials_options_set_max_tls_version( - grpc_tls_credentials_options* options, grpc_tls_version max_tls_version); - -/** - * EXPERIMENTAL API - Subject to change - * - * Copies a grpc_tls_credentials_options. - */ -GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_copy( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * Destroys a grpc_tls_credentials_options. - */ -GRPCAPI void grpc_tls_credentials_options_destroy( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the credential provider in the options. - * The |options| will implicitly take a new ref to the |provider|. - */ -GRPCAPI void grpc_tls_credentials_options_set_certificate_provider( - grpc_tls_credentials_options* options, - grpc_tls_certificate_provider* provider); - -/** - * EXPERIMENTAL API - Subject to change - * - * If set, gRPC stack will keep watching the root certificates with - * name |root_cert_name|. - * If this is not set on the client side, we will use the root certificates - * stored in the default system location, since client side must provide root - * certificates in TLS. - * If this is not set on the server side, we will not watch any root certificate - * updates, and assume no root certificates needed for the server(single-side - * TLS). Default root certs on the server side is not supported. - */ -GRPCAPI void grpc_tls_credentials_options_watch_root_certs( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the name of the root certificates being watched. - * If not set, We will use a default empty string as the root certificate name. - */ -GRPCAPI void grpc_tls_credentials_options_set_root_cert_name( - grpc_tls_credentials_options* options, const char* root_cert_name); - -/** - * EXPERIMENTAL API - Subject to change - * - * If set, gRPC stack will keep watching the identity key-cert pairs - * with name |identity_cert_name|. - * This is required on the server side, and optional on the client side. - */ -GRPCAPI void grpc_tls_credentials_options_watch_identity_key_cert_pairs( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the name of the identity certificates being watched. - * If not set, We will use a default empty string as the identity certificate - * name. - */ -GRPCAPI void grpc_tls_credentials_options_set_identity_cert_name( - grpc_tls_credentials_options* options, const char* identity_cert_name); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the options of whether to request and/or verify client certs. This shall - * only be called on the server side. - */ -GRPCAPI void grpc_tls_credentials_options_set_cert_request_type( - grpc_tls_credentials_options* options, - grpc_ssl_client_certificate_request_type type); - -/** Deprecated in favor of grpc_tls_credentials_options_set_crl_provider. The - * crl provider interface provides a significantly more flexible approach to - * using CRLs. See gRFC A69 for details. - * EXPERIMENTAL API - Subject to change - * - * If set, gRPC will read all hashed x.509 CRL files in the directory and - * enforce the CRL files on all TLS handshakes. Only supported for OpenSSL - * version > 1.1. - * It is used for experimental purpose for now and subject to change. - */ -GRPCAPI void grpc_tls_credentials_options_set_crl_directory( - grpc_tls_credentials_options* options, const char* crl_directory); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the options of whether to verify server certs on the client side. - * Passing in a non-zero value indicates verifying the certs. - */ -GRPCAPI void grpc_tls_credentials_options_set_verify_server_cert( - grpc_tls_credentials_options* options, int verify_server_cert); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets whether or not a TLS server should send a list of CA names in the - * ServerHello. This list of CA names is read from the server's trust bundle, so - * that the client can use this list as a hint to know which certificate it - * should send to the server. - * - * WARNING: This API is extremely dangerous and should not be used. If the - * server's trust bundle is too large, then the TLS server will be unable to - * form a ServerHello, and hence will be unusable. The definition of "too large" - * depends on the underlying SSL library being used and on the size of the CN - * fields of the certificates in the trust bundle. - */ -GRPCAPI void grpc_tls_credentials_options_set_send_client_ca_list( - grpc_tls_credentials_options* options, bool send_client_ca_list); - -/** - * EXPERIMENTAL API - Subject to change - * - * The read-only request information exposed in a verification call. - * Callers should not directly manage the ownership of it. We will make sure it - * is always available inside verify() or cancel() call, and will destroy the - * object at the end of custom verification. - */ -typedef struct grpc_tls_custom_verification_check_request { - /* The target name of the server when the client initiates the connection. */ - /* This field will be nullptr if on the server side. */ - const char* target_name; - /* The information contained in the certificate chain sent from the peer. */ - struct peer_info { - /* The Common Name field on the peer leaf certificate. */ - const char* common_name; - /* The list of Subject Alternative Names on the peer leaf certificate. */ - struct san_names { - char** uri_names; - size_t uri_names_size; - char** dns_names; - size_t dns_names_size; - char** email_names; - size_t email_names_size; - char** ip_names; - size_t ip_names_size; - } san_names; - /* The raw peer leaf certificate. */ - const char* peer_cert; - /* The raw peer certificate chain. Note that it is not always guaranteed to - * get the peer full chain. For more, please refer to - * GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME defined in file - * grpc_security_constants.h. - * TODO(ZhenLian): Consider fixing this in the future. */ - const char* peer_cert_full_chain; - /* The verified root cert subject. - * This value will only be filled if the cryptographic peer certificate - * verification was successful */ - const char* verified_root_cert_subject; - } peer_info; -} grpc_tls_custom_verification_check_request; - -/** - * EXPERIMENTAL API - Subject to change - * - * A callback function provided by gRPC as a parameter of the |verify| function - * in grpc_tls_certificate_verifier_external. If |verify| is expected to be run - * asynchronously, the implementer of |verify| will need to invoke this callback - * with |callback_arg| and proper verification status at the end to bring the - * control back to gRPC C core. - */ -typedef void (*grpc_tls_on_custom_verification_check_done_cb)( - grpc_tls_custom_verification_check_request* request, void* callback_arg, - grpc_status_code status, const char* error_details); - -/** - * EXPERIMENTAL API - Subject to change - * - * The internal verifier type that will be used inside core. - */ -typedef struct grpc_tls_certificate_verifier grpc_tls_certificate_verifier; - -/** - * EXPERIMENTAL API - Subject to change - * - * A struct containing all the necessary functions a custom external verifier - * needs to implement to be able to be converted to an internal verifier. - */ -typedef struct grpc_tls_certificate_verifier_external { - void* user_data; - /** - * A function pointer containing the verification logic that will be - * performed after the TLS handshake is done. It could be processed - * synchronously or asynchronously. - * - If expected to be processed synchronously, the implementer should - * populate the verification result through |sync_status| and - * |sync_error_details|, and then return true. - * - If expected to be processed asynchronously, the implementer should return - * false immediately, and then in the asynchronous thread invoke |callback| - * with the verification result. The implementer MUST NOT invoke the async - * |callback| in the same thread before |verify| returns, otherwise it can - * lead to deadlocks. - * - * user_data: any argument that is passed in the user_data of - * grpc_tls_certificate_verifier_external during construction time - * can be retrieved later here. - * request: request information exposed to the function implementer. - * callback: the callback that the function implementer needs to invoke, if - * return a non-zero value. It is usually invoked when the - * asynchronous verification is done, and serves to bring the - * control back to gRPC. - * callback_arg: A pointer to the internal ExternalVerifier instance. This is - * mainly used as an argument in |callback|, if want to invoke - * |callback| in async mode. - * sync_status: indicates if a connection should be allowed. This should only - * be used if the verification check is done synchronously. - * sync_error_details: the error generated while verifying a connection. This - * should only be used if the verification check is done - * synchronously. the implementation must allocate the - * error string via gpr_malloc() or gpr_strdup(). - * return: return 0 if |verify| is expected to be executed asynchronously, - * otherwise return a non-zero value. - */ - 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); - /** - * A function pointer that cleans up the caller-specified resources when the - * verifier is still running but the whole connection got cancelled. This - * could happen when the verifier is doing some async operations, and the - * whole handshaker object got destroyed because of connection time limit is - * reached, or any other reasons. In such cases, function implementers might - * want to be notified, and properly clean up some resources. - * - * user_data: any argument that is passed in the user_data of - * grpc_tls_certificate_verifier_external during construction time - * can be retrieved later here. - * request: request information exposed to the function implementer. It will - * be the same request object that was passed to verify(), and it - * tells the cancel() which request to cancel. - */ - void (*cancel)(void* user_data, - grpc_tls_custom_verification_check_request* request); - /** - * A function pointer that does some additional destruction work when the - * verifier is destroyed. This is used when the caller wants to associate some - * objects to the lifetime of external_verifier, and destroy them when - * external_verifier got destructed. For example, in C++, the class containing - * user-specified callback functions should not be destroyed before - * external_verifier, since external_verifier will invoke them while being - * used. - * Note that the caller MUST delete the grpc_tls_certificate_verifier_external - * object itself in this function, otherwise it will cause memory leaks. That - * also means the user_data has to carries at least a self pointer, for the - * callers to later delete it in destruct(). - * - * user_data: any argument that is passed in the user_data of - * grpc_tls_certificate_verifier_external during construction time - * can be retrieved later here. - */ - void (*destruct)(void* user_data); -} grpc_tls_certificate_verifier_external; - -/** - * EXPERIMENTAL API - Subject to change - * - * Converts an external verifier to an internal verifier. - * Note that we will not take the ownership of the external_verifier. Callers - * will need to delete external_verifier in its own destruct function. - */ -grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_external_create( - grpc_tls_certificate_verifier_external* external_verifier); - -/** - * EXPERIMENTAL API - Subject to change - * - * Factory function for an internal verifier that won't perform any - * post-handshake verification. Note: using this solely without any other - * authentication mechanisms on the peer identity will leave your applications - * to the MITM(Man-In-The-Middle) attacks. Users should avoid doing so in - * production environments. - */ -grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_no_op_create(); - -/** - * EXPERIMENTAL API - Subject to change - * - * Factory function for an internal verifier that will do the default hostname - * check. - */ -grpc_tls_certificate_verifier* grpc_tls_certificate_verifier_host_name_create(); - -/** - * EXPERIMENTAL API - Subject to change - * - * Releases a grpc_tls_certificate_verifier object. The creator of the - * grpc_tls_certificate_verifier object is responsible for its release. - */ -void grpc_tls_certificate_verifier_release( - grpc_tls_certificate_verifier* verifier); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the verifier in options. The |options| will implicitly take a new ref to - * the |verifier|. If not set on the client side, we will verify server's - * certificates, and check the default hostname. If not set on the server side, - * we will verify client's certificates. - */ -void grpc_tls_credentials_options_set_certificate_verifier( - grpc_tls_credentials_options* options, - grpc_tls_certificate_verifier* verifier); - -/** - * EXPERIMENTAL API - Subject to change - * - * Sets the options of whether to check the hostname of the peer on a per-call - * basis. This is usually used in a combination with virtual hosting at the - * client side, where each individual call on a channel can have a different - * host associated with it. - * This check is intended to verify that the host specified for the individual - * call is covered by the cert that the peer presented. - * The default is a non-zero value, which indicates performing such checks. - */ -GRPCAPI void grpc_tls_credentials_options_set_check_call_host( - grpc_tls_credentials_options* options, int check_call_host); - -/** - * EXPERIMENTAL API - Subject to change - * - * Performs the verification logic of an internal verifier. - * This is typically used when composing the internal verifiers as part of the - * custom verification. - * If |grpc_tls_certificate_verifier_verify| returns true, inspect the - * verification result through request->status and request->error_details. - * Otherwise, inspect through the parameter of |callback|. - */ -int grpc_tls_certificate_verifier_verify( - grpc_tls_certificate_verifier* verifier, - 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); - -/** - * EXPERIMENTAL API - Subject to change - * - * Performs the cancellation logic of an internal verifier. - * This is typically used when composing the internal verifiers as part of the - * custom verification. - */ -void grpc_tls_certificate_verifier_cancel( - grpc_tls_certificate_verifier* verifier, - grpc_tls_custom_verification_check_request* request); - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates a TLS channel credential object based on the - * grpc_tls_credentials_options specified by callers. The - * grpc_channel_credentials will take the ownership of the |options|. The - * security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - */ -grpc_channel_credentials* grpc_tls_credentials_create( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * Creates a TLS server credential object based on the - * grpc_tls_credentials_options specified by callers. The - * grpc_server_credentials will take the ownership of the |options|. - */ -grpc_server_credentials* grpc_tls_server_credentials_create( - grpc_tls_credentials_options* options); - -/** - * EXPERIMENTAL API - Subject to change - * - * This method creates an insecure channel credentials object. - */ -GRPCAPI grpc_channel_credentials* grpc_insecure_credentials_create(); - -/** - * EXPERIMENTAL API - Subject to change - * - * This method creates an insecure server credentials object. - */ -GRPCAPI grpc_server_credentials* grpc_insecure_server_credentials_create(); - -/** - * EXPERIMENTAL API - Subject to change - * - * This method creates an xDS channel credentials object. - * - * Creating a channel with credentials of this type indicates that the channel - * should get credentials configuration from the xDS control plane. - * - * \a fallback_credentials are used if the channel target does not have the - * 'xds:///' scheme or if the xDS control plane does not provide information on - * how to fetch credentials dynamically. Does NOT take ownership of the \a - * fallback_credentials. (Internally takes a ref to the object.) - */ -GRPCAPI grpc_channel_credentials* grpc_xds_credentials_create( - grpc_channel_credentials* fallback_credentials); - -/** - * EXPERIMENTAL API - Subject to change - * - * This method creates an xDS server credentials object. - * - * \a fallback_credentials are used if the xDS control plane does not provide - * information on how to fetch credentials dynamically. - * - * Does NOT take ownership of the \a fallback_credentials. (Internally takes - * a ref to the object.) - */ -GRPCAPI grpc_server_credentials* grpc_xds_server_credentials_create( - grpc_server_credentials* fallback_credentials); - /** * EXPERIMENTAL - Subject to change. * An opaque type that is responsible for providing authorization policies to @@ -1302,26 +151,6 @@ grpc_authorization_policy_provider_file_watcher_create( GRPCAPI void grpc_authorization_policy_provider_release( grpc_authorization_policy_provider* provider); -/** --- TLS session key logging. --- - * Experimental API to control tls session key logging. Tls session key logging - * is expected to be used only for debugging purposes and never in production. - * Tls session key logging is only enabled when: - * At least one grpc_tls_credentials_options object is assigned a tls session - * key logging file path using the API specified below. - */ - -/** - * EXPERIMENTAL API - Subject to change. - * Configures a grpc_tls_credentials_options object with tls session key - * logging capability. TLS channels using these credentials have tls session - * key logging enabled. - * - options is the grpc_tls_credentials_options object - * - path is a string pointing to the location where TLS session keys would be - * stored. - */ -GRPCAPI void grpc_tls_credentials_options_set_tls_session_key_log_file_path( - grpc_tls_credentials_options* options, const char* path); - #ifdef __cplusplus } #endif diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 7adee5b69e5..c9219532826 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -6,6 +6,7 @@ header "byte_buffer.h" header "byte_buffer_reader.h" header "census.h" header "compression.h" + header "credentials.h" header "fork.h" header "grpc.h" header "grpc_audit_logging.h" diff --git a/include/grpcpp/security/tls_certificate_provider.h b/include/grpcpp/security/tls_certificate_provider.h index d784292992e..3e7c9523156 100644 --- a/include/grpcpp/security/tls_certificate_provider.h +++ b/include/grpcpp/security/tls_certificate_provider.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/package.xml b/package.xml index 9288e08446f..6a184f74d73 100644 --- a/package.xml +++ b/package.xml @@ -33,6 +33,7 @@ + diff --git a/src/core/BUILD b/src/core/BUILD index 3ecb922f38b..23040cc5fe8 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -3655,6 +3655,7 @@ grpc_cc_library( "validation_errors", "//:alts_util", "//:gpr", + "//:grpc_core_credentials_header", "//:ref_counted_ptr", ], ) @@ -3808,6 +3809,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:handshaker", "//:iomgr", @@ -3846,6 +3848,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:handshaker", "//:iomgr", @@ -3905,6 +3908,7 @@ grpc_cc_library( "//:gpr", "//:grpc_base", "//:grpc_client_channel", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:handshaker", "//:iomgr", @@ -3948,6 +3952,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:grpc_trace", "//:handshaker", @@ -4004,6 +4009,7 @@ grpc_cc_library( "//:gpr", "//:grpc_alts_credentials", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_jwt_credentials", "//:grpc_public_hdrs", "//:grpc_security_base", @@ -4078,6 +4084,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_credentials_util", "//:grpc_public_hdrs", "//:grpc_security_base", @@ -4117,6 +4124,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:grpc_trace", "//:promise", @@ -4164,6 +4172,7 @@ grpc_cc_library( "//:api_trace", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_credentials_util", "//:grpc_security_base", "//:grpc_trace", @@ -4219,6 +4228,7 @@ grpc_cc_library( "time", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_credentials_util", "//:grpc_security_base", "//:httpcli", @@ -4255,6 +4265,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:handshaker", "//:iomgr", @@ -5143,6 +5154,7 @@ grpc_cc_library( "//:gpr", "//:grpc_base", "//:grpc_client_channel", + "//:grpc_core_credentials_header", "//:grpc_credentials_util", "//:grpc_public_hdrs", "//:grpc_security_base", @@ -5222,6 +5234,7 @@ grpc_cc_library( "//:exec_ctx", "//:gpr", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_public_hdrs", "//:grpc_security_base", "//:grpc_service_config_impl", @@ -5256,6 +5269,7 @@ grpc_cc_library( "//:config", "//:gpr", "//:gpr_platform", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:ref_counted_ptr", ], @@ -6966,6 +6980,7 @@ grpc_cc_library( "//:gpr", "//:gpr_platform", "//:grpc_base", + "//:grpc_core_credentials_header", "//:grpc_security_base", "//:grpc_trace", "//:httpcli", diff --git a/src/core/ext/gcp/metadata_query.cc b/src/core/ext/gcp/metadata_query.cc index 9edbabfde49..212a7639a03 100644 --- a/src/core/ext/gcp/metadata_query.cc +++ b/src/core/ext/gcp/metadata_query.cc @@ -28,6 +28,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/ext/xds/xds_server_config_fetcher.cc index 75f4e704aba..a236fd05d75 100644 --- a/src/core/ext/xds/xds_server_config_fetcher.cc +++ b/src/core/ext/xds/xds_server_config_fetcher.cc @@ -38,6 +38,7 @@ #include "absl/types/optional.h" #include "absl/types/variant.h" +#include #include #include #include diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 28127811b2d..f5acf5bc3ba 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -25,6 +25,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/certificate_provider/certificate_provider_factory.h b/src/core/lib/security/certificate_provider/certificate_provider_factory.h index beacb85032e..6d1b36e7b20 100644 --- a/src/core/lib/security/certificate_provider/certificate_provider_factory.h +++ b/src/core/lib/security/certificate_provider/certificate_provider_factory.h @@ -23,6 +23,7 @@ #include "absl/strings/string_view.h" +#include #include #include diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index 9cdc64bde6d..877adb8c788 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -22,6 +22,7 @@ #include +#include #include #include #include diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index bbc38020d4f..1c1b85bfc63 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -26,6 +26,7 @@ #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/alts/alts_credentials.h b/src/core/lib/security/credentials/alts/alts_credentials.h index 08ee0439666..46a513a0026 100644 --- a/src/core/lib/security/credentials/alts/alts_credentials.h +++ b/src/core/lib/security/credentials/alts/alts_credentials.h @@ -19,6 +19,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_ALTS_CREDENTIALS_H #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_ALTS_CREDENTIALS_H +#include #include #include #include diff --git a/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h b/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h index 6997beee5de..771beaf543a 100644 --- a/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +++ b/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h @@ -19,6 +19,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_GRPC_ALTS_CREDENTIALS_OPTIONS_H #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_GRPC_ALTS_CREDENTIALS_OPTIONS_H +#include #include #include diff --git a/src/core/lib/security/credentials/call_creds_util.h b/src/core/lib/security/credentials/call_creds_util.h index 87dcc80fd76..6e95f100f94 100644 --- a/src/core/lib/security/credentials/call_creds_util.h +++ b/src/core/lib/security/credentials/call_creds_util.h @@ -19,6 +19,7 @@ #include +#include #include #include diff --git a/src/core/lib/security/credentials/channel_creds_registry_init.cc b/src/core/lib/security/credentials/channel_creds_registry_init.cc index 557967a54c7..4f19760f377 100644 --- a/src/core/lib/security/credentials/channel_creds_registry_init.cc +++ b/src/core/lib/security/credentials/channel_creds_registry_init.cc @@ -23,6 +23,7 @@ #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h index 9c1841b311c..230706ed935 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/src/core/lib/security/credentials/composite/composite_credentials.h @@ -26,6 +26,7 @@ #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 59922c916b8..6a9661c05a6 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -26,6 +26,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc index 74609f44742..754fd4b3ed0 100644 --- a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc @@ -28,6 +28,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/external/external_account_credentials.cc b/src/core/lib/security/credentials/external/external_account_credentials.cc index 9b027ae49b9..ae3f80e5986 100644 --- a/src/core/lib/security/credentials/external/external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/external_account_credentials.cc @@ -35,6 +35,7 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/external/url_external_account_credentials.cc b/src/core/lib/security/credentials/external/url_external_account_credentials.cc index a010be13846..310c7e40170 100644 --- a/src/core/lib/security/credentials/external/url_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/url_external_account_credentials.cc @@ -27,6 +27,7 @@ #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index 8f6d4dfa11b..a18d90d0344 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -23,6 +23,7 @@ #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index a8cc51d1f72..4291bdf5e62 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -28,7 +28,8 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include // IWYU pragma: keep +#include +#include #include #include #include diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.h b/src/core/lib/security/credentials/google_default/google_default_credentials.h index f17105bbdfa..acf2fa6404b 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.h +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.h @@ -20,6 +20,7 @@ #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H #include +#include #include #include #include diff --git a/src/core/lib/security/credentials/iam/iam_credentials.h b/src/core/lib/security/credentials/iam/iam_credentials.h index ae2960e8466..e5ed10316dc 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.h +++ b/src/core/lib/security/credentials/iam/iam_credentials.h @@ -24,6 +24,7 @@ #include "absl/status/statusor.h" #include "absl/types/optional.h" +#include #include #include diff --git a/src/core/lib/security/credentials/insecure/insecure_credentials.h b/src/core/lib/security/credentials/insecure/insecure_credentials.h index 1ccee0bc480..e9bf9327e72 100644 --- a/src/core/lib/security/credentials/insecure/insecure_credentials.h +++ b/src/core/lib/security/credentials/insecure/insecure_credentials.h @@ -19,6 +19,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_INSECURE_INSECURE_CREDENTIALS_H #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_INSECURE_INSECURE_CREDENTIALS_H +#include #include #include #include diff --git a/src/core/lib/security/credentials/jwt/json_token.cc b/src/core/lib/security/credentials/jwt/json_token.cc index 82124dcd59c..ba81ab8dac3 100644 --- a/src/core/lib/security/credentials/jwt/json_token.cc +++ b/src/core/lib/security/credentials/jwt/json_token.cc @@ -33,6 +33,7 @@ #include "absl/status/statusor.h" #include "absl/strings/escaping.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index a5691cd2666..98c80150e94 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -27,6 +27,7 @@ #include "absl/status/status.h" #include "absl/strings/str_cat.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index 8ca6296f8ea..50df9094d0e 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -29,6 +29,7 @@ #include "absl/time/time.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/local/local_credentials.h b/src/core/lib/security/credentials/local/local_credentials.h index 7a52d9a0d1e..77765bc6242 100644 --- a/src/core/lib/security/credentials/local/local_credentials.h +++ b/src/core/lib/security/credentials/local/local_credentials.h @@ -19,6 +19,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_LOCAL_LOCAL_CREDENTIALS_H #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_LOCAL_LOCAL_CREDENTIALS_H +#include #include #include #include diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index bbd666e7dd8..842b3f70f08 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -33,6 +33,7 @@ #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 137818f095a..4bed299f406 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -26,6 +26,7 @@ #include "absl/status/statusor.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index a3c22fbe278..715d071e14e 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -28,6 +28,7 @@ #include "absl/container/inlined_vector.h" #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.h b/src/core/lib/security/credentials/ssl/ssl_credentials.h index 0dd131ff381..d76009f0666 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.h +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h @@ -20,6 +20,7 @@ #include +#include #include #include #include diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc index 7744d62de1a..dbe28e1cf98 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc @@ -18,6 +18,7 @@ #include "absl/status/status.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc index 5e81d3533bf..03921c540aa 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc @@ -25,6 +25,7 @@ #include "absl/status/status.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h index 9734f191fc9..69a9861df22 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h @@ -23,6 +23,7 @@ #include "absl/base/thread_annotations.h" #include "absl/status/status.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h index 6f56905ae32..b29468239a1 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +++ b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h @@ -25,6 +25,7 @@ #include "absl/container/inlined_vector.h" +#include #include #include "src/core/lib/gprpp/ref_counted.h" diff --git a/src/core/lib/security/credentials/tls/tls_credentials.h b/src/core/lib/security/credentials/tls/tls_credentials.h index c79b4b0c554..c72dcd61da8 100644 --- a/src/core/lib/security/credentials/tls/tls_credentials.h +++ b/src/core/lib/security/credentials/tls/tls_credentials.h @@ -19,6 +19,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H +#include #include #include #include diff --git a/src/core/lib/security/credentials/xds/xds_credentials.h b/src/core/lib/security/credentials/xds/xds_credentials.h index b64def62b6f..09762d30276 100644 --- a/src/core/lib/security/credentials/xds/xds_credentials.h +++ b/src/core/lib/security/credentials/xds/xds_credentials.h @@ -28,6 +28,7 @@ #include "absl/status/status.h" +#include #include #include #include diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.h b/src/core/lib/security/security_connector/alts/alts_security_connector.h index 25cef39f92f..1f0c13a3618 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.h +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.h @@ -18,6 +18,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_ALTS_ALTS_SECURITY_CONNECTOR_H #define GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_ALTS_ALTS_SECURITY_CONNECTOR_H +#include #include #include #include diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.h b/src/core/lib/security/security_connector/fake/fake_security_connector.h index a8823493750..1edc40c0b95 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.h +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.h @@ -18,6 +18,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_FAKE_FAKE_SECURITY_CONNECTOR_H #define GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_FAKE_FAKE_SECURITY_CONNECTOR_H +#include #include #include #include diff --git a/src/core/lib/security/security_connector/insecure/insecure_security_connector.h b/src/core/lib/security/security_connector/insecure/insecure_security_connector.h index 8f78f610eab..c2716de0939 100644 --- a/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +++ b/src/core/lib/security/security_connector/insecure/insecure_security_connector.h @@ -24,6 +24,7 @@ #include "absl/status/status.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/security_connector/local/local_security_connector.h b/src/core/lib/security/security_connector/local/local_security_connector.h index ad39afbcf32..09020552f1c 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.h +++ b/src/core/lib/security/security_connector/local/local_security_connector.h @@ -18,6 +18,7 @@ #ifndef GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOCAL_LOCAL_SECURITY_CONNECTOR_H #define GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_LOCAL_LOCAL_SECURITY_CONNECTOR_H +#include #include #include #include diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index 1965984866b..f4bf841d042 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -24,6 +24,7 @@ #include "absl/status/status.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.h b/src/core/lib/security/security_connector/ssl/ssl_security_connector.h index f743b6ff3b2..3ce665d587e 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.h @@ -20,6 +20,7 @@ #define GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_SSL_SECURITY_CONNECTOR_H #include +#include #include #include #include diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index de302b6476c..41b89093833 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -29,6 +29,7 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" +#include #include #include #include diff --git a/src/core/lib/security/security_connector/tls/tls_security_connector.h b/src/core/lib/security/security_connector/tls/tls_security_connector.h index cf6593b4c68..c9293b39943 100644 --- a/src/core/lib/security/security_connector/tls/tls_security_connector.h +++ b/src/core/lib/security/security_connector/tls/tls_security_connector.h @@ -27,6 +27,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/transport/auth_filters.h b/src/core/lib/security/transport/auth_filters.h index ced5319bb55..06b8b6e6fae 100644 --- a/src/core/lib/security/transport/auth_filters.h +++ b/src/core/lib/security/transport/auth_filters.h @@ -21,6 +21,7 @@ #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 400087dcedd..1314b7d523b 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -26,6 +26,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index f2e403b329f..c36db059b3a 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -26,6 +26,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" +#include #include #include #include diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index 98cf9bbec93..ac7372cb464 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -24,6 +24,7 @@ #include "upb/mem/arena.hpp" +#include #include #include #include diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc index d260f1c68c7..e1d6653ed55 100644 --- a/src/cpp/client/create_channel_posix.cc +++ b/src/cpp/client/create_channel_posix.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/common/tls_certificate_provider.cc b/src/cpp/common/tls_certificate_provider.cc index c51c0ea5892..e978a085bee 100644 --- a/src/cpp/common/tls_certificate_provider.cc +++ b/src/cpp/common/tls_certificate_provider.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/common/tls_certificate_verifier.cc b/src/cpp/common/tls_certificate_verifier.cc index 093062a6202..9e717d0714a 100644 --- a/src/cpp/common/tls_certificate_verifier.cc +++ b/src/cpp/common/tls_certificate_verifier.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/common/tls_credentials_options.cc b/src/cpp/common/tls_credentials_options.cc index 56664e501fd..77af87b1280 100644 --- a/src/cpp/common/tls_credentials_options.cc +++ b/src/cpp/common/tls_credentials_options.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/server/server_posix.cc b/src/cpp/server/server_posix.cc index ecc1848a1fc..3491ca58c3c 100644 --- a/src/cpp/server/server_posix.cc +++ b/src/cpp/server/server_posix.cc @@ -16,6 +16,7 @@ // // +#include #include #include #include diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.mm b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.mm index 89679ba2989..28039fd2390 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.mm +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.mm @@ -18,6 +18,7 @@ #import "GRPCInsecureChannelFactory.h" +#include #include #import "ChannelArgsUtil.h" diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.mm b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.mm index 8321ac5b35f..1c884b461cc 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.mm +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.mm @@ -19,6 +19,7 @@ #import "GRPCSecureChannelFactory.h" #import +#include #include #import "ChannelArgsUtil.h" diff --git a/src/php/ext/grpc/call_credentials.h b/src/php/ext/grpc/call_credentials.h index e0cc8638534..e82520802b0 100644 --- a/src/php/ext/grpc/call_credentials.h +++ b/src/php/ext/grpc/call_credentials.h @@ -21,6 +21,7 @@ #include "php_grpc.h" +#include #include /* Class entry for the CallCredentials PHP class */ diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index 8cac73ffd7d..0dca12debfa 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/src/php/ext/grpc/channel_credentials.h b/src/php/ext/grpc/channel_credentials.h index 7c6cf30367d..c790f3e6524 100644 --- a/src/php/ext/grpc/channel_credentials.h +++ b/src/php/ext/grpc/channel_credentials.h @@ -21,6 +21,7 @@ #include "php_grpc.h" +#include #include /* Class entry for the ChannelCredentials PHP class */ diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 8a0aa075fdf..7541729f15a 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -28,6 +28,7 @@ #include "server_credentials.h" #include "completion_queue.h" #include +#include #include #include #include diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c index 2001760e349..ebedb184c72 100644 --- a/src/php/ext/grpc/server.c +++ b/src/php/ext/grpc/server.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/src/php/ext/grpc/server_credentials.h b/src/php/ext/grpc/server_credentials.h index 6a1af3603ed..91edf262481 100644 --- a/src/php/ext/grpc/server_credentials.h +++ b/src/php/ext/grpc/server_credentials.h @@ -21,6 +21,7 @@ #include "php_grpc.h" +#include #include /* Class entry for the Server_Credentials PHP class */ diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 29149e9893a..ce9a1d85e6b 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -445,6 +445,9 @@ cdef extern from "grpc/grpc.h": grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag) nogil char *grpc_channel_get_target(grpc_channel *channel) nogil + grpc_channel *grpc_channel_create( + const char *target, grpc_channel_credentials *creds, + const grpc_channel_args *args) nogil void grpc_channel_destroy(grpc_channel *channel) nogil grpc_server *grpc_server_create( @@ -493,17 +496,18 @@ cdef extern from "grpc/grpc.h": grpc_slice grpc_dump_xds_configs() nogil + ctypedef struct grpc_server_credentials: + # We don't care about the internals (and in fact don't know them) + pass -cdef extern from "grpc/grpc_security.h": - - # Declare this as an enum, this is the only way to make it a const in - # cython - enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX +cdef extern from "grpc/grpc_security_constants.h": - ctypedef enum grpc_ssl_roots_override_result: - GRPC_SSL_ROOTS_OVERRIDE_OK - GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY - GRPC_SSL_ROOTS_OVERRIDE_FAILED + ctypedef enum grpc_security_level: + GRPC_SECURITY_MIN + GRPC_SECURITY_NONE = GRPC_SECURITY_MIN + GRPC_INTEGRITY_ONLY + GRPC_PRIVACY_AND_INTEGRITY + GRPC_SECURITY_MAX = GRPC_PRIVACY_AND_INTEGRITY ctypedef enum grpc_ssl_client_certificate_request_type: GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, @@ -512,18 +516,31 @@ cdef extern from "grpc/grpc_security.h": GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY - ctypedef enum grpc_security_level: - GRPC_SECURITY_MIN - GRPC_SECURITY_NONE = GRPC_SECURITY_MIN - GRPC_INTEGRITY_ONLY - GRPC_PRIVACY_AND_INTEGRITY - GRPC_SECURITY_MAX = GRPC_PRIVACY_AND_INTEGRITY + ctypedef enum grpc_ssl_roots_override_result: + GRPC_SSL_ROOTS_OVERRIDE_OK + GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY + GRPC_SSL_ROOTS_OVERRIDE_FAILED ctypedef enum grpc_ssl_certificate_config_reload_status: GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL + ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)( + void *user_data, + grpc_ssl_server_certificate_config **config) + + ctypedef struct grpc_auth_property_iterator: + pass + + ctypedef struct grpc_auth_property: + char *name + char *value + size_t value_length + + +cdef extern from "grpc/credentials.h": + ctypedef struct grpc_ssl_server_certificate_config: # We don't care about the internals pass @@ -539,10 +556,6 @@ cdef extern from "grpc/grpc_security.h": void grpc_ssl_server_certificate_config_destroy(grpc_ssl_server_certificate_config *config) - ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)( - void *user_data, - grpc_ssl_server_certificate_config **config) - grpc_ssl_server_credentials_options *grpc_ssl_server_credentials_create_options_using_config( grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config *certificate_config) @@ -567,23 +580,12 @@ cdef extern from "grpc/grpc_security.h": # We don't care about the internals (and in fact don't know them) pass - ctypedef struct grpc_ssl_session_cache: - # We don't care about the internals (and in fact don't know them) - pass - ctypedef struct verify_peer_options: # We don't care about the internals (and in fact don't know them) pass - ctypedef void (*grpc_ssl_roots_override_callback)(char **pem_root_certs) - - grpc_ssl_session_cache *grpc_ssl_session_cache_create_lru(size_t capacity) - void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache) - - void grpc_set_ssl_roots_override_callback( - grpc_ssl_roots_override_callback cb) nogil - grpc_channel_credentials *grpc_google_default_credentials_create(grpc_call_credentials* call_credentials) nogil + grpc_channel_credentials *grpc_ssl_credentials_create( const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, verify_peer_options *verify_options, void *reserved) nogil @@ -605,33 +607,22 @@ cdef extern from "grpc/grpc_security.h": grpc_call_credentials *grpc_composite_call_credentials_create( grpc_call_credentials *creds1, grpc_call_credentials *creds2, void *reserved) nogil + grpc_call_credentials *grpc_google_compute_engine_credentials_create( void *reserved) nogil + grpc_call_credentials *grpc_service_account_jwt_access_credentials_create( const char *json_key, gpr_timespec token_lifetime, void *reserved) nogil + grpc_call_credentials *grpc_google_refresh_token_credentials_create( const char *json_refresh_token, void *reserved) nogil + grpc_call_credentials *grpc_google_iam_credentials_create( const char *authorization_token, const char *authority_selector, void *reserved) nogil - void grpc_call_credentials_release(grpc_call_credentials *creds) nogil - - grpc_channel *grpc_channel_create( - const char *target, grpc_channel_credentials *creds, - const grpc_channel_args *args) nogil - - ctypedef struct grpc_server_credentials: - # We don't care about the internals (and in fact don't know them) - pass - void grpc_server_credentials_release(grpc_server_credentials *creds) nogil - - int grpc_server_add_http2_port(grpc_server *server, const char *addr, - grpc_server_credentials *creds) nogil - - grpc_call_error grpc_call_set_credentials(grpc_call *call, - grpc_call_credentials *creds) nogil + void grpc_call_credentials_release(grpc_call_credentials *creds) nogil ctypedef struct grpc_auth_context: # We don't care about the internals (and in fact don't know them) @@ -646,6 +637,10 @@ cdef extern from "grpc/grpc_security.h": void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, grpc_status_code status, const char *error_details) nogil + # Declare this as an enum, this is the only way to make it a const in + # cython + enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX + ctypedef struct grpc_metadata_credentials_plugin: int (*get_metadata)( void *state, grpc_auth_metadata_context context, @@ -660,13 +655,47 @@ cdef extern from "grpc/grpc_security.h": grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void *reserved) nogil - ctypedef struct grpc_auth_property_iterator: + grpc_channel_credentials *grpc_local_credentials_create( + grpc_local_connect_type type) + grpc_server_credentials *grpc_local_server_credentials_create( + grpc_local_connect_type type) + + ctypedef struct grpc_alts_credentials_options: + # We don't care about the internals (and in fact don't know them) pass - ctypedef struct grpc_auth_property: - char *name - char *value - size_t value_length + grpc_channel_credentials *grpc_alts_credentials_create( + const grpc_alts_credentials_options *options) + grpc_server_credentials *grpc_alts_server_credentials_create( + const grpc_alts_credentials_options *options) + + grpc_alts_credentials_options* grpc_alts_credentials_client_options_create() + grpc_alts_credentials_options* grpc_alts_credentials_server_options_create() + void grpc_alts_credentials_options_destroy(grpc_alts_credentials_options *options) + void grpc_alts_credentials_client_options_add_target_service_account(grpc_alts_credentials_options *options, const char *service_account) + + +cdef extern from "grpc/grpc_security.h": + + ctypedef struct grpc_ssl_session_cache: + # We don't care about the internals (and in fact don't know them) + pass + + ctypedef void (*grpc_ssl_roots_override_callback)(char **pem_root_certs) + + grpc_ssl_session_cache *grpc_ssl_session_cache_create_lru(size_t capacity) + void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache) + + void grpc_set_ssl_roots_override_callback( + grpc_ssl_roots_override_callback cb) nogil + + void grpc_server_credentials_release(grpc_server_credentials *creds) nogil + + int grpc_server_add_http2_port(grpc_server *server, const char *addr, + grpc_server_credentials *creds) nogil + + grpc_call_error grpc_call_set_credentials(grpc_call *call, + grpc_call_credentials *creds) nogil grpc_auth_property *grpc_auth_property_iterator_next( grpc_auth_property_iterator *it) @@ -690,26 +719,6 @@ cdef extern from "grpc/grpc_security.h": void grpc_auth_context_release(grpc_auth_context *context) - grpc_channel_credentials *grpc_local_credentials_create( - grpc_local_connect_type type) - grpc_server_credentials *grpc_local_server_credentials_create( - grpc_local_connect_type type) - - ctypedef struct grpc_alts_credentials_options: - # We don't care about the internals (and in fact don't know them) - pass - - grpc_channel_credentials *grpc_alts_credentials_create( - const grpc_alts_credentials_options *options) - grpc_server_credentials *grpc_alts_server_credentials_create( - const grpc_alts_credentials_options *options) - - grpc_alts_credentials_options* grpc_alts_credentials_client_options_create() - grpc_alts_credentials_options* grpc_alts_credentials_server_options_create() - void grpc_alts_credentials_options_destroy(grpc_alts_credentials_options *options) - void grpc_alts_credentials_client_options_add_target_service_account(grpc_alts_credentials_options *options, const char *service_account) - - cdef extern from "grpc/compression.h": diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index 4d4420cbac4..1afcfbdcc74 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -27,6 +27,7 @@ #include "rb_grpc.h" #include "rb_grpc_imports.generated.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_call_credentials.h b/src/ruby/ext/grpc/rb_call_credentials.h index 35c48f83371..785a773aff3 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.h +++ b/src/ruby/ext/grpc/rb_call_credentials.h @@ -21,6 +21,7 @@ #include +#include #include /* Initializes the ruby CallCredentials class. */ diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 165708e6951..48099c258b6 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -32,6 +32,7 @@ #include "rb_server.h" #include "rb_xds_channel_credentials.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c index 8382fb1f904..e570bfb707f 100644 --- a/src/ruby/ext/grpc/rb_channel_credentials.c +++ b/src/ruby/ext/grpc/rb_channel_credentials.c @@ -26,6 +26,7 @@ #include "rb_grpc.h" #include "rb_grpc_imports.generated.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 302dbf49f44..e4607ce6d00 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -42,6 +42,70 @@ grpc_compression_options_init_type grpc_compression_options_init_import; grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import; grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import; grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; +grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +grpc_external_account_credentials_create_type grpc_external_account_credentials_create_import; +grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +grpc_sts_credentials_create_type grpc_sts_credentials_create_import; +grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import; +grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import; +grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +grpc_call_credentials_release_type grpc_call_credentials_release_import; +grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import; +grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import; +grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; +grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; +grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import; +grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import; +grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import; +grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import; +grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +grpc_alts_credentials_client_options_create_type grpc_alts_credentials_client_options_create_import; +grpc_alts_credentials_server_options_create_type grpc_alts_credentials_server_options_create_import; +grpc_alts_credentials_client_options_add_target_service_account_type grpc_alts_credentials_client_options_add_target_service_account_import; +grpc_alts_credentials_options_destroy_type grpc_alts_credentials_options_destroy_import; +grpc_alts_credentials_create_type grpc_alts_credentials_create_import; +grpc_alts_server_credentials_create_type grpc_alts_server_credentials_create_import; +grpc_tls_identity_pairs_create_type grpc_tls_identity_pairs_create_import; +grpc_tls_identity_pairs_add_pair_type grpc_tls_identity_pairs_add_pair_import; +grpc_tls_identity_pairs_destroy_type grpc_tls_identity_pairs_destroy_import; +grpc_tls_certificate_provider_static_data_create_type grpc_tls_certificate_provider_static_data_create_import; +grpc_tls_certificate_provider_file_watcher_create_type grpc_tls_certificate_provider_file_watcher_create_import; +grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_release_import; +grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import; +grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import; +grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import; +grpc_tls_credentials_options_copy_type grpc_tls_credentials_options_copy_import; +grpc_tls_credentials_options_destroy_type grpc_tls_credentials_options_destroy_import; +grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import; +grpc_tls_credentials_options_watch_root_certs_type grpc_tls_credentials_options_watch_root_certs_import; +grpc_tls_credentials_options_set_root_cert_name_type grpc_tls_credentials_options_set_root_cert_name_import; +grpc_tls_credentials_options_watch_identity_key_cert_pairs_type grpc_tls_credentials_options_watch_identity_key_cert_pairs_import; +grpc_tls_credentials_options_set_identity_cert_name_type grpc_tls_credentials_options_set_identity_cert_name_import; +grpc_tls_credentials_options_set_cert_request_type_type grpc_tls_credentials_options_set_cert_request_type_import; +grpc_tls_credentials_options_set_crl_directory_type grpc_tls_credentials_options_set_crl_directory_import; +grpc_tls_credentials_options_set_verify_server_cert_type grpc_tls_credentials_options_set_verify_server_cert_import; +grpc_tls_credentials_options_set_send_client_ca_list_type grpc_tls_credentials_options_set_send_client_ca_list_import; +grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import; +grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import; +grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import; +grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; +grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +grpc_insecure_credentials_create_type grpc_insecure_credentials_create_import; +grpc_insecure_server_credentials_create_type grpc_insecure_server_credentials_create_import; +grpc_xds_credentials_create_type grpc_xds_credentials_create_import; +grpc_xds_server_credentials_create_type grpc_xds_server_credentials_create_import; +grpc_local_credentials_create_type grpc_local_credentials_create_import; +grpc_local_server_credentials_create_type grpc_local_server_credentials_create_import; +grpc_tls_credentials_options_set_check_call_host_type grpc_tls_credentials_options_set_check_call_host_import; +grpc_tls_credentials_options_set_tls_session_key_log_file_path_type grpc_tls_credentials_options_set_tls_session_key_log_file_path_import; grpc_metadata_array_init_type grpc_metadata_array_init_import; grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import; grpc_call_details_init_type grpc_call_details_init_import; @@ -87,6 +151,7 @@ grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; grpc_call_failed_before_recv_message_type grpc_call_failed_before_recv_message_import; grpc_call_ref_type grpc_call_ref_import; grpc_call_unref_type grpc_call_unref_import; +grpc_call_set_credentials_type grpc_call_set_credentials_import; grpc_server_request_call_type grpc_server_request_call_import; grpc_server_register_method_type grpc_server_register_method_import; grpc_server_request_registered_call_type grpc_server_request_registered_call_import; @@ -133,74 +198,9 @@ grpc_auth_context_release_type grpc_auth_context_release_import; grpc_auth_context_add_property_type grpc_auth_context_add_property_import; grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import; grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; -grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import; -grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import; -grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import; -grpc_call_credentials_release_type grpc_call_credentials_release_import; -grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; -grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; -grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; -grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; -grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; -grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; -grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; -grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; -grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; -grpc_external_account_credentials_create_type grpc_external_account_credentials_create_import; -grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; -grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; -grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; -grpc_sts_credentials_create_type grpc_sts_credentials_create_import; -grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import; -grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import; -grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; -grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import; -grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import; -grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; -grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; -grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import; -grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import; -grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import; -grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import; -grpc_call_set_credentials_type grpc_call_set_credentials_import; -grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; -grpc_alts_credentials_client_options_create_type grpc_alts_credentials_client_options_create_import; -grpc_alts_credentials_server_options_create_type grpc_alts_credentials_server_options_create_import; -grpc_alts_credentials_client_options_add_target_service_account_type grpc_alts_credentials_client_options_add_target_service_account_import; -grpc_alts_credentials_options_destroy_type grpc_alts_credentials_options_destroy_import; -grpc_alts_credentials_create_type grpc_alts_credentials_create_import; -grpc_alts_server_credentials_create_type grpc_alts_server_credentials_create_import; -grpc_local_credentials_create_type grpc_local_credentials_create_import; -grpc_local_server_credentials_create_type grpc_local_server_credentials_create_import; -grpc_tls_identity_pairs_create_type grpc_tls_identity_pairs_create_import; -grpc_tls_identity_pairs_add_pair_type grpc_tls_identity_pairs_add_pair_import; -grpc_tls_identity_pairs_destroy_type grpc_tls_identity_pairs_destroy_import; -grpc_tls_certificate_provider_static_data_create_type grpc_tls_certificate_provider_static_data_create_import; -grpc_tls_certificate_provider_file_watcher_create_type grpc_tls_certificate_provider_file_watcher_create_import; -grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_release_import; -grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import; -grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import; -grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import; -grpc_tls_credentials_options_copy_type grpc_tls_credentials_options_copy_import; -grpc_tls_credentials_options_destroy_type grpc_tls_credentials_options_destroy_import; -grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import; -grpc_tls_credentials_options_watch_root_certs_type grpc_tls_credentials_options_watch_root_certs_import; -grpc_tls_credentials_options_set_root_cert_name_type grpc_tls_credentials_options_set_root_cert_name_import; -grpc_tls_credentials_options_watch_identity_key_cert_pairs_type grpc_tls_credentials_options_watch_identity_key_cert_pairs_import; -grpc_tls_credentials_options_set_identity_cert_name_type grpc_tls_credentials_options_set_identity_cert_name_import; -grpc_tls_credentials_options_set_cert_request_type_type grpc_tls_credentials_options_set_cert_request_type_import; -grpc_tls_credentials_options_set_crl_directory_type grpc_tls_credentials_options_set_crl_directory_import; -grpc_tls_credentials_options_set_verify_server_cert_type grpc_tls_credentials_options_set_verify_server_cert_import; -grpc_tls_credentials_options_set_send_client_ca_list_type grpc_tls_credentials_options_set_send_client_ca_list_import; -grpc_tls_credentials_options_set_check_call_host_type grpc_tls_credentials_options_set_check_call_host_import; -grpc_insecure_credentials_create_type grpc_insecure_credentials_create_import; -grpc_insecure_server_credentials_create_type grpc_insecure_server_credentials_create_import; -grpc_xds_credentials_create_type grpc_xds_credentials_create_import; -grpc_xds_server_credentials_create_type grpc_xds_server_credentials_create_import; grpc_authorization_policy_provider_static_data_create_type grpc_authorization_policy_provider_static_data_create_import; grpc_authorization_policy_provider_file_watcher_create_type grpc_authorization_policy_provider_file_watcher_create_import; grpc_authorization_policy_provider_release_type grpc_authorization_policy_provider_release_import; -grpc_tls_credentials_options_set_tls_session_key_log_file_path_type grpc_tls_credentials_options_set_tls_session_key_log_file_path_import; grpc_slice_ref_type grpc_slice_ref_import; grpc_slice_unref_type grpc_slice_unref_import; grpc_slice_copy_type grpc_slice_copy_import; @@ -332,6 +332,70 @@ void grpc_rb_load_imports(HMODULE library) { grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm"); grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm"); grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled"); + grpc_service_account_jwt_access_credentials_create_import = (grpc_service_account_jwt_access_credentials_create_type) GetProcAddress(library, "grpc_service_account_jwt_access_credentials_create"); + grpc_external_account_credentials_create_import = (grpc_external_account_credentials_create_type) GetProcAddress(library, "grpc_external_account_credentials_create"); + grpc_google_refresh_token_credentials_create_import = (grpc_google_refresh_token_credentials_create_type) GetProcAddress(library, "grpc_google_refresh_token_credentials_create"); + grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create"); + grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create"); + grpc_sts_credentials_create_import = (grpc_sts_credentials_create_type) GetProcAddress(library, "grpc_sts_credentials_create"); + grpc_auth_metadata_context_copy_import = (grpc_auth_metadata_context_copy_type) GetProcAddress(library, "grpc_auth_metadata_context_copy"); + grpc_auth_metadata_context_reset_import = (grpc_auth_metadata_context_reset_type) GetProcAddress(library, "grpc_auth_metadata_context_reset"); + grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin"); + grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release"); + grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create"); + grpc_ssl_server_certificate_config_create_import = (grpc_ssl_server_certificate_config_create_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_create"); + grpc_ssl_server_certificate_config_destroy_import = (grpc_ssl_server_certificate_config_destroy_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_destroy"); + grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create"); + grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex"); + grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); + grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex"); + grpc_ssl_server_credentials_create_options_using_config_import = (grpc_ssl_server_credentials_create_options_using_config_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config"); + grpc_ssl_server_credentials_create_options_using_config_fetcher_import = (grpc_ssl_server_credentials_create_options_using_config_fetcher_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config_fetcher"); + grpc_ssl_server_credentials_options_destroy_import = (grpc_ssl_server_credentials_options_destroy_type) GetProcAddress(library, "grpc_ssl_server_credentials_options_destroy"); + grpc_ssl_server_credentials_create_with_options_import = (grpc_ssl_server_credentials_create_with_options_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_with_options"); + grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); + grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create"); + grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create"); + grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create"); + grpc_alts_credentials_client_options_create_import = (grpc_alts_credentials_client_options_create_type) GetProcAddress(library, "grpc_alts_credentials_client_options_create"); + grpc_alts_credentials_server_options_create_import = (grpc_alts_credentials_server_options_create_type) GetProcAddress(library, "grpc_alts_credentials_server_options_create"); + grpc_alts_credentials_client_options_add_target_service_account_import = (grpc_alts_credentials_client_options_add_target_service_account_type) GetProcAddress(library, "grpc_alts_credentials_client_options_add_target_service_account"); + grpc_alts_credentials_options_destroy_import = (grpc_alts_credentials_options_destroy_type) GetProcAddress(library, "grpc_alts_credentials_options_destroy"); + grpc_alts_credentials_create_import = (grpc_alts_credentials_create_type) GetProcAddress(library, "grpc_alts_credentials_create"); + grpc_alts_server_credentials_create_import = (grpc_alts_server_credentials_create_type) GetProcAddress(library, "grpc_alts_server_credentials_create"); + grpc_tls_identity_pairs_create_import = (grpc_tls_identity_pairs_create_type) GetProcAddress(library, "grpc_tls_identity_pairs_create"); + grpc_tls_identity_pairs_add_pair_import = (grpc_tls_identity_pairs_add_pair_type) GetProcAddress(library, "grpc_tls_identity_pairs_add_pair"); + grpc_tls_identity_pairs_destroy_import = (grpc_tls_identity_pairs_destroy_type) GetProcAddress(library, "grpc_tls_identity_pairs_destroy"); + grpc_tls_certificate_provider_static_data_create_import = (grpc_tls_certificate_provider_static_data_create_type) GetProcAddress(library, "grpc_tls_certificate_provider_static_data_create"); + grpc_tls_certificate_provider_file_watcher_create_import = (grpc_tls_certificate_provider_file_watcher_create_type) GetProcAddress(library, "grpc_tls_certificate_provider_file_watcher_create"); + grpc_tls_certificate_provider_release_import = (grpc_tls_certificate_provider_release_type) GetProcAddress(library, "grpc_tls_certificate_provider_release"); + grpc_tls_credentials_options_create_import = (grpc_tls_credentials_options_create_type) GetProcAddress(library, "grpc_tls_credentials_options_create"); + grpc_tls_credentials_options_set_min_tls_version_import = (grpc_tls_credentials_options_set_min_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_min_tls_version"); + grpc_tls_credentials_options_set_max_tls_version_import = (grpc_tls_credentials_options_set_max_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_max_tls_version"); + grpc_tls_credentials_options_copy_import = (grpc_tls_credentials_options_copy_type) GetProcAddress(library, "grpc_tls_credentials_options_copy"); + grpc_tls_credentials_options_destroy_import = (grpc_tls_credentials_options_destroy_type) GetProcAddress(library, "grpc_tls_credentials_options_destroy"); + grpc_tls_credentials_options_set_certificate_provider_import = (grpc_tls_credentials_options_set_certificate_provider_type) GetProcAddress(library, "grpc_tls_credentials_options_set_certificate_provider"); + grpc_tls_credentials_options_watch_root_certs_import = (grpc_tls_credentials_options_watch_root_certs_type) GetProcAddress(library, "grpc_tls_credentials_options_watch_root_certs"); + grpc_tls_credentials_options_set_root_cert_name_import = (grpc_tls_credentials_options_set_root_cert_name_type) GetProcAddress(library, "grpc_tls_credentials_options_set_root_cert_name"); + grpc_tls_credentials_options_watch_identity_key_cert_pairs_import = (grpc_tls_credentials_options_watch_identity_key_cert_pairs_type) GetProcAddress(library, "grpc_tls_credentials_options_watch_identity_key_cert_pairs"); + grpc_tls_credentials_options_set_identity_cert_name_import = (grpc_tls_credentials_options_set_identity_cert_name_type) GetProcAddress(library, "grpc_tls_credentials_options_set_identity_cert_name"); + grpc_tls_credentials_options_set_cert_request_type_import = (grpc_tls_credentials_options_set_cert_request_type_type) GetProcAddress(library, "grpc_tls_credentials_options_set_cert_request_type"); + grpc_tls_credentials_options_set_crl_directory_import = (grpc_tls_credentials_options_set_crl_directory_type) GetProcAddress(library, "grpc_tls_credentials_options_set_crl_directory"); + grpc_tls_credentials_options_set_verify_server_cert_import = (grpc_tls_credentials_options_set_verify_server_cert_type) GetProcAddress(library, "grpc_tls_credentials_options_set_verify_server_cert"); + grpc_tls_credentials_options_set_send_client_ca_list_import = (grpc_tls_credentials_options_set_send_client_ca_list_type) GetProcAddress(library, "grpc_tls_credentials_options_set_send_client_ca_list"); + grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru"); + grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy"); + grpc_ssl_session_cache_create_channel_arg_import = (grpc_ssl_session_cache_create_channel_arg_type) GetProcAddress(library, "grpc_ssl_session_cache_create_channel_arg"); + grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback"); + grpc_max_auth_token_lifetime_import = (grpc_max_auth_token_lifetime_type) GetProcAddress(library, "grpc_max_auth_token_lifetime"); + grpc_insecure_credentials_create_import = (grpc_insecure_credentials_create_type) GetProcAddress(library, "grpc_insecure_credentials_create"); + grpc_insecure_server_credentials_create_import = (grpc_insecure_server_credentials_create_type) GetProcAddress(library, "grpc_insecure_server_credentials_create"); + grpc_xds_credentials_create_import = (grpc_xds_credentials_create_type) GetProcAddress(library, "grpc_xds_credentials_create"); + grpc_xds_server_credentials_create_import = (grpc_xds_server_credentials_create_type) GetProcAddress(library, "grpc_xds_server_credentials_create"); + grpc_local_credentials_create_import = (grpc_local_credentials_create_type) GetProcAddress(library, "grpc_local_credentials_create"); + grpc_local_server_credentials_create_import = (grpc_local_server_credentials_create_type) GetProcAddress(library, "grpc_local_server_credentials_create"); + grpc_tls_credentials_options_set_check_call_host_import = (grpc_tls_credentials_options_set_check_call_host_type) GetProcAddress(library, "grpc_tls_credentials_options_set_check_call_host"); + grpc_tls_credentials_options_set_tls_session_key_log_file_path_import = (grpc_tls_credentials_options_set_tls_session_key_log_file_path_type) GetProcAddress(library, "grpc_tls_credentials_options_set_tls_session_key_log_file_path"); grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init"); grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy"); grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init"); @@ -377,6 +441,7 @@ void grpc_rb_load_imports(HMODULE library) { grpc_call_failed_before_recv_message_import = (grpc_call_failed_before_recv_message_type) GetProcAddress(library, "grpc_call_failed_before_recv_message"); grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref"); grpc_call_unref_import = (grpc_call_unref_type) GetProcAddress(library, "grpc_call_unref"); + grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); grpc_server_request_call_import = (grpc_server_request_call_type) GetProcAddress(library, "grpc_server_request_call"); grpc_server_register_method_import = (grpc_server_register_method_type) GetProcAddress(library, "grpc_server_register_method"); grpc_server_request_registered_call_import = (grpc_server_request_registered_call_type) GetProcAddress(library, "grpc_server_request_registered_call"); @@ -423,74 +488,9 @@ void grpc_rb_load_imports(HMODULE library) { grpc_auth_context_add_property_import = (grpc_auth_context_add_property_type) GetProcAddress(library, "grpc_auth_context_add_property"); grpc_auth_context_add_cstring_property_import = (grpc_auth_context_add_cstring_property_type) GetProcAddress(library, "grpc_auth_context_add_cstring_property"); grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name"); - grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru"); - grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy"); - grpc_ssl_session_cache_create_channel_arg_import = (grpc_ssl_session_cache_create_channel_arg_type) GetProcAddress(library, "grpc_ssl_session_cache_create_channel_arg"); - grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release"); - grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create"); - grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback"); - grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create"); - grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex"); - grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create"); - grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create"); - grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create"); - grpc_max_auth_token_lifetime_import = (grpc_max_auth_token_lifetime_type) GetProcAddress(library, "grpc_max_auth_token_lifetime"); - grpc_service_account_jwt_access_credentials_create_import = (grpc_service_account_jwt_access_credentials_create_type) GetProcAddress(library, "grpc_service_account_jwt_access_credentials_create"); - grpc_external_account_credentials_create_import = (grpc_external_account_credentials_create_type) GetProcAddress(library, "grpc_external_account_credentials_create"); - grpc_google_refresh_token_credentials_create_import = (grpc_google_refresh_token_credentials_create_type) GetProcAddress(library, "grpc_google_refresh_token_credentials_create"); - grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create"); - grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create"); - grpc_sts_credentials_create_import = (grpc_sts_credentials_create_type) GetProcAddress(library, "grpc_sts_credentials_create"); - grpc_auth_metadata_context_copy_import = (grpc_auth_metadata_context_copy_type) GetProcAddress(library, "grpc_auth_metadata_context_copy"); - grpc_auth_metadata_context_reset_import = (grpc_auth_metadata_context_reset_type) GetProcAddress(library, "grpc_auth_metadata_context_reset"); - grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin"); - grpc_ssl_server_certificate_config_create_import = (grpc_ssl_server_certificate_config_create_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_create"); - grpc_ssl_server_certificate_config_destroy_import = (grpc_ssl_server_certificate_config_destroy_type) GetProcAddress(library, "grpc_ssl_server_certificate_config_destroy"); - grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); - grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex"); - grpc_ssl_server_credentials_create_options_using_config_import = (grpc_ssl_server_credentials_create_options_using_config_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config"); - grpc_ssl_server_credentials_create_options_using_config_fetcher_import = (grpc_ssl_server_credentials_create_options_using_config_fetcher_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_options_using_config_fetcher"); - grpc_ssl_server_credentials_options_destroy_import = (grpc_ssl_server_credentials_options_destroy_type) GetProcAddress(library, "grpc_ssl_server_credentials_options_destroy"); - grpc_ssl_server_credentials_create_with_options_import = (grpc_ssl_server_credentials_create_with_options_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_with_options"); - grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); - grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); - grpc_alts_credentials_client_options_create_import = (grpc_alts_credentials_client_options_create_type) GetProcAddress(library, "grpc_alts_credentials_client_options_create"); - grpc_alts_credentials_server_options_create_import = (grpc_alts_credentials_server_options_create_type) GetProcAddress(library, "grpc_alts_credentials_server_options_create"); - grpc_alts_credentials_client_options_add_target_service_account_import = (grpc_alts_credentials_client_options_add_target_service_account_type) GetProcAddress(library, "grpc_alts_credentials_client_options_add_target_service_account"); - grpc_alts_credentials_options_destroy_import = (grpc_alts_credentials_options_destroy_type) GetProcAddress(library, "grpc_alts_credentials_options_destroy"); - grpc_alts_credentials_create_import = (grpc_alts_credentials_create_type) GetProcAddress(library, "grpc_alts_credentials_create"); - grpc_alts_server_credentials_create_import = (grpc_alts_server_credentials_create_type) GetProcAddress(library, "grpc_alts_server_credentials_create"); - grpc_local_credentials_create_import = (grpc_local_credentials_create_type) GetProcAddress(library, "grpc_local_credentials_create"); - grpc_local_server_credentials_create_import = (grpc_local_server_credentials_create_type) GetProcAddress(library, "grpc_local_server_credentials_create"); - grpc_tls_identity_pairs_create_import = (grpc_tls_identity_pairs_create_type) GetProcAddress(library, "grpc_tls_identity_pairs_create"); - grpc_tls_identity_pairs_add_pair_import = (grpc_tls_identity_pairs_add_pair_type) GetProcAddress(library, "grpc_tls_identity_pairs_add_pair"); - grpc_tls_identity_pairs_destroy_import = (grpc_tls_identity_pairs_destroy_type) GetProcAddress(library, "grpc_tls_identity_pairs_destroy"); - grpc_tls_certificate_provider_static_data_create_import = (grpc_tls_certificate_provider_static_data_create_type) GetProcAddress(library, "grpc_tls_certificate_provider_static_data_create"); - grpc_tls_certificate_provider_file_watcher_create_import = (grpc_tls_certificate_provider_file_watcher_create_type) GetProcAddress(library, "grpc_tls_certificate_provider_file_watcher_create"); - grpc_tls_certificate_provider_release_import = (grpc_tls_certificate_provider_release_type) GetProcAddress(library, "grpc_tls_certificate_provider_release"); - grpc_tls_credentials_options_create_import = (grpc_tls_credentials_options_create_type) GetProcAddress(library, "grpc_tls_credentials_options_create"); - grpc_tls_credentials_options_set_min_tls_version_import = (grpc_tls_credentials_options_set_min_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_min_tls_version"); - grpc_tls_credentials_options_set_max_tls_version_import = (grpc_tls_credentials_options_set_max_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_max_tls_version"); - grpc_tls_credentials_options_copy_import = (grpc_tls_credentials_options_copy_type) GetProcAddress(library, "grpc_tls_credentials_options_copy"); - grpc_tls_credentials_options_destroy_import = (grpc_tls_credentials_options_destroy_type) GetProcAddress(library, "grpc_tls_credentials_options_destroy"); - grpc_tls_credentials_options_set_certificate_provider_import = (grpc_tls_credentials_options_set_certificate_provider_type) GetProcAddress(library, "grpc_tls_credentials_options_set_certificate_provider"); - grpc_tls_credentials_options_watch_root_certs_import = (grpc_tls_credentials_options_watch_root_certs_type) GetProcAddress(library, "grpc_tls_credentials_options_watch_root_certs"); - grpc_tls_credentials_options_set_root_cert_name_import = (grpc_tls_credentials_options_set_root_cert_name_type) GetProcAddress(library, "grpc_tls_credentials_options_set_root_cert_name"); - grpc_tls_credentials_options_watch_identity_key_cert_pairs_import = (grpc_tls_credentials_options_watch_identity_key_cert_pairs_type) GetProcAddress(library, "grpc_tls_credentials_options_watch_identity_key_cert_pairs"); - grpc_tls_credentials_options_set_identity_cert_name_import = (grpc_tls_credentials_options_set_identity_cert_name_type) GetProcAddress(library, "grpc_tls_credentials_options_set_identity_cert_name"); - grpc_tls_credentials_options_set_cert_request_type_import = (grpc_tls_credentials_options_set_cert_request_type_type) GetProcAddress(library, "grpc_tls_credentials_options_set_cert_request_type"); - grpc_tls_credentials_options_set_crl_directory_import = (grpc_tls_credentials_options_set_crl_directory_type) GetProcAddress(library, "grpc_tls_credentials_options_set_crl_directory"); - grpc_tls_credentials_options_set_verify_server_cert_import = (grpc_tls_credentials_options_set_verify_server_cert_type) GetProcAddress(library, "grpc_tls_credentials_options_set_verify_server_cert"); - grpc_tls_credentials_options_set_send_client_ca_list_import = (grpc_tls_credentials_options_set_send_client_ca_list_type) GetProcAddress(library, "grpc_tls_credentials_options_set_send_client_ca_list"); - grpc_tls_credentials_options_set_check_call_host_import = (grpc_tls_credentials_options_set_check_call_host_type) GetProcAddress(library, "grpc_tls_credentials_options_set_check_call_host"); - grpc_insecure_credentials_create_import = (grpc_insecure_credentials_create_type) GetProcAddress(library, "grpc_insecure_credentials_create"); - grpc_insecure_server_credentials_create_import = (grpc_insecure_server_credentials_create_type) GetProcAddress(library, "grpc_insecure_server_credentials_create"); - grpc_xds_credentials_create_import = (grpc_xds_credentials_create_type) GetProcAddress(library, "grpc_xds_credentials_create"); - grpc_xds_server_credentials_create_import = (grpc_xds_server_credentials_create_type) GetProcAddress(library, "grpc_xds_server_credentials_create"); grpc_authorization_policy_provider_static_data_create_import = (grpc_authorization_policy_provider_static_data_create_type) GetProcAddress(library, "grpc_authorization_policy_provider_static_data_create"); grpc_authorization_policy_provider_file_watcher_create_import = (grpc_authorization_policy_provider_file_watcher_create_type) GetProcAddress(library, "grpc_authorization_policy_provider_file_watcher_create"); grpc_authorization_policy_provider_release_import = (grpc_authorization_policy_provider_release_type) GetProcAddress(library, "grpc_authorization_policy_provider_release"); - grpc_tls_credentials_options_set_tls_session_key_log_file_path_import = (grpc_tls_credentials_options_set_tls_session_key_log_file_path_type) GetProcAddress(library, "grpc_tls_credentials_options_set_tls_session_key_log_file_path"); grpc_slice_ref_import = (grpc_slice_ref_type) GetProcAddress(library, "grpc_slice_ref"); grpc_slice_unref_import = (grpc_slice_unref_type) GetProcAddress(library, "grpc_slice_unref"); grpc_slice_copy_import = (grpc_slice_copy_type) GetProcAddress(library, "grpc_slice_copy"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index d4e2099eda4..42fb67dface 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -101,6 +102,198 @@ extern grpc_compression_options_disable_algorithm_type grpc_compression_options_ typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options* opts, grpc_compression_algorithm algorithm); extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; #define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import +typedef grpc_call_credentials*(*grpc_service_account_jwt_access_credentials_create_type)(const char* json_key, gpr_timespec token_lifetime, void* reserved); +extern grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +#define grpc_service_account_jwt_access_credentials_create grpc_service_account_jwt_access_credentials_create_import +typedef grpc_call_credentials*(*grpc_external_account_credentials_create_type)(const char* json_string, const char* scopes_string); +extern grpc_external_account_credentials_create_type grpc_external_account_credentials_create_import; +#define grpc_external_account_credentials_create grpc_external_account_credentials_create_import +typedef grpc_call_credentials*(*grpc_google_refresh_token_credentials_create_type)(const char* json_refresh_token, void* reserved); +extern grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +#define grpc_google_refresh_token_credentials_create grpc_google_refresh_token_credentials_create_import +typedef grpc_call_credentials*(*grpc_access_token_credentials_create_type)(const char* access_token, void* reserved); +extern grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +#define grpc_access_token_credentials_create grpc_access_token_credentials_create_import +typedef grpc_call_credentials*(*grpc_google_iam_credentials_create_type)(const char* authorization_token, const char* authority_selector, void* reserved); +extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +#define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import +typedef grpc_call_credentials*(*grpc_sts_credentials_create_type)(const grpc_sts_credentials_options* options, void* reserved); +extern grpc_sts_credentials_create_type grpc_sts_credentials_create_import; +#define grpc_sts_credentials_create grpc_sts_credentials_create_import +typedef void(*grpc_auth_metadata_context_copy_type)(grpc_auth_metadata_context* from, grpc_auth_metadata_context* to); +extern grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import; +#define grpc_auth_metadata_context_copy grpc_auth_metadata_context_copy_import +typedef void(*grpc_auth_metadata_context_reset_type)(grpc_auth_metadata_context* context); +extern grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import; +#define grpc_auth_metadata_context_reset grpc_auth_metadata_context_reset_import +typedef grpc_call_credentials*(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void* reserved); +extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +#define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import +typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds); +extern grpc_call_credentials_release_type grpc_call_credentials_release_import; +#define grpc_call_credentials_release grpc_call_credentials_release_import +typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(grpc_call_credentials* call_credentials); +extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import +typedef grpc_ssl_server_certificate_config*(*grpc_ssl_server_certificate_config_create_type)(const char* pem_root_certs, const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs); +extern grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import; +#define grpc_ssl_server_certificate_config_create grpc_ssl_server_certificate_config_create_import +typedef void(*grpc_ssl_server_certificate_config_destroy_type)(grpc_ssl_server_certificate_config* config); +extern grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import; +#define grpc_ssl_server_certificate_config_destroy grpc_ssl_server_certificate_config_destroy_import +typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); +extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import +typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved); +extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; +#define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import +typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void* reserved); +extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import +typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void* reserved); +extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; +#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import +typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config* certificate_config); +extern grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import; +#define grpc_ssl_server_credentials_create_options_using_config grpc_ssl_server_credentials_create_options_using_config_import +typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_fetcher_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config_callback cb, void* user_data); +extern grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import; +#define grpc_ssl_server_credentials_create_options_using_config_fetcher grpc_ssl_server_credentials_create_options_using_config_fetcher_import +typedef void(*grpc_ssl_server_credentials_options_destroy_type)(grpc_ssl_server_credentials_options* options); +extern grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import; +#define grpc_ssl_server_credentials_options_destroy grpc_ssl_server_credentials_options_destroy_import +typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_with_options_type)(grpc_ssl_server_credentials_options* options); +extern grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import; +#define grpc_ssl_server_credentials_create_with_options grpc_ssl_server_credentials_create_with_options_import +typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials* creds, grpc_auth_metadata_processor processor); +extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +#define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import +typedef grpc_call_credentials*(*grpc_composite_call_credentials_create_type)(grpc_call_credentials* creds1, grpc_call_credentials* creds2, void* reserved); +extern grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +#define grpc_composite_call_credentials_create grpc_composite_call_credentials_create_import +typedef grpc_call_credentials*(*grpc_google_compute_engine_credentials_create_type)(void* reserved); +extern grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +#define grpc_google_compute_engine_credentials_create grpc_google_compute_engine_credentials_create_import +typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved); +extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import +typedef grpc_alts_credentials_options*(*grpc_alts_credentials_client_options_create_type)(void); +extern grpc_alts_credentials_client_options_create_type grpc_alts_credentials_client_options_create_import; +#define grpc_alts_credentials_client_options_create grpc_alts_credentials_client_options_create_import +typedef grpc_alts_credentials_options*(*grpc_alts_credentials_server_options_create_type)(void); +extern grpc_alts_credentials_server_options_create_type grpc_alts_credentials_server_options_create_import; +#define grpc_alts_credentials_server_options_create grpc_alts_credentials_server_options_create_import +typedef void(*grpc_alts_credentials_client_options_add_target_service_account_type)(grpc_alts_credentials_options* options, const char* service_account); +extern grpc_alts_credentials_client_options_add_target_service_account_type grpc_alts_credentials_client_options_add_target_service_account_import; +#define grpc_alts_credentials_client_options_add_target_service_account grpc_alts_credentials_client_options_add_target_service_account_import +typedef void(*grpc_alts_credentials_options_destroy_type)(grpc_alts_credentials_options* options); +extern grpc_alts_credentials_options_destroy_type grpc_alts_credentials_options_destroy_import; +#define grpc_alts_credentials_options_destroy grpc_alts_credentials_options_destroy_import +typedef grpc_channel_credentials*(*grpc_alts_credentials_create_type)(const grpc_alts_credentials_options* options); +extern grpc_alts_credentials_create_type grpc_alts_credentials_create_import; +#define grpc_alts_credentials_create grpc_alts_credentials_create_import +typedef grpc_server_credentials*(*grpc_alts_server_credentials_create_type)(const grpc_alts_credentials_options* options); +extern grpc_alts_server_credentials_create_type grpc_alts_server_credentials_create_import; +#define grpc_alts_server_credentials_create grpc_alts_server_credentials_create_import +typedef grpc_tls_identity_pairs*(*grpc_tls_identity_pairs_create_type)(); +extern grpc_tls_identity_pairs_create_type grpc_tls_identity_pairs_create_import; +#define grpc_tls_identity_pairs_create grpc_tls_identity_pairs_create_import +typedef void(*grpc_tls_identity_pairs_add_pair_type)(grpc_tls_identity_pairs* pairs, const char* private_key, const char* cert_chain); +extern grpc_tls_identity_pairs_add_pair_type grpc_tls_identity_pairs_add_pair_import; +#define grpc_tls_identity_pairs_add_pair grpc_tls_identity_pairs_add_pair_import +typedef void(*grpc_tls_identity_pairs_destroy_type)(grpc_tls_identity_pairs* pairs); +extern grpc_tls_identity_pairs_destroy_type grpc_tls_identity_pairs_destroy_import; +#define grpc_tls_identity_pairs_destroy grpc_tls_identity_pairs_destroy_import +typedef grpc_tls_certificate_provider*(*grpc_tls_certificate_provider_static_data_create_type)(const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs); +extern grpc_tls_certificate_provider_static_data_create_type grpc_tls_certificate_provider_static_data_create_import; +#define grpc_tls_certificate_provider_static_data_create grpc_tls_certificate_provider_static_data_create_import +typedef grpc_tls_certificate_provider*(*grpc_tls_certificate_provider_file_watcher_create_type)(const char* private_key_path, const char* identity_certificate_path, const char* root_cert_path, unsigned int refresh_interval_sec); +extern grpc_tls_certificate_provider_file_watcher_create_type grpc_tls_certificate_provider_file_watcher_create_import; +#define grpc_tls_certificate_provider_file_watcher_create grpc_tls_certificate_provider_file_watcher_create_import +typedef void(*grpc_tls_certificate_provider_release_type)(grpc_tls_certificate_provider* provider); +extern grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_release_import; +#define grpc_tls_certificate_provider_release grpc_tls_certificate_provider_release_import +typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_create_type)(void); +extern grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import; +#define grpc_tls_credentials_options_create grpc_tls_credentials_options_create_import +typedef void(*grpc_tls_credentials_options_set_min_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version min_tls_version); +extern grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import; +#define grpc_tls_credentials_options_set_min_tls_version grpc_tls_credentials_options_set_min_tls_version_import +typedef void(*grpc_tls_credentials_options_set_max_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version max_tls_version); +extern grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import; +#define grpc_tls_credentials_options_set_max_tls_version grpc_tls_credentials_options_set_max_tls_version_import +typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_copy_type)(grpc_tls_credentials_options* options); +extern grpc_tls_credentials_options_copy_type grpc_tls_credentials_options_copy_import; +#define grpc_tls_credentials_options_copy grpc_tls_credentials_options_copy_import +typedef void(*grpc_tls_credentials_options_destroy_type)(grpc_tls_credentials_options* options); +extern grpc_tls_credentials_options_destroy_type grpc_tls_credentials_options_destroy_import; +#define grpc_tls_credentials_options_destroy grpc_tls_credentials_options_destroy_import +typedef void(*grpc_tls_credentials_options_set_certificate_provider_type)(grpc_tls_credentials_options* options, grpc_tls_certificate_provider* provider); +extern grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import; +#define grpc_tls_credentials_options_set_certificate_provider grpc_tls_credentials_options_set_certificate_provider_import +typedef void(*grpc_tls_credentials_options_watch_root_certs_type)(grpc_tls_credentials_options* options); +extern grpc_tls_credentials_options_watch_root_certs_type grpc_tls_credentials_options_watch_root_certs_import; +#define grpc_tls_credentials_options_watch_root_certs grpc_tls_credentials_options_watch_root_certs_import +typedef void(*grpc_tls_credentials_options_set_root_cert_name_type)(grpc_tls_credentials_options* options, const char* root_cert_name); +extern grpc_tls_credentials_options_set_root_cert_name_type grpc_tls_credentials_options_set_root_cert_name_import; +#define grpc_tls_credentials_options_set_root_cert_name grpc_tls_credentials_options_set_root_cert_name_import +typedef void(*grpc_tls_credentials_options_watch_identity_key_cert_pairs_type)(grpc_tls_credentials_options* options); +extern grpc_tls_credentials_options_watch_identity_key_cert_pairs_type grpc_tls_credentials_options_watch_identity_key_cert_pairs_import; +#define grpc_tls_credentials_options_watch_identity_key_cert_pairs grpc_tls_credentials_options_watch_identity_key_cert_pairs_import +typedef void(*grpc_tls_credentials_options_set_identity_cert_name_type)(grpc_tls_credentials_options* options, const char* identity_cert_name); +extern grpc_tls_credentials_options_set_identity_cert_name_type grpc_tls_credentials_options_set_identity_cert_name_import; +#define grpc_tls_credentials_options_set_identity_cert_name grpc_tls_credentials_options_set_identity_cert_name_import +typedef void(*grpc_tls_credentials_options_set_cert_request_type_type)(grpc_tls_credentials_options* options, grpc_ssl_client_certificate_request_type type); +extern grpc_tls_credentials_options_set_cert_request_type_type grpc_tls_credentials_options_set_cert_request_type_import; +#define grpc_tls_credentials_options_set_cert_request_type grpc_tls_credentials_options_set_cert_request_type_import +typedef void(*grpc_tls_credentials_options_set_crl_directory_type)(grpc_tls_credentials_options* options, const char* crl_directory); +extern grpc_tls_credentials_options_set_crl_directory_type grpc_tls_credentials_options_set_crl_directory_import; +#define grpc_tls_credentials_options_set_crl_directory grpc_tls_credentials_options_set_crl_directory_import +typedef void(*grpc_tls_credentials_options_set_verify_server_cert_type)(grpc_tls_credentials_options* options, int verify_server_cert); +extern grpc_tls_credentials_options_set_verify_server_cert_type grpc_tls_credentials_options_set_verify_server_cert_import; +#define grpc_tls_credentials_options_set_verify_server_cert grpc_tls_credentials_options_set_verify_server_cert_import +typedef void(*grpc_tls_credentials_options_set_send_client_ca_list_type)(grpc_tls_credentials_options* options, bool send_client_ca_list); +extern grpc_tls_credentials_options_set_send_client_ca_list_type grpc_tls_credentials_options_set_send_client_ca_list_import; +#define grpc_tls_credentials_options_set_send_client_ca_list grpc_tls_credentials_options_set_send_client_ca_list_import +typedef grpc_ssl_session_cache*(*grpc_ssl_session_cache_create_lru_type)(size_t capacity); +extern grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import; +#define grpc_ssl_session_cache_create_lru grpc_ssl_session_cache_create_lru_import +typedef void(*grpc_ssl_session_cache_destroy_type)(grpc_ssl_session_cache* cache); +extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import; +#define grpc_ssl_session_cache_destroy grpc_ssl_session_cache_destroy_import +typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache); +extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import; +#define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import +typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb); +extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; +#define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import +typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)(void); +extern grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +#define grpc_max_auth_token_lifetime grpc_max_auth_token_lifetime_import +typedef grpc_channel_credentials*(*grpc_insecure_credentials_create_type)(); +extern grpc_insecure_credentials_create_type grpc_insecure_credentials_create_import; +#define grpc_insecure_credentials_create grpc_insecure_credentials_create_import +typedef grpc_server_credentials*(*grpc_insecure_server_credentials_create_type)(); +extern grpc_insecure_server_credentials_create_type grpc_insecure_server_credentials_create_import; +#define grpc_insecure_server_credentials_create grpc_insecure_server_credentials_create_import +typedef grpc_channel_credentials*(*grpc_xds_credentials_create_type)(grpc_channel_credentials* fallback_credentials); +extern grpc_xds_credentials_create_type grpc_xds_credentials_create_import; +#define grpc_xds_credentials_create grpc_xds_credentials_create_import +typedef grpc_server_credentials*(*grpc_xds_server_credentials_create_type)(grpc_server_credentials* fallback_credentials); +extern grpc_xds_server_credentials_create_type grpc_xds_server_credentials_create_import; +#define grpc_xds_server_credentials_create grpc_xds_server_credentials_create_import +typedef grpc_channel_credentials*(*grpc_local_credentials_create_type)(grpc_local_connect_type type); +extern grpc_local_credentials_create_type grpc_local_credentials_create_import; +#define grpc_local_credentials_create grpc_local_credentials_create_import +typedef grpc_server_credentials*(*grpc_local_server_credentials_create_type)(grpc_local_connect_type type); +extern grpc_local_server_credentials_create_type grpc_local_server_credentials_create_import; +#define grpc_local_server_credentials_create grpc_local_server_credentials_create_import +typedef void(*grpc_tls_credentials_options_set_check_call_host_type)(grpc_tls_credentials_options* options, int check_call_host); +extern grpc_tls_credentials_options_set_check_call_host_type grpc_tls_credentials_options_set_check_call_host_import; +#define grpc_tls_credentials_options_set_check_call_host grpc_tls_credentials_options_set_check_call_host_import +typedef void(*grpc_tls_credentials_options_set_tls_session_key_log_file_path_type)(grpc_tls_credentials_options* options, const char* path); +extern grpc_tls_credentials_options_set_tls_session_key_log_file_path_type grpc_tls_credentials_options_set_tls_session_key_log_file_path_import; +#define grpc_tls_credentials_options_set_tls_session_key_log_file_path grpc_tls_credentials_options_set_tls_session_key_log_file_path_import typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array* array); extern grpc_metadata_array_init_type grpc_metadata_array_init_import; #define grpc_metadata_array_init grpc_metadata_array_init_import @@ -236,6 +429,9 @@ extern grpc_call_ref_type grpc_call_ref_import; typedef void(*grpc_call_unref_type)(grpc_call* call); extern grpc_call_unref_type grpc_call_unref_import; #define grpc_call_unref grpc_call_unref_import +typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call* call, grpc_call_credentials* creds); +extern grpc_call_set_credentials_type grpc_call_set_credentials_import; +#define grpc_call_set_credentials grpc_call_set_credentials_import typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server* server, grpc_call** call, grpc_call_details* details, grpc_metadata_array* request_metadata, grpc_completion_queue* cq_bound_to_call, grpc_completion_queue* cq_for_notification, void* tag_new); extern grpc_server_request_call_type grpc_server_request_call_import; #define grpc_server_request_call grpc_server_request_call_import @@ -374,198 +570,6 @@ extern grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context* ctx, const char* name); extern grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; #define grpc_auth_context_set_peer_identity_property_name grpc_auth_context_set_peer_identity_property_name_import -typedef grpc_ssl_session_cache*(*grpc_ssl_session_cache_create_lru_type)(size_t capacity); -extern grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import; -#define grpc_ssl_session_cache_create_lru grpc_ssl_session_cache_create_lru_import -typedef void(*grpc_ssl_session_cache_destroy_type)(grpc_ssl_session_cache* cache); -extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import; -#define grpc_ssl_session_cache_destroy grpc_ssl_session_cache_destroy_import -typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache); -extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import; -#define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import -typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds); -extern grpc_call_credentials_release_type grpc_call_credentials_release_import; -#define grpc_call_credentials_release grpc_call_credentials_release_import -typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(grpc_call_credentials* call_credentials); -extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; -#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import -typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb); -extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; -#define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import -typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); -extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; -#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import -typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved); -extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import; -#define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import -typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved); -extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; -#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import -typedef grpc_call_credentials*(*grpc_composite_call_credentials_create_type)(grpc_call_credentials* creds1, grpc_call_credentials* creds2, void* reserved); -extern grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; -#define grpc_composite_call_credentials_create grpc_composite_call_credentials_create_import -typedef grpc_call_credentials*(*grpc_google_compute_engine_credentials_create_type)(void* reserved); -extern grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; -#define grpc_google_compute_engine_credentials_create grpc_google_compute_engine_credentials_create_import -typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)(void); -extern grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; -#define grpc_max_auth_token_lifetime grpc_max_auth_token_lifetime_import -typedef grpc_call_credentials*(*grpc_service_account_jwt_access_credentials_create_type)(const char* json_key, gpr_timespec token_lifetime, void* reserved); -extern grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; -#define grpc_service_account_jwt_access_credentials_create grpc_service_account_jwt_access_credentials_create_import -typedef grpc_call_credentials*(*grpc_external_account_credentials_create_type)(const char* json_string, const char* scopes_string); -extern grpc_external_account_credentials_create_type grpc_external_account_credentials_create_import; -#define grpc_external_account_credentials_create grpc_external_account_credentials_create_import -typedef grpc_call_credentials*(*grpc_google_refresh_token_credentials_create_type)(const char* json_refresh_token, void* reserved); -extern grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; -#define grpc_google_refresh_token_credentials_create grpc_google_refresh_token_credentials_create_import -typedef grpc_call_credentials*(*grpc_access_token_credentials_create_type)(const char* access_token, void* reserved); -extern grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; -#define grpc_access_token_credentials_create grpc_access_token_credentials_create_import -typedef grpc_call_credentials*(*grpc_google_iam_credentials_create_type)(const char* authorization_token, const char* authority_selector, void* reserved); -extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; -#define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import -typedef grpc_call_credentials*(*grpc_sts_credentials_create_type)(const grpc_sts_credentials_options* options, void* reserved); -extern grpc_sts_credentials_create_type grpc_sts_credentials_create_import; -#define grpc_sts_credentials_create grpc_sts_credentials_create_import -typedef void(*grpc_auth_metadata_context_copy_type)(grpc_auth_metadata_context* from, grpc_auth_metadata_context* to); -extern grpc_auth_metadata_context_copy_type grpc_auth_metadata_context_copy_import; -#define grpc_auth_metadata_context_copy grpc_auth_metadata_context_copy_import -typedef void(*grpc_auth_metadata_context_reset_type)(grpc_auth_metadata_context* context); -extern grpc_auth_metadata_context_reset_type grpc_auth_metadata_context_reset_import; -#define grpc_auth_metadata_context_reset grpc_auth_metadata_context_reset_import -typedef grpc_call_credentials*(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void* reserved); -extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; -#define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import -typedef grpc_ssl_server_certificate_config*(*grpc_ssl_server_certificate_config_create_type)(const char* pem_root_certs, const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs); -extern grpc_ssl_server_certificate_config_create_type grpc_ssl_server_certificate_config_create_import; -#define grpc_ssl_server_certificate_config_create grpc_ssl_server_certificate_config_create_import -typedef void(*grpc_ssl_server_certificate_config_destroy_type)(grpc_ssl_server_certificate_config* config); -extern grpc_ssl_server_certificate_config_destroy_type grpc_ssl_server_certificate_config_destroy_import; -#define grpc_ssl_server_certificate_config_destroy grpc_ssl_server_certificate_config_destroy_import -typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void* reserved); -extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; -#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import -typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void* reserved); -extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; -#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import -typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config* certificate_config); -extern grpc_ssl_server_credentials_create_options_using_config_type grpc_ssl_server_credentials_create_options_using_config_import; -#define grpc_ssl_server_credentials_create_options_using_config grpc_ssl_server_credentials_create_options_using_config_import -typedef grpc_ssl_server_credentials_options*(*grpc_ssl_server_credentials_create_options_using_config_fetcher_type)(grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_certificate_config_callback cb, void* user_data); -extern grpc_ssl_server_credentials_create_options_using_config_fetcher_type grpc_ssl_server_credentials_create_options_using_config_fetcher_import; -#define grpc_ssl_server_credentials_create_options_using_config_fetcher grpc_ssl_server_credentials_create_options_using_config_fetcher_import -typedef void(*grpc_ssl_server_credentials_options_destroy_type)(grpc_ssl_server_credentials_options* options); -extern grpc_ssl_server_credentials_options_destroy_type grpc_ssl_server_credentials_options_destroy_import; -#define grpc_ssl_server_credentials_options_destroy grpc_ssl_server_credentials_options_destroy_import -typedef grpc_server_credentials*(*grpc_ssl_server_credentials_create_with_options_type)(grpc_ssl_server_credentials_options* options); -extern grpc_ssl_server_credentials_create_with_options_type grpc_ssl_server_credentials_create_with_options_import; -#define grpc_ssl_server_credentials_create_with_options grpc_ssl_server_credentials_create_with_options_import -typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call* call, grpc_call_credentials* creds); -extern grpc_call_set_credentials_type grpc_call_set_credentials_import; -#define grpc_call_set_credentials grpc_call_set_credentials_import -typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials* creds, grpc_auth_metadata_processor processor); -extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; -#define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import -typedef grpc_alts_credentials_options*(*grpc_alts_credentials_client_options_create_type)(void); -extern grpc_alts_credentials_client_options_create_type grpc_alts_credentials_client_options_create_import; -#define grpc_alts_credentials_client_options_create grpc_alts_credentials_client_options_create_import -typedef grpc_alts_credentials_options*(*grpc_alts_credentials_server_options_create_type)(void); -extern grpc_alts_credentials_server_options_create_type grpc_alts_credentials_server_options_create_import; -#define grpc_alts_credentials_server_options_create grpc_alts_credentials_server_options_create_import -typedef void(*grpc_alts_credentials_client_options_add_target_service_account_type)(grpc_alts_credentials_options* options, const char* service_account); -extern grpc_alts_credentials_client_options_add_target_service_account_type grpc_alts_credentials_client_options_add_target_service_account_import; -#define grpc_alts_credentials_client_options_add_target_service_account grpc_alts_credentials_client_options_add_target_service_account_import -typedef void(*grpc_alts_credentials_options_destroy_type)(grpc_alts_credentials_options* options); -extern grpc_alts_credentials_options_destroy_type grpc_alts_credentials_options_destroy_import; -#define grpc_alts_credentials_options_destroy grpc_alts_credentials_options_destroy_import -typedef grpc_channel_credentials*(*grpc_alts_credentials_create_type)(const grpc_alts_credentials_options* options); -extern grpc_alts_credentials_create_type grpc_alts_credentials_create_import; -#define grpc_alts_credentials_create grpc_alts_credentials_create_import -typedef grpc_server_credentials*(*grpc_alts_server_credentials_create_type)(const grpc_alts_credentials_options* options); -extern grpc_alts_server_credentials_create_type grpc_alts_server_credentials_create_import; -#define grpc_alts_server_credentials_create grpc_alts_server_credentials_create_import -typedef grpc_channel_credentials*(*grpc_local_credentials_create_type)(grpc_local_connect_type type); -extern grpc_local_credentials_create_type grpc_local_credentials_create_import; -#define grpc_local_credentials_create grpc_local_credentials_create_import -typedef grpc_server_credentials*(*grpc_local_server_credentials_create_type)(grpc_local_connect_type type); -extern grpc_local_server_credentials_create_type grpc_local_server_credentials_create_import; -#define grpc_local_server_credentials_create grpc_local_server_credentials_create_import -typedef grpc_tls_identity_pairs*(*grpc_tls_identity_pairs_create_type)(); -extern grpc_tls_identity_pairs_create_type grpc_tls_identity_pairs_create_import; -#define grpc_tls_identity_pairs_create grpc_tls_identity_pairs_create_import -typedef void(*grpc_tls_identity_pairs_add_pair_type)(grpc_tls_identity_pairs* pairs, const char* private_key, const char* cert_chain); -extern grpc_tls_identity_pairs_add_pair_type grpc_tls_identity_pairs_add_pair_import; -#define grpc_tls_identity_pairs_add_pair grpc_tls_identity_pairs_add_pair_import -typedef void(*grpc_tls_identity_pairs_destroy_type)(grpc_tls_identity_pairs* pairs); -extern grpc_tls_identity_pairs_destroy_type grpc_tls_identity_pairs_destroy_import; -#define grpc_tls_identity_pairs_destroy grpc_tls_identity_pairs_destroy_import -typedef grpc_tls_certificate_provider*(*grpc_tls_certificate_provider_static_data_create_type)(const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs); -extern grpc_tls_certificate_provider_static_data_create_type grpc_tls_certificate_provider_static_data_create_import; -#define grpc_tls_certificate_provider_static_data_create grpc_tls_certificate_provider_static_data_create_import -typedef grpc_tls_certificate_provider*(*grpc_tls_certificate_provider_file_watcher_create_type)(const char* private_key_path, const char* identity_certificate_path, const char* root_cert_path, unsigned int refresh_interval_sec); -extern grpc_tls_certificate_provider_file_watcher_create_type grpc_tls_certificate_provider_file_watcher_create_import; -#define grpc_tls_certificate_provider_file_watcher_create grpc_tls_certificate_provider_file_watcher_create_import -typedef void(*grpc_tls_certificate_provider_release_type)(grpc_tls_certificate_provider* provider); -extern grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_release_import; -#define grpc_tls_certificate_provider_release grpc_tls_certificate_provider_release_import -typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_create_type)(void); -extern grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import; -#define grpc_tls_credentials_options_create grpc_tls_credentials_options_create_import -typedef void(*grpc_tls_credentials_options_set_min_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version min_tls_version); -extern grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import; -#define grpc_tls_credentials_options_set_min_tls_version grpc_tls_credentials_options_set_min_tls_version_import -typedef void(*grpc_tls_credentials_options_set_max_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version max_tls_version); -extern grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import; -#define grpc_tls_credentials_options_set_max_tls_version grpc_tls_credentials_options_set_max_tls_version_import -typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_copy_type)(grpc_tls_credentials_options* options); -extern grpc_tls_credentials_options_copy_type grpc_tls_credentials_options_copy_import; -#define grpc_tls_credentials_options_copy grpc_tls_credentials_options_copy_import -typedef void(*grpc_tls_credentials_options_destroy_type)(grpc_tls_credentials_options* options); -extern grpc_tls_credentials_options_destroy_type grpc_tls_credentials_options_destroy_import; -#define grpc_tls_credentials_options_destroy grpc_tls_credentials_options_destroy_import -typedef void(*grpc_tls_credentials_options_set_certificate_provider_type)(grpc_tls_credentials_options* options, grpc_tls_certificate_provider* provider); -extern grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import; -#define grpc_tls_credentials_options_set_certificate_provider grpc_tls_credentials_options_set_certificate_provider_import -typedef void(*grpc_tls_credentials_options_watch_root_certs_type)(grpc_tls_credentials_options* options); -extern grpc_tls_credentials_options_watch_root_certs_type grpc_tls_credentials_options_watch_root_certs_import; -#define grpc_tls_credentials_options_watch_root_certs grpc_tls_credentials_options_watch_root_certs_import -typedef void(*grpc_tls_credentials_options_set_root_cert_name_type)(grpc_tls_credentials_options* options, const char* root_cert_name); -extern grpc_tls_credentials_options_set_root_cert_name_type grpc_tls_credentials_options_set_root_cert_name_import; -#define grpc_tls_credentials_options_set_root_cert_name grpc_tls_credentials_options_set_root_cert_name_import -typedef void(*grpc_tls_credentials_options_watch_identity_key_cert_pairs_type)(grpc_tls_credentials_options* options); -extern grpc_tls_credentials_options_watch_identity_key_cert_pairs_type grpc_tls_credentials_options_watch_identity_key_cert_pairs_import; -#define grpc_tls_credentials_options_watch_identity_key_cert_pairs grpc_tls_credentials_options_watch_identity_key_cert_pairs_import -typedef void(*grpc_tls_credentials_options_set_identity_cert_name_type)(grpc_tls_credentials_options* options, const char* identity_cert_name); -extern grpc_tls_credentials_options_set_identity_cert_name_type grpc_tls_credentials_options_set_identity_cert_name_import; -#define grpc_tls_credentials_options_set_identity_cert_name grpc_tls_credentials_options_set_identity_cert_name_import -typedef void(*grpc_tls_credentials_options_set_cert_request_type_type)(grpc_tls_credentials_options* options, grpc_ssl_client_certificate_request_type type); -extern grpc_tls_credentials_options_set_cert_request_type_type grpc_tls_credentials_options_set_cert_request_type_import; -#define grpc_tls_credentials_options_set_cert_request_type grpc_tls_credentials_options_set_cert_request_type_import -typedef void(*grpc_tls_credentials_options_set_crl_directory_type)(grpc_tls_credentials_options* options, const char* crl_directory); -extern grpc_tls_credentials_options_set_crl_directory_type grpc_tls_credentials_options_set_crl_directory_import; -#define grpc_tls_credentials_options_set_crl_directory grpc_tls_credentials_options_set_crl_directory_import -typedef void(*grpc_tls_credentials_options_set_verify_server_cert_type)(grpc_tls_credentials_options* options, int verify_server_cert); -extern grpc_tls_credentials_options_set_verify_server_cert_type grpc_tls_credentials_options_set_verify_server_cert_import; -#define grpc_tls_credentials_options_set_verify_server_cert grpc_tls_credentials_options_set_verify_server_cert_import -typedef void(*grpc_tls_credentials_options_set_send_client_ca_list_type)(grpc_tls_credentials_options* options, bool send_client_ca_list); -extern grpc_tls_credentials_options_set_send_client_ca_list_type grpc_tls_credentials_options_set_send_client_ca_list_import; -#define grpc_tls_credentials_options_set_send_client_ca_list grpc_tls_credentials_options_set_send_client_ca_list_import -typedef void(*grpc_tls_credentials_options_set_check_call_host_type)(grpc_tls_credentials_options* options, int check_call_host); -extern grpc_tls_credentials_options_set_check_call_host_type grpc_tls_credentials_options_set_check_call_host_import; -#define grpc_tls_credentials_options_set_check_call_host grpc_tls_credentials_options_set_check_call_host_import -typedef grpc_channel_credentials*(*grpc_insecure_credentials_create_type)(); -extern grpc_insecure_credentials_create_type grpc_insecure_credentials_create_import; -#define grpc_insecure_credentials_create grpc_insecure_credentials_create_import -typedef grpc_server_credentials*(*grpc_insecure_server_credentials_create_type)(); -extern grpc_insecure_server_credentials_create_type grpc_insecure_server_credentials_create_import; -#define grpc_insecure_server_credentials_create grpc_insecure_server_credentials_create_import -typedef grpc_channel_credentials*(*grpc_xds_credentials_create_type)(grpc_channel_credentials* fallback_credentials); -extern grpc_xds_credentials_create_type grpc_xds_credentials_create_import; -#define grpc_xds_credentials_create grpc_xds_credentials_create_import -typedef grpc_server_credentials*(*grpc_xds_server_credentials_create_type)(grpc_server_credentials* fallback_credentials); -extern grpc_xds_server_credentials_create_type grpc_xds_server_credentials_create_import; -#define grpc_xds_server_credentials_create grpc_xds_server_credentials_create_import typedef grpc_authorization_policy_provider*(*grpc_authorization_policy_provider_static_data_create_type)(const char* authz_policy, grpc_status_code* code, const char** error_details); extern grpc_authorization_policy_provider_static_data_create_type grpc_authorization_policy_provider_static_data_create_import; #define grpc_authorization_policy_provider_static_data_create grpc_authorization_policy_provider_static_data_create_import @@ -575,9 +579,6 @@ extern grpc_authorization_policy_provider_file_watcher_create_type grpc_authoriz typedef void(*grpc_authorization_policy_provider_release_type)(grpc_authorization_policy_provider* provider); extern grpc_authorization_policy_provider_release_type grpc_authorization_policy_provider_release_import; #define grpc_authorization_policy_provider_release grpc_authorization_policy_provider_release_import -typedef void(*grpc_tls_credentials_options_set_tls_session_key_log_file_path_type)(grpc_tls_credentials_options* options, const char* path); -extern grpc_tls_credentials_options_set_tls_session_key_log_file_path_type grpc_tls_credentials_options_set_tls_session_key_log_file_path_import; -#define grpc_tls_credentials_options_set_tls_session_key_log_file_path grpc_tls_credentials_options_set_tls_session_key_log_file_path_import typedef grpc_slice(*grpc_slice_ref_type)(grpc_slice s); extern grpc_slice_ref_type grpc_slice_ref_import; #define grpc_slice_ref grpc_slice_ref_import diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index 387dcff2d27..51ba4a91eb2 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -29,6 +29,7 @@ #include "rb_server_credentials.h" #include "rb_xds_server_credentials.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c index 42c259015cd..73c754d5352 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.c +++ b/src/ruby/ext/grpc/rb_server_credentials.c @@ -23,6 +23,7 @@ #include "rb_grpc.h" #include "rb_grpc_imports.generated.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_server_credentials.h b/src/ruby/ext/grpc/rb_server_credentials.h index bb14b575c05..64b22715d99 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.h +++ b/src/ruby/ext/grpc/rb_server_credentials.h @@ -23,6 +23,7 @@ #include +#include #include /* Initializes the ruby ServerCredentials class. */ diff --git a/src/ruby/ext/grpc/rb_xds_channel_credentials.c b/src/ruby/ext/grpc/rb_xds_channel_credentials.c index db3d6dbdac4..56b08d99287 100644 --- a/src/ruby/ext/grpc/rb_xds_channel_credentials.c +++ b/src/ruby/ext/grpc/rb_xds_channel_credentials.c @@ -27,6 +27,7 @@ #include "rb_grpc.h" #include "rb_grpc_imports.generated.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_xds_server_credentials.c b/src/ruby/ext/grpc/rb_xds_server_credentials.c index 3d4ec5afe53..8186d0eb49e 100644 --- a/src/ruby/ext/grpc/rb_xds_server_credentials.c +++ b/src/ruby/ext/grpc/rb_xds_server_credentials.c @@ -24,6 +24,7 @@ #include "rb_grpc_imports.generated.h" #include "rb_server_credentials.h" +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_xds_server_credentials.h b/src/ruby/ext/grpc/rb_xds_server_credentials.h index eff00c7dcf5..3ec1ced8e4b 100644 --- a/src/ruby/ext/grpc/rb_xds_server_credentials.h +++ b/src/ruby/ext/grpc/rb_xds_server_credentials.h @@ -23,6 +23,7 @@ #include +#include #include /* Initializes the ruby XdsServerCredentials class. */ diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 5faa7b7bc5a..40b1d87c66b 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -21,6 +21,7 @@ #include +#include #include #include #include diff --git a/test/core/bad_ssl/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc index 14693494cee..049e87f9700 100644 --- a/test/core/bad_ssl/servers/alpn.cc +++ b/test/core/bad_ssl/servers/alpn.cc @@ -20,6 +20,7 @@ #include +#include #include #include #include diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc index 954c28fca7f..4c6b26a025c 100644 --- a/test/core/bad_ssl/servers/cert.cc +++ b/test/core/bad_ssl/servers/cert.cc @@ -16,6 +16,7 @@ // // +#include #include #include #include diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc index fd035ccc12d..9e722c67f84 100644 --- a/test/core/channel/channel_args_test.cc +++ b/test/core/channel/channel_args_test.cc @@ -22,6 +22,7 @@ #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 1a346f3da6c..2396c4a3945 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -24,6 +24,7 @@ #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 3b57b4a6ef7..973af3690eb 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -30,6 +30,7 @@ #include "absl/status/statusor.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index ea613b36fbd..b898c0aa23d 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index a670f4ece5d..b3deb41f14f 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -20,6 +20,7 @@ #include +#include #include #include #include diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index db0d1d710a6..4c4c782e3b2 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -42,6 +42,7 @@ #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/test/core/end2end/end2end_test_suites.cc b/test/core/end2end/end2end_test_suites.cc index 625d1a8190a..f1f86668b20 100644 --- a/test/core/end2end/end2end_test_suites.cc +++ b/test/core/end2end/end2end_test_suites.cc @@ -34,6 +34,7 @@ #include "gtest/gtest.h" #include +#include #include #include #include diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 410f3366014..f033f608061 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_oauth2_common.h b/test/core/end2end/fixtures/h2_oauth2_common.h index 57ae5a7d60d..e66f341059a 100644 --- a/test/core/end2end/fixtures/h2_oauth2_common.h +++ b/test/core/end2end/fixtures/h2_oauth2_common.h @@ -17,6 +17,7 @@ #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h index fe6bc5d43dd..5b49fcb39e5 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h @@ -17,6 +17,7 @@ #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_ssl_tls_common.h b/test/core/end2end/fixtures/h2_ssl_tls_common.h index 1a2d8da331d..e026ccbd381 100644 --- a/test/core/end2end/fixtures/h2_ssl_tls_common.h +++ b/test/core/end2end/fixtures/h2_ssl_tls_common.h @@ -17,6 +17,7 @@ #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_tls_common.h b/test/core/end2end/fixtures/h2_tls_common.h index 5fd2972fd0f..0abc56e6d06 100644 --- a/test/core/end2end/fixtures/h2_tls_common.h +++ b/test/core/end2end/fixtures/h2_tls_common.h @@ -26,6 +26,7 @@ #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 7cb814de9e2..2c4059b1973 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -22,6 +22,7 @@ #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/secure_fixture.h b/test/core/end2end/fixtures/secure_fixture.h index d047e712d21..8a64b49fc75 100644 --- a/test/core/end2end/fixtures/secure_fixture.h +++ b/test/core/end2end/fixtures/secure_fixture.h @@ -20,6 +20,7 @@ #include "absl/functional/any_invocable.h" +#include #include #include #include diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index ab506cc54fc..213c13b427a 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -36,6 +36,7 @@ #include "absl/time/time.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/test/core/end2end/fuzzers/server_fuzzer_chttp2.cc b/test/core/end2end/fuzzers/server_fuzzer_chttp2.cc index b01b357825e..f95e2c69e2b 100644 --- a/test/core/end2end/fuzzers/server_fuzzer_chttp2.cc +++ b/test/core/end2end/fuzzers/server_fuzzer_chttp2.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include "src/libfuzzer/libfuzzer_macro.h" diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index 0359b71db11..c8e958edc30 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -31,6 +31,7 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 584bceb7ef6..d1d94e5ac3a 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -27,6 +27,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 875b9f79e53..55243de78ed 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -24,6 +24,7 @@ #include "absl/types/optional.h" +#include #include #include #include diff --git a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc index 8cc76b5bfe1..958ae061e67 100644 --- a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc +++ b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc @@ -24,6 +24,7 @@ #include "absl/types/optional.h" +#include #include #include #include diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index 7f5d2345aa7..deeefe165a0 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/multiple_server_queues_test.cc b/test/core/end2end/multiple_server_queues_test.cc index daa8bb3c5fe..025f9f939af 100644 --- a/test/core/end2end/multiple_server_queues_test.cc +++ b/test/core/end2end/multiple_server_queues_test.cc @@ -16,6 +16,7 @@ // // +#include #include #include #include diff --git a/test/core/end2end/no_server_test.cc b/test/core/end2end/no_server_test.cc index 0a785d921ff..c6357f911cd 100644 --- a/test/core/end2end/no_server_test.cc +++ b/test/core/end2end/no_server_test.cc @@ -24,6 +24,7 @@ #include "absl/status/statusor.h" #include "absl/time/time.h" +#include #include #include #include diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc index b90f681d0d2..ce6b949085f 100644 --- a/test/core/end2end/tests/call_creds.cc +++ b/test/core/end2end/tests/call_creds.cc @@ -21,6 +21,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/filters/client_auth_filter_test.cc b/test/core/filters/client_auth_filter_test.cc index 4596cdee59f..bc06504b25f 100644 --- a/test/core/filters/client_auth_filter_test.cc +++ b/test/core/filters/client_auth_filter_test.cc @@ -21,6 +21,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc index 5540d3084e1..ce5951abacb 100644 --- a/test/core/handshake/client_ssl.cc +++ b/test/core/handshake/client_ssl.cc @@ -51,6 +51,7 @@ #include "absl/strings/str_cat.h" +#include #include #include #include diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc index 0f0c4b195b1..b4a0ad1e828 100644 --- a/test/core/handshake/server_ssl_common.cc +++ b/test/core/handshake/server_ssl_common.cc @@ -36,6 +36,7 @@ #include "absl/base/thread_annotations.h" #include "absl/strings/str_cat.h" +#include #include #include #include diff --git a/test/core/handshake/verify_peer_options.cc b/test/core/handshake/verify_peer_options.cc index c9f47d39de6..fae7ffbb5fe 100644 --- a/test/core/handshake/verify_peer_options.cc +++ b/test/core/handshake/verify_peer_options.cc @@ -34,6 +34,7 @@ #include "absl/strings/str_cat.h" +#include #include #include #include diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 8ed555af61b..7a8f3bf92b3 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -34,6 +34,7 @@ #include "absl/time/clock.h" #include "absl/time/time.h" +#include #include #include #include diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index 3b20c7193ed..61185fe361e 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 7426e8b6a91..a789240f5b3 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -36,6 +36,7 @@ #include "absl/status/status.h" #include +#include #include #include #include diff --git a/test/core/security/alts_credentials_fuzzer.cc b/test/core/security/alts_credentials_fuzzer.cc index a11d362511f..1d47a506061 100644 --- a/test/core/security/alts_credentials_fuzzer.cc +++ b/test/core/security/alts_credentials_fuzzer.cc @@ -18,6 +18,7 @@ #include +#include #include #include #include diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index c645a30c792..edee063aa16 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 5afafcf50a3..5ee501d431c 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -31,6 +31,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_replace.h" +#include #include #include #include diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index 49cee158a09..c60c85bbf7f 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/test/core/security/grpc_tls_credentials_options_comparator_test.cc b/test/core/security/grpc_tls_credentials_options_comparator_test.cc index 6971f0c20e5..0f1e1e8c828 100644 --- a/test/core/security/grpc_tls_credentials_options_comparator_test.cc +++ b/test/core/security/grpc_tls_credentials_options_comparator_test.cc @@ -24,6 +24,8 @@ #include +#include + #include "src/core/lib/security/credentials/xds/xds_credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" #include "test/core/util/test_config.h" diff --git a/test/core/security/grpc_tls_credentials_options_test.cc b/test/core/security/grpc_tls_credentials_options_test.cc index 0b903ae0c05..f213e987c40 100644 --- a/test/core/security/grpc_tls_credentials_options_test.cc +++ b/test/core/security/grpc_tls_credentials_options_test.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc index 5e89cf292aa..97cd240ee13 100644 --- a/test/core/security/json_token_test.cc +++ b/test/core/security/json_token_test.cc @@ -25,6 +25,7 @@ #include "absl/strings/escaping.h" +#include #include #include #include diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index 956783d2ff3..a23c7b4d5a1 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -20,6 +20,7 @@ #include +#include #include #include #include diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index a5ade93304c..66ea4a904c0 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index cb781d1fd7e..83df36a3968 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -23,6 +23,7 @@ #include +#include #include #include #include diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index 4a8b5e47742..e657550f376 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -16,6 +16,7 @@ // // +#include #include #include #include diff --git a/test/core/security/tls_security_connector_test.cc b/test/core/security/tls_security_connector_test.cc index f1bcc410653..264eb8103db 100644 --- a/test/core/security/tls_security_connector_test.cc +++ b/test/core/security/tls_security_connector_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc index 2b1ee72dc94..3e73c423719 100644 --- a/test/core/surface/concurrent_connectivity_test.cc +++ b/test/core/surface/concurrent_connectivity_test.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_cat.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 40ca9b67385..ec43da2fdad 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -22,6 +22,7 @@ #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index 73a053e1196..17f93f194fa 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -24,6 +24,7 @@ #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index 3c211a9dd81..3e04c59df8a 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -20,6 +20,7 @@ #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index c3a927a9f8b..a111b836f0f 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_cat.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc index 0852008863b..3cdb2d9940f 100644 --- a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc +++ b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc @@ -31,6 +31,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc index 61a45e0790e..7977929d083 100644 --- a/test/core/transport/chttp2/settings_timeout_test.cc +++ b/test/core/transport/chttp2/settings_timeout_test.cc @@ -30,6 +30,7 @@ #include "absl/strings/str_cat.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc b/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc index ef8aacabc36..423ed40e584 100644 --- a/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc +++ b/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc @@ -23,6 +23,7 @@ #include "gtest/gtest.h" #include +#include #include #include #include diff --git a/test/core/transport/chttp2/streams_not_seen_test.cc b/test/core/transport/chttp2/streams_not_seen_test.cc index 7105ec9b912..fe1626d48f4 100644 --- a/test/core/transport/chttp2/streams_not_seen_test.cc +++ b/test/core/transport/chttp2/streams_not_seen_test.cc @@ -38,6 +38,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" +#include #include #include #include diff --git a/test/core/transport/chttp2/too_many_pings_test.cc b/test/core/transport/chttp2/too_many_pings_test.cc index cfb2ca8f1e6..474e2edb4b3 100644 --- a/test/core/transport/chttp2/too_many_pings_test.cc +++ b/test/core/transport/chttp2/too_many_pings_test.cc @@ -32,6 +32,7 @@ #include "gtest/gtest.h" #include +#include #include #include #include diff --git a/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc b/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc index e7c50708564..e703c2a1fa8 100644 --- a/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc +++ b/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc @@ -34,6 +34,7 @@ #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" +#include #include #include #include diff --git a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc index bbacdcfe45f..43502dbb8f2 100644 --- a/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc +++ b/test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc @@ -22,6 +22,7 @@ #include "upb/mem/arena.hpp" +#include #include #include diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc index 8dc073fc7e2..fd651bc29a7 100644 --- a/test/core/util/port_server_client.cc +++ b/test/core/util/port_server_client.cc @@ -30,6 +30,7 @@ #include "absl/status/statusor.h" #include "absl/strings/str_format.h" +#include #include #include #include diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 408f45c794b..91be4134f12 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -33,6 +33,7 @@ #include "absl/synchronization/notification.h" #include "absl/types/span.h" +#include #include #include #include diff --git a/test/cpp/end2end/rls_end2end_test.cc b/test/cpp/end2end/rls_end2end_test.cc index 942c183b890..6f52a802f8c 100644 --- a/test/cpp/end2end/rls_end2end_test.cc +++ b/test/cpp/end2end/rls_end2end_test.cc @@ -33,6 +33,7 @@ #include "absl/strings/str_join.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/test/cpp/end2end/ssl_credentials_test.cc b/test/cpp/end2end/ssl_credentials_test.cc index f8b73ae952e..092fe427aed 100644 --- a/test/cpp/end2end/ssl_credentials_test.cc +++ b/test/cpp/end2end/ssl_credentials_test.cc @@ -26,6 +26,7 @@ #include "absl/synchronization/notification.h" +#include #include #include #include diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 523de360bd6..d9d10f1eeb9 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -28,6 +28,7 @@ #include "absl/strings/escaping.h" #include "absl/strings/match.h" +#include #include #include #include diff --git a/test/cpp/microbenchmarks/bm_channel.cc b/test/cpp/microbenchmarks/bm_channel.cc index c4b62a304c0..ff9baf59b70 100644 --- a/test/cpp/microbenchmarks/bm_channel.cc +++ b/test/cpp/microbenchmarks/bm_channel.cc @@ -20,6 +20,7 @@ #include +#include #include #include diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index c2009ae970a..9b6cacafd49 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -27,6 +27,7 @@ #include "absl/strings/str_format.h" #include +#include #include #include #include diff --git a/tools/codegen/core/gen_grpc_tls_credentials_options.py b/tools/codegen/core/gen_grpc_tls_credentials_options.py index 1c802bee886..b0a6d01ebbb 100755 --- a/tools/codegen/core/gen_grpc_tls_credentials_options.py +++ b/tools/codegen/core/gen_grpc_tls_credentials_options.py @@ -305,6 +305,7 @@ print( #include "absl/container/inlined_vector.h" +#include #include #include "src/core/lib/gprpp/ref_counted.h" @@ -469,6 +470,8 @@ print( #include +#include + #include "src/core/lib/security/credentials/xds/xds_credentials.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" #include "test/core/util/test_config.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index a6bb91ebf02..6e0f4316174 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -880,6 +880,7 @@ include/grpc/byte_buffer.h \ include/grpc/byte_buffer_reader.h \ include/grpc/census.h \ include/grpc/compression.h \ +include/grpc/credentials.h \ include/grpc/event_engine/endpoint_config.h \ include/grpc/event_engine/event_engine.h \ include/grpc/event_engine/extensible.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 68ce1dc0369..45745a6b3c8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -880,6 +880,7 @@ include/grpc/byte_buffer.h \ include/grpc/byte_buffer_reader.h \ include/grpc/census.h \ include/grpc/compression.h \ +include/grpc/credentials.h \ include/grpc/event_engine/endpoint_config.h \ include/grpc/event_engine/event_engine.h \ include/grpc/event_engine/extensible.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index f9261a2a94f..224d9f2d10b 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -813,6 +813,7 @@ include/grpc/byte_buffer.h \ include/grpc/byte_buffer_reader.h \ include/grpc/census.h \ include/grpc/compression.h \ +include/grpc/credentials.h \ include/grpc/event_engine/endpoint_config.h \ include/grpc/event_engine/event_engine.h \ include/grpc/event_engine/extensible.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 66d40b201af..73cb5cdb1c6 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -813,6 +813,7 @@ include/grpc/byte_buffer.h \ include/grpc/byte_buffer_reader.h \ include/grpc/census.h \ include/grpc/compression.h \ +include/grpc/credentials.h \ include/grpc/event_engine/endpoint_config.h \ include/grpc/event_engine/event_engine.h \ include/grpc/event_engine/extensible.h \ From 67ba35bac061e3be742f35daf0c89b51c5337fa5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 16 Apr 2024 20:30:27 +0000 Subject: [PATCH 10/45] [esoteric] Eliminate unused argument errors with GPR_DEBUG_ASSERT (#36373) Eliminate cases where we get unused parameter errors only because of a debug assert, and because of short-circuit evaluation not add any overhead into release builds. Closes #36373 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36373 from ctiller:ugh123 073ea1236a0963972de270cf0acf02ebe4e4bf50 PiperOrigin-RevId: 625435672 --- include/grpc/support/log.h | 2 +- include/grpcpp/support/callback_common.h | 2 ++ src/core/client_channel/client_channel_filter.cc | 2 ++ src/core/load_balancing/xds/xds_cluster_impl.cc | 5 +++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index a118561904d..6e5cf4b7157 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -102,7 +102,7 @@ GPRAPI void gpr_assertion_failed(const char* filename, int line, #ifndef NDEBUG #define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x) #else -#define GPR_DEBUG_ASSERT(x) +#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(true || (x)) #endif #ifdef __cplusplus diff --git a/include/grpcpp/support/callback_common.h b/include/grpcpp/support/callback_common.h index a99a47dbf4d..6ae8cfb946a 100644 --- a/include/grpcpp/support/callback_common.h +++ b/include/grpcpp/support/callback_common.h @@ -207,7 +207,9 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor { auto* ops = ops_; #endif bool do_callback = ops_->FinalizeResult(&ignored, &ok); +#ifndef NDEBUG GPR_DEBUG_ASSERT(ignored == ops); +#endif if (do_callback) { CatchingCallback(func_, ok); diff --git a/src/core/client_channel/client_channel_filter.cc b/src/core/client_channel/client_channel_filter.cc index 16f94347e4e..b7d4d6d4952 100644 --- a/src/core/client_channel/client_channel_filter.cc +++ b/src/core/client_channel/client_channel_filter.cc @@ -644,7 +644,9 @@ class ClientChannelFilter::SubchannelWrapper final chand, this, subchannel_.get()); } GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper"); +#ifndef NDEBUG GPR_DEBUG_ASSERT(chand_->work_serializer_->RunningInWorkSerializer()); +#endif if (chand_->channelz_node_ != nullptr) { auto* subchannel_node = subchannel_->channelz_node(); if (subchannel_node != nullptr) { diff --git a/src/core/load_balancing/xds/xds_cluster_impl.cc b/src/core/load_balancing/xds/xds_cluster_impl.cc index ef766148021..acb1454a0b7 100644 --- a/src/core/load_balancing/xds/xds_cluster_impl.cc +++ b/src/core/load_balancing/xds/xds_cluster_impl.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -36,6 +34,7 @@ #include #include +#include #include "src/core/client_channel/client_channel_internal.h" #include "src/core/ext/xds/xds_bootstrap.h" @@ -328,7 +327,9 @@ class XdsClusterImplLb::Picker::SubchannelCallTracker final ~SubchannelCallTracker() override { locality_stats_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); call_counter_.reset(DEBUG_LOCATION, "SubchannelCallTracker"); +#ifndef NDEBUG GPR_DEBUG_ASSERT(!started_); +#endif } void Start() override { From c3a077e184cd7599c8eaaafe9af9f138ee2def6e Mon Sep 17 00:00:00 2001 From: Yijie Ma Date: Tue, 16 Apr 2024 22:19:30 +0000 Subject: [PATCH 11/45] [examples/cpp] Fix missing parentheses (#36382) Fix https://github.com/grpc/grpc/issues/36367. Closes #36382 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36382 from yijiem:fix-example-cmake 54521e87a1e04496642423bfa8b6586063d848b6 PiperOrigin-RevId: 625469934 --- examples/cpp/keepalive/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cpp/keepalive/CMakeLists.txt b/examples/cpp/keepalive/CMakeLists.txt index 06024dfbc9b..8053fba1df6 100644 --- a/examples/cpp/keepalive/CMakeLists.txt +++ b/examples/cpp/keepalive/CMakeLists.txt @@ -58,7 +58,7 @@ target_link_libraries(hw_grpc_proto # Targets greeter_[async_](client|server) foreach(_target - greeter_callback_client greeter_callback_server + greeter_callback_client greeter_callback_server) add_executable(${_target} "${_target}.cc") target_link_libraries(${_target} hw_grpc_proto From c40ea61261bb27d86011be7b68d157470a20a6bc Mon Sep 17 00:00:00 2001 From: Yousuk Seung Date: Tue, 16 Apr 2024 23:31:59 +0000 Subject: [PATCH 12/45] Add options to omit CQ or sync server APIs in generated code PiperOrigin-RevId: 625490214 --- src/compiler/cpp_generator.cc | 1220 ++++++++++++++++++--------------- src/compiler/cpp_generator.h | 4 + src/compiler/cpp_plugin.h | 20 + 3 files changed, 694 insertions(+), 550 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index d49ab12af9d..15470a191d3 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -20,6 +20,7 @@ #include #include +#include namespace grpc_cpp_generator { namespace { @@ -189,6 +190,7 @@ std::string GetHeaderIncludes(grpc_generator::File* file, void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars, bool is_public) { (*vars)["Method"] = method->name(); @@ -208,23 +210,25 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, *vars, "virtual ::grpc::Status $Method$(::grpc::ClientContext* context, " "const $Request$& request, $Response$* response) = 0;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - printer->Print( - *vars, - "std::unique_ptr< " - "::grpc::ClientAsyncResponseReaderInterface< $Response$>> " - "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncResponseReaderInterface< $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, request, cq));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + printer->Print( + *vars, + "std::unique_ptr< " + "::grpc::ClientAsyncResponseReaderInterface< $Response$>> " + "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); + printer->Indent(); + printer->Print( + *vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncResponseReaderInterface< $Response$>>(" + "$AsyncPrefix$$Method$Raw(context, request, cq));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (ClientOnlyStreaming(method)) { printer->Print( @@ -239,25 +243,27 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "($Method$Raw(context, response));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncWriterInterface< $Request$>>" - " $AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "$Response$* " - "response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncWriterInterface< $Request$>>(" - "$AsyncPrefix$$Method$Raw(context, response, " - "cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncWriterInterface< $Request$>>" + " $AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "$Response$* " + "response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print(*vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncWriterInterface< $Request$>>(" + "$AsyncPrefix$$Method$Raw(context, response, " + "cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -272,24 +278,27 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "($Method$Raw(context, request));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto& async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncReaderInterface< $Response$>> " - "$AsyncPrefix$$Method$(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderInterface< $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, request, cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncReaderInterface< " + "$Response$>> " + "$AsyncPrefix$$Method$(" + "::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print(*vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncReaderInterface< $Response$>>(" + "$AsyncPrefix$$Method$Raw(context, request, " + "cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (method->BidiStreaming()) { printer->Print(*vars, @@ -304,36 +313,43 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "$Method$Raw(context));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "std::unique_ptr< " - "::grpc::ClientAsyncReaderWriterInterface< $Request$, $Response$>> " - "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderWriterInterface< $Request$, $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< " + "::grpc::ClientAsyncReaderWriterInterface< $Request$, " + "$Response$>> " + "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print( + *vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncReaderWriterInterface< $Request$, " + "$Response$>>(" + "$AsyncPrefix$$Method$Raw(context, cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } } else { if (method->NoStreaming()) { - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncResponseReaderInterface< $Response$>* " - "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) = 0;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + printer->Print( + *vars, + "virtual ::grpc::ClientAsyncResponseReaderInterface< " + "$Response$>* " + "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) = 0;\n"); + } } } else if (ClientOnlyStreaming(method)) { printer->Print( @@ -341,15 +357,17 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "virtual ::grpc::ClientWriterInterface< $Request$>*" " $Method$Raw(" "::grpc::ClientContext* context, $Response$* response) = 0;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncWriterInterface< $Request$>*" - " $AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + printer->Print( + *vars, + "virtual ::grpc::ClientAsyncWriterInterface< $Request$>*" + " $AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " + "$Response$* response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -357,30 +375,34 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "virtual ::grpc::ClientReaderInterface< $Response$>* " "$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request) = 0;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncReaderInterface< $Response$>* " - "$AsyncPrefix$$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + printer->Print( + *vars, + "virtual ::grpc::ClientAsyncReaderInterface< $Response$>* " + "$AsyncPrefix$$Method$Raw(" + "::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + } } } else if (method->BidiStreaming()) { printer->Print(*vars, "virtual ::grpc::ClientReaderWriterInterface< $Request$, " "$Response$>* " "$Method$Raw(::grpc::ClientContext* context) = 0;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncReaderWriterInterface< " - "$Request$, $Response$>* " - "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + printer->Print( + *vars, + "virtual ::grpc::ClientAsyncReaderWriterInterface< " + "$Request$, $Response$>* " + "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) = 0;\n"); + } } } } @@ -388,6 +410,7 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, void PrintHeaderClientMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars, bool is_public) { (*vars)["Method"] = method->name(); @@ -406,21 +429,24 @@ void PrintHeaderClientMethod(grpc_generator::Printer* printer, *vars, "::grpc::Status $Method$(::grpc::ClientContext* context, " "const $Request$& request, $Response$* response) override;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> " - "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncResponseReader< $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, request, cq));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncResponseReader< " + "$Response$>> " + "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); + printer->Indent(); + printer->Print(*vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncResponseReader< $Response$>>(" + "$AsyncPrefix$$Method$Raw(context, request, cq));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (ClientOnlyStreaming(method)) { printer->Print( @@ -434,23 +460,26 @@ void PrintHeaderClientMethod(grpc_generator::Printer* printer, "($Method$Raw(context, response));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print(*vars, - "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>" - " $AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>(" - "$AsyncPrefix$$Method$Raw(context, response, " - "cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>" + " $AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "$Response$* response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print( + *vars, + "return std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>(" + "$AsyncPrefix$$Method$Raw(context, response, " + "cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -465,23 +494,26 @@ void PrintHeaderClientMethod(grpc_generator::Printer* printer, "($Method$Raw(context, request));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> " - "$AsyncPrefix$$Method$(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, request, cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> " + "$AsyncPrefix$$Method$(" + "::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print( + *vars, + "return std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>>(" + "$AsyncPrefix$$Method$Raw(context, request, " + "cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } else if (method->BidiStreaming()) { printer->Print( @@ -495,79 +527,91 @@ void PrintHeaderClientMethod(grpc_generator::Printer* printer, "$Method$Raw(context));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print(*vars, - "std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " - "$Request$, $Response$>> " - "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>>(" - "$AsyncPrefix$$Method$Raw(context, cq$AsyncRawArgs$));\n"); - printer->Outdent(); - printer->Print("}\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " + "$Request$, $Response$>> " + "$AsyncPrefix$$Method$(::grpc::ClientContext* context, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Indent(); + printer->Print( + *vars, + "return std::unique_ptr< " + "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>>(" + "$AsyncPrefix$$Method$Raw(context, cq$AsyncRawArgs$));\n"); + printer->Outdent(); + printer->Print("}\n"); + } } } } else { if (method->NoStreaming()) { - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - printer->Print( - *vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) override;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + printer->Print( + *vars, + "::grpc::ClientAsyncResponseReader< $Response$>* " + "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) override;\n"); + } } } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, "::grpc::ClientWriter< $Request$>* $Method$Raw(" "::grpc::ClientContext* context, $Response$* response) " "override;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "::grpc::ClientAsyncWriter< $Request$>* $AsyncPrefix$$Method$Raw(" - "::grpc::ClientContext* context, $Response$* response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "::grpc::ClientAsyncWriter< $Request$>* $AsyncPrefix$$Method$Raw(" + "::grpc::ClientContext* context, $Response$* response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, "::grpc::ClientReader< $Response$>* $Method$Raw(" "::grpc::ClientContext* context, const $Request$& request)" " override;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "::grpc::ClientAsyncReader< $Response$>* $AsyncPrefix$$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "::grpc::ClientAsyncReader< $Response$>* " + "$AsyncPrefix$$Method$Raw(" + "::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + } } } else if (method->BidiStreaming()) { printer->Print(*vars, "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$Method$Raw(::grpc::ClientContext* context) override;\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncRawArgs"] = async_prefix.raw_args; - printer->Print( - *vars, - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " - "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncRawArgs"] = async_prefix.raw_args; + printer->Print( + *vars, + "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " + "$AsyncPrefix$$Method$Raw(::grpc::ClientContext* context, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) override;\n"); + } } } } @@ -724,31 +768,35 @@ void PrintHeaderClientMethodData(grpc_generator::Printer* printer, void PrintHeaderServerMethodSync(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); printer->Print(method->GetLeadingComments("//").c_str()); + if (params.allow_sync_server_api) { + printer->Print("virtual "); + } if (method->NoStreaming()) { printer->Print(*vars, - "virtual ::grpc::Status $Method$(" + "::grpc::Status $Method$(" "::grpc::ServerContext* context, const $Request$* request, " "$Response$* response);\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "virtual ::grpc::Status $Method$(" + "::grpc::Status $Method$(" "::grpc::ServerContext* context, " "::grpc::ServerReader< $Request$>* reader, " "$Response$* response);\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, - "virtual ::grpc::Status $Method$(" + "::grpc::Status $Method$(" "::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerWriter< $Response$>* writer);\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, - "virtual ::grpc::Status $Method$(" + "::grpc::Status $Method$(" "::grpc::ServerContext* context, " "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);" "\n"); @@ -761,17 +809,19 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer* printer, // to generate async and raw async APIs. void PrintHeaderServerAsyncMethodsHelper( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map* vars) { + const Parameters& params, std::map* vars) { if (method->NoStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "void Request$Method$(" @@ -784,16 +834,18 @@ void PrintHeaderServerAsyncMethodsHelper( "request, response, new_call_cq, notification_cq, tag);\n"); printer->Print("}\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "void Request$Method$(" @@ -806,16 +858,18 @@ void PrintHeaderServerAsyncMethodsHelper( "context, reader, new_call_cq, notification_cq, tag);\n"); printer->Print("}\n"); } else if (ServerOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " - "{\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "{\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "void Request$Method$(" @@ -829,16 +883,18 @@ void PrintHeaderServerAsyncMethodsHelper( "context, request, writer, new_call_cq, notification_cq, tag);\n"); printer->Print("}\n"); } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " - " override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + " override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "void Request$Method$(" @@ -856,6 +912,7 @@ void PrintHeaderServerAsyncMethodsHelper( void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); // These will be disabled @@ -881,7 +938,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "~WithAsyncMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); - PrintHeaderServerAsyncMethodsHelper(printer, method, vars); + PrintHeaderServerAsyncMethodsHelper(printer, method, params, vars); printer->Outdent(); printer->Print(*vars, "};\n"); } @@ -891,17 +948,19 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, // to generate callback and raw callback APIs. void PrintHeaderServerCallbackMethodsHelper( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map* vars) { + const Parameters& params, std::map* vars) { if (method->NoStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print(*vars, "virtual ::grpc::ServerUnaryReactor* $Method$(\n" " ::grpc::CallbackServerContext* /*context*/, " @@ -909,16 +968,18 @@ void PrintHeaderServerCallbackMethodsHelper( "$RealResponse$* /*response*/)" " { return nullptr; }\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print(*vars, "virtual ::grpc::ServerReadReactor< " "$RealRequest$>* $Method$(\n" @@ -926,16 +987,18 @@ void PrintHeaderServerCallbackMethodsHelper( "/*context*/, $RealResponse$* /*response*/)" " { return nullptr; }\n"); } else if (ServerOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " - "{\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "{\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n" @@ -943,16 +1006,18 @@ void PrintHeaderServerCallbackMethodsHelper( "/*context*/, const $RealRequest$* /*request*/)" " { return nullptr; }\n"); } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " - " override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + " override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } printer->Print( *vars, "virtual ::grpc::ServerBidiReactor< $RealRequest$, $RealResponse$>* " @@ -964,6 +1029,7 @@ void PrintHeaderServerCallbackMethodsHelper( void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); // These will be disabled @@ -1039,14 +1105,14 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, "~WithCallbackMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); - PrintHeaderServerCallbackMethodsHelper(printer, method, vars); + PrintHeaderServerCallbackMethodsHelper(printer, method, params, vars); printer->Outdent(); printer->Print(*vars, "};\n"); } void PrintHeaderServerMethodRawCallback( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map* vars) { + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); // These will be disabled (*vars)["Request"] = method->input_type_name(); @@ -1111,7 +1177,7 @@ void PrintHeaderServerMethodRawCallback( "~WithRawCallbackMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); - PrintHeaderServerCallbackMethodsHelper(printer, method, vars); + PrintHeaderServerCallbackMethodsHelper(printer, method, params, vars); printer->Outdent(); printer->Print(*vars, "};\n"); } @@ -1227,6 +1293,7 @@ void PrintHeaderServerMethodSplitStreaming( void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); @@ -1248,49 +1315,51 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, "~WithGenericMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); - if (method->NoStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (ClientOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (ServerOnlyStreaming(method)) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " - "{\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " - " override {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); + if (params.allow_sync_server_api) { + if (method->NoStreaming()) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } else if (ClientOnlyStreaming(method)) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } else if (ServerOnlyStreaming(method)) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "{\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } else if (method->BidiStreaming()) { + printer->Print( + *vars, + "// disable synchronous version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + " override {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + } } printer->Outdent(); printer->Print(*vars, "};\n"); @@ -1298,6 +1367,7 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); // These will be disabled @@ -1322,13 +1392,14 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, "~WithRawMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); - PrintHeaderServerAsyncMethodsHelper(printer, method, vars); + PrintHeaderServerAsyncMethodsHelper(printer, method, params, vars); printer->Outdent(); printer->Print(*vars, "};\n"); } void PrintHeaderService(grpc_generator::Printer* printer, const grpc_generator::Service* service, + const Parameters& params, std::map* vars) { (*vars)["Service"] = service->name(); @@ -1352,8 +1423,8 @@ void PrintHeaderService(grpc_generator::Printer* printer, printer->Print("virtual ~StubInterface() {}\n"); for (int i = 0; i < service->method_count(); ++i) { printer->Print(service->method(i)->GetLeadingComments("//").c_str()); - PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, - true); + PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), params, + vars, true); printer->Print(service->method(i)->GetTrailingComments("//").c_str()); } PrintHeaderClientMethodCallbackInterfacesStart(printer, vars); @@ -1368,8 +1439,8 @@ void PrintHeaderService(grpc_generator::Printer* printer, printer->Print(" private:\n"); printer->Indent(); for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, - false); + PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), params, + vars, false); } printer->Outdent(); printer->Print("};\n"); @@ -1382,7 +1453,8 @@ void PrintHeaderService(grpc_generator::Printer* printer, "channel, const ::grpc::StubOptions& options = " "::grpc::StubOptions());\n"); for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethod(printer, service->method(i).get(), vars, true); + PrintHeaderClientMethod(printer, service->method(i).get(), params, vars, + true); } PrintHeaderClientMethodCallbackStart(printer, vars); for (int i = 0; i < service->method_count(); ++i) { @@ -1395,7 +1467,8 @@ void PrintHeaderService(grpc_generator::Printer* printer, printer->Print("std::shared_ptr< ::grpc::ChannelInterface> channel_;\n"); printer->Print("class async async_stub_{this};\n"); for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethod(printer, service->method(i).get(), vars, false); + PrintHeaderClientMethod(printer, service->method(i).get(), params, vars, + false); } for (int i = 0; i < service->method_count(); ++i) { PrintHeaderClientMethodData(printer, service->method(i).get(), vars); @@ -1417,33 +1490,38 @@ void PrintHeaderService(grpc_generator::Printer* printer, printer->Print("Service();\n"); printer->Print("virtual ~Service();\n"); for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderServerMethodSync(printer, service->method(i).get(), vars); + PrintHeaderServerMethodSync(printer, service->method(i).get(), params, + vars); } printer->Outdent(); printer->Print("};\n"); - // Server side - Asynchronous - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodAsync(printer, service->method(i).get(), vars); - } + if (params.allow_cq_api) { + // Server side - Asynchronous + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["Idx"] = as_string(i); + PrintHeaderServerMethodAsync(printer, service->method(i).get(), params, + vars); + } - printer->Print("typedef "); + printer->Print("typedef "); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i)->name(); - printer->Print(*vars, "WithAsyncMethod_$method_name$<"); - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - printer->Print(" >"); + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i)->name(); + printer->Print(*vars, "WithAsyncMethod_$method_name$<"); + } + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + printer->Print(" >"); + } + printer->Print(" AsyncService;\n"); } - printer->Print(" AsyncService;\n"); // Server side - Callback for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodCallback(printer, service->method(i).get(), vars); + PrintHeaderServerMethodCallback(printer, service->method(i).get(), params, + vars); } printer->Print("typedef "); @@ -1465,88 +1543,95 @@ void PrintHeaderService(grpc_generator::Printer* printer, // Server side - Generic for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars); + PrintHeaderServerMethodGeneric(printer, service->method(i).get(), params, + vars); } - // Server side - Raw - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodRaw(printer, service->method(i).get(), vars); + // Server side - Raw Async + if (params.allow_cq_api) { + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["Idx"] = as_string(i); + PrintHeaderServerMethodRaw(printer, service->method(i).get(), params, + vars); + } } // Server side - Raw Callback for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodRawCallback(printer, service->method(i).get(), vars); + PrintHeaderServerMethodRawCallback(printer, service->method(i).get(), + params, vars); } - // Server side - Streamed Unary - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodStreamedUnary(printer, service->method(i).get(), - vars); - } + if (params.allow_sync_server_api) { + // Server side - Streamed Unary + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["Idx"] = as_string(i); + PrintHeaderServerMethodStreamedUnary(printer, service->method(i).get(), + vars); + } - printer->Print("typedef "); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i)->name(); - if (service->method(i)->NoStreaming()) { - printer->Print(*vars, "WithStreamedUnaryMethod_$method_name$<"); + printer->Print("typedef "); + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i)->name(); + if (service->method(i)->NoStreaming()) { + printer->Print(*vars, "WithStreamedUnaryMethod_$method_name$<"); + } } - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - if (service->method(i)->NoStreaming()) { - printer->Print(" >"); + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + if (service->method(i)->NoStreaming()) { + printer->Print(" >"); + } } - } - printer->Print(" StreamedUnaryService;\n"); + printer->Print(" StreamedUnaryService;\n"); - // Server side - controlled server-side streaming - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodSplitStreaming(printer, service->method(i).get(), - vars); - } + // Server side - controlled server-side streaming + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["Idx"] = as_string(i); + PrintHeaderServerMethodSplitStreaming(printer, service->method(i).get(), + vars); + } - printer->Print("typedef "); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i)->name(); - auto method = service->method(i); - if (ServerOnlyStreaming(method.get())) { - printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); + printer->Print("typedef "); + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i)->name(); + auto method = service->method(i); + if (ServerOnlyStreaming(method.get())) { + printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); + } } - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - auto method = service->method(i); - if (ServerOnlyStreaming(method.get())) { - printer->Print(" >"); + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + auto method = service->method(i); + if (ServerOnlyStreaming(method.get())) { + printer->Print(" >"); + } } - } - printer->Print(" SplitStreamedService;\n"); + printer->Print(" SplitStreamedService;\n"); - // Server side - typedef for controlled both unary and server-side streaming - printer->Print("typedef "); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i)->name(); - auto method = service->method(i); - if (ServerOnlyStreaming(method.get())) { - printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); - } - if (service->method(i)->NoStreaming()) { - printer->Print(*vars, "WithStreamedUnaryMethod_$method_name$<"); + // Server side - typedef for controlled both unary and server-side streaming + printer->Print("typedef "); + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i)->name(); + auto method = service->method(i); + if (ServerOnlyStreaming(method.get())) { + printer->Print(*vars, "WithSplitStreamingMethod_$method_name$<"); + } + if (service->method(i)->NoStreaming()) { + printer->Print(*vars, "WithStreamedUnaryMethod_$method_name$<"); + } } - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - auto method = service->method(i); - if (service->method(i)->NoStreaming() || - ServerOnlyStreaming(method.get())) { - printer->Print(" >"); + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + auto method = service->method(i); + if (service->method(i)->NoStreaming() || + ServerOnlyStreaming(method.get())) { + printer->Print(" >"); + } } + printer->Print(" StreamedService;\n"); } - printer->Print(" StreamedService;\n"); printer->Outdent(); printer->Print("};\n"); @@ -1573,7 +1658,7 @@ std::string GetHeaderServices(grpc_generator::File* file, } for (int i = 0; i < file->service_count(); ++i) { - PrintHeaderService(printer.get(), file->service(i).get(), &vars); + PrintHeaderService(printer.get(), file->service(i).get(), params, &vars); printer->Print("\n"); } @@ -1682,6 +1767,7 @@ std::string GetSourceIncludes(grpc_generator::File* file, void PrintSourceClientMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); @@ -1729,32 +1815,35 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, reactor);\n}\n\n"); - printer->Print(*vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "$ns$$Service$::Stub::PrepareAsync$Method$Raw(::grpc::" - "ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Print(*vars, - " return " - "::grpc::internal::ClientAsyncResponseReaderHelper::Create" - "< $Response$, $Request$, ::grpc::protobuf::MessageLite, " - "::grpc::protobuf::MessageLite>" - "(channel_.get(), cq, rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); - printer->Print(*vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "$ns$$Service$::Stub::Async$Method$Raw(::grpc::" - "ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Print(*vars, - " auto* result =\n" - " this->PrepareAsync$Method$Raw(context, request, cq);\n" - " result->StartCall();\n" - " return result;\n" - "}\n\n"); + if (params.allow_cq_api) { + printer->Print(*vars, + "::grpc::ClientAsyncResponseReader< $Response$>* " + "$ns$$Service$::Stub::PrepareAsync$Method$Raw(::grpc::" + "ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); + printer->Print(*vars, + " return " + "::grpc::internal::ClientAsyncResponseReaderHelper::Create" + "< $Response$, $Request$, ::grpc::protobuf::MessageLite, " + "::grpc::protobuf::MessageLite>" + "(channel_.get(), cq, rpcmethod_$Method$_, " + "context, request);\n" + "}\n\n"); + printer->Print(*vars, + "::grpc::ClientAsyncResponseReader< $Response$>* " + "$ns$$Service$::Stub::Async$Method$Raw(::grpc::" + "ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); + printer->Print( + *vars, + " auto* result =\n" + " this->PrepareAsync$Method$Raw(context, request, cq);\n" + " result->StartCall();\n" + " return result;\n" + "}\n\n"); + } } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, "::grpc::ClientWriter< $Request$>* " @@ -1781,23 +1870,25 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "context, response, reactor);\n" "}\n\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncStart"] = async_prefix.start; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncCreateArgs"] = async_prefix.create_args; - printer->Print(*vars, - "::grpc::ClientAsyncWriter< $Request$>* " - "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(" - "::grpc::ClientContext* context, $Response$* response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Print( - *vars, - " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" - "::Create(channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, response, $AsyncStart$$AsyncCreateArgs$);\n" - "}\n\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncStart"] = async_prefix.start; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncCreateArgs"] = async_prefix.create_args; + printer->Print(*vars, + "::grpc::ClientAsyncWriter< $Request$>* " + "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(" + "::grpc::ClientContext* context, $Response$* response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Print( + *vars, + " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" + "::Create(channel_.get(), cq, " + "rpcmethod_$Method$_, " + "context, response, $AsyncStart$$AsyncCreateArgs$);\n" + "}\n\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -1826,24 +1917,26 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "context, request, reactor);\n" "}\n\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncStart"] = async_prefix.start; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncCreateArgs"] = async_prefix.create_args; - printer->Print( - *vars, - "::grpc::ClientAsyncReader< $Response$>* " - "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Print(*vars, - " return ::grpc::internal::ClientAsyncReaderFactory< " - "$Response$>" - "::Create(channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, request, $AsyncStart$$AsyncCreateArgs$);\n" - "}\n\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncStart"] = async_prefix.start; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncCreateArgs"] = async_prefix.create_args; + printer->Print( + *vars, + "::grpc::ClientAsyncReader< $Response$>* " + "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(" + "::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Print(*vars, + " return ::grpc::internal::ClientAsyncReaderFactory< " + "$Response$>" + "::Create(channel_.get(), cq, " + "rpcmethod_$Method$_, " + "context, request, $AsyncStart$$AsyncCreateArgs$);\n" + "}\n\n"); + } } } else if (method->BidiStreaming()) { printer->Print( @@ -1871,30 +1964,34 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "context, reactor);\n" "}\n\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncStart"] = async_prefix.start; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["AsyncCreateArgs"] = async_prefix.create_args; - printer->Print(*vars, - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " - "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(::grpc::" - "ClientContext* context, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Print(*vars, - " return " - "::grpc::internal::ClientAsyncReaderWriterFactory< " - "$Request$, $Response$>::Create(" - "channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, $AsyncStart$$AsyncCreateArgs$);\n" - "}\n\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncStart"] = async_prefix.start; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["AsyncCreateArgs"] = async_prefix.create_args; + printer->Print( + *vars, + "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " + "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(::grpc::" + "ClientContext* context, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); + printer->Print(*vars, + " return " + "::grpc::internal::ClientAsyncReaderWriterFactory< " + "$Request$, $Response$>::Create(" + "channel_.get(), cq, " + "rpcmethod_$Method$_, " + "context, $AsyncStart$$AsyncCreateArgs$);\n" + "}\n\n"); + } } } } void PrintSourceServerMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); @@ -1904,6 +2001,9 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, "::grpc::Status $ns$$Service$::Service::$Method$(" "::grpc::ServerContext* context, " "const $Request$* request, $Response$* response) {\n"); + if (!params.allow_sync_server_api) { + printer->Print(" abort();\n"); + } printer->Print(" (void) context;\n"); printer->Print(" (void) request;\n"); printer->Print(" (void) response;\n"); @@ -1917,6 +2017,9 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, "::grpc::ServerContext* context, " "::grpc::ServerReader< $Request$>* reader, " "$Response$* response) {\n"); + if (!params.allow_sync_server_api) { + printer->Print(" abort();\n"); + } printer->Print(" (void) context;\n"); printer->Print(" (void) reader;\n"); printer->Print(" (void) response;\n"); @@ -1930,6 +2033,9 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, "::grpc::ServerContext* context, " "const $Request$* request, " "::grpc::ServerWriter< $Response$>* writer) {\n"); + if (!params.allow_sync_server_api) { + printer->Print(" abort();\n"); + } printer->Print(" (void) context;\n"); printer->Print(" (void) request;\n"); printer->Print(" (void) writer;\n"); @@ -1943,6 +2049,9 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, "::grpc::ServerContext* context, " "::grpc::ServerReaderWriter< $Response$, $Request$>* " "stream) {\n"); + if (!params.allow_sync_server_api) { + printer->Print(" abort();\n"); + } printer->Print(" (void) context;\n"); printer->Print(" (void) stream;\n"); printer->Print( @@ -1954,6 +2063,7 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, void PrintSourceService(grpc_generator::Printer* printer, const grpc_generator::Service* service, + const Parameters& params, std::map* vars) { (*vars)["Service"] = service->name(); @@ -2011,7 +2121,7 @@ void PrintSourceService(grpc_generator::Printer* printer, for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintSourceClientMethod(printer, service->method(i).get(), vars); + PrintSourceClientMethod(printer, service->method(i).get(), params, vars); } printer->Print(*vars, "$ns$$Service$::Service::Service() {\n"); @@ -2087,7 +2197,7 @@ void PrintSourceService(grpc_generator::Printer* printer, "}\n\n"); for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintSourceServerMethod(printer, service->method(i).get(), vars); + PrintSourceServerMethod(printer, service->method(i).get(), params, vars); } } @@ -2113,7 +2223,7 @@ std::string GetSourceServices(grpc_generator::File* file, } for (int i = 0; i < file->service_count(); ++i) { - PrintSourceService(printer.get(), file->service(i).get(), &vars); + PrintSourceService(printer.get(), file->service(i).get(), params, &vars); printer->Print("\n"); } } @@ -2224,6 +2334,7 @@ std::string GetMockIncludes(grpc_generator::File* file, void PrintMockClientMethods(grpc_generator::Printer* printer, const grpc_generator::Method* method, + const Parameters& params, std::map* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); @@ -2240,14 +2351,16 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, *vars, "MOCK_METHOD3($Method$, ::grpc::Status(::grpc::ClientContext* context, " "const $Request$& request, $Response$* response));\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - printer->Print( - *vars, - "MOCK_METHOD3($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncResponseReaderInterface< $Response$>*" - "(::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq));\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + printer->Print( + *vars, + "MOCK_METHOD3($AsyncPrefix$$Method$Raw, " + "::grpc::ClientAsyncResponseReaderInterface< $Response$>*" + "(::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq));\n"); + } } } else if (ClientOnlyStreaming(method)) { printer->Print( @@ -2255,16 +2368,18 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, "MOCK_METHOD2($Method$Raw, " "::grpc::ClientWriterInterface< $Request$>*" "(::grpc::ClientContext* context, $Response$* response));\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["MockArgs"] = - std::to_string(3 + async_prefix.extra_method_param_count); - printer->Print(*vars, - "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncWriterInterface< $Request$>*" - "(::grpc::ClientContext* context, $Response$* response, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$));\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["MockArgs"] = + std::to_string(3 + async_prefix.extra_method_param_count); + printer->Print(*vars, + "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " + "::grpc::ClientAsyncWriterInterface< $Request$>*" + "(::grpc::ClientContext* context, $Response$* response, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$));\n"); + } } } else if (ServerOnlyStreaming(method)) { printer->Print( @@ -2272,17 +2387,19 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, "MOCK_METHOD2($Method$Raw, " "::grpc::ClientReaderInterface< $Response$>*" "(::grpc::ClientContext* context, const $Request$& request));\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["MockArgs"] = - std::to_string(3 + async_prefix.extra_method_param_count); - printer->Print( - *vars, - "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncReaderInterface< $Response$>*" - "(::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq$AsyncMethodParams$));\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["MockArgs"] = + std::to_string(3 + async_prefix.extra_method_param_count); + printer->Print( + *vars, + "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " + "::grpc::ClientAsyncReaderInterface< $Response$>*" + "(::grpc::ClientContext* context, const $Request$& request, " + "::grpc::CompletionQueue* cq$AsyncMethodParams$));\n"); + } } } else if (method->BidiStreaming()) { printer->Print( @@ -2290,24 +2407,27 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, "MOCK_METHOD1($Method$Raw, " "::grpc::ClientReaderWriterInterface< $Request$, $Response$>*" "(::grpc::ClientContext* context));\n"); - for (auto async_prefix : async_prefixes) { - (*vars)["AsyncPrefix"] = async_prefix.prefix; - (*vars)["AsyncMethodParams"] = async_prefix.method_params; - (*vars)["MockArgs"] = - std::to_string(2 + async_prefix.extra_method_param_count); - printer->Print( - *vars, - "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncReaderWriterInterface<$Request$, " - "$Response$>*" - "(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq" - "$AsyncMethodParams$));\n"); + if (params.allow_cq_api) { + for (const auto& async_prefix : async_prefixes) { + (*vars)["AsyncPrefix"] = async_prefix.prefix; + (*vars)["AsyncMethodParams"] = async_prefix.method_params; + (*vars)["MockArgs"] = + std::to_string(2 + async_prefix.extra_method_param_count); + printer->Print( + *vars, + "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " + "::grpc::ClientAsyncReaderWriterInterface<$Request$, " + "$Response$>*" + "(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq" + "$AsyncMethodParams$));\n"); + } } } } void PrintMockService(grpc_generator::Printer* printer, const grpc_generator::Service* service, + const Parameters& params, std::map* vars) { (*vars)["Service"] = service->name(); @@ -2316,7 +2436,7 @@ void PrintMockService(grpc_generator::Printer* printer, " public:\n"); printer->Indent(); for (int i = 0; i < service->method_count(); ++i) { - PrintMockClientMethods(printer, service->method(i).get(), vars); + PrintMockClientMethods(printer, service->method(i).get(), params, vars); } printer->Outdent(); printer->Print("};\n"); @@ -2342,7 +2462,7 @@ std::string GetMockServices(grpc_generator::File* file, } for (int i = 0; i < file->service_count(); i++) { - PrintMockService(printer.get(), file->service(i).get(), &vars); + PrintMockService(printer.get(), file->service(i).get(), params, &vars); printer->Print("\n"); } diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h index 4032876cef8..14e8f129af5 100644 --- a/src/compiler/cpp_generator.h +++ b/src/compiler/cpp_generator.h @@ -64,6 +64,10 @@ struct Parameters { std::string message_header_extension; // Whether to include headers corresponding to imports in source file. bool include_import_headers; + // Whether to expose synchronous server API. + bool allow_sync_server_api; + // Whether to generate completion queue API. + bool allow_cq_api; }; // Return the prologue of the generated header file. diff --git a/src/compiler/cpp_plugin.h b/src/compiler/cpp_plugin.h index 9c8c4bd2474..1e356e9421d 100644 --- a/src/compiler/cpp_plugin.h +++ b/src/compiler/cpp_plugin.h @@ -65,6 +65,8 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { generator_parameters.use_system_headers = true; generator_parameters.generate_mock_code = false; generator_parameters.include_import_headers = false; + generator_parameters.allow_sync_server_api = true; + generator_parameters.allow_cq_api = true; ProtoBufFile pbfile(file); @@ -95,6 +97,24 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { *error = std::string("Invalid parameter: ") + *parameter_string; return false; } + } else if (param[0] == "allow_sync_server_api") { + if (param[1] == "true") { + generator_parameters.allow_sync_server_api = true; + } else if (param[1] == "false") { + generator_parameters.allow_sync_server_api = false; + } else { + *error = std::string("Invalid parameter: ") + *parameter_string; + return false; + } + } else if (param[0] == "allow_cq_api") { + if (param[1] == "true") { + generator_parameters.allow_cq_api = true; + } else if (param[1] == "false") { + generator_parameters.allow_cq_api = false; + } else { + *error = std::string("Invalid parameter: ") + *parameter_string; + return false; + } } else if (param[0] == "gmock_search_path") { generator_parameters.gmock_search_path = param[1]; } else if (param[0] == "additional_header_includes") { From 7396cec6249bafd3412d65ef150cb62858793307 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 17 Apr 2024 00:22:52 +0000 Subject: [PATCH 13/45] Automated rollback of commit 7561250649fb5dc01040b8ade45328750993feac. PiperOrigin-RevId: 625502885 --- src/cpp/ext/otel/BUILD | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cpp/ext/otel/BUILD b/src/cpp/ext/otel/BUILD index fe5cb0bd478..588c769652d 100644 --- a/src/cpp/ext/otel/BUILD +++ b/src/cpp/ext/otel/BUILD @@ -55,13 +55,9 @@ grpc_cc_library( "absl/types:optional", "absl/types:span", "otel/api", - "otel/sdk", ], language = "c++", - visibility = [ - "//:__subpackages__", - "//blockchain/research/falcon/monitoring:__subpackages__", - ], + visibility = ["//:__subpackages__"], deps = [ "//:call_tracer", "//:config", From 56d25ca55628afb6522b25ea279e5313a3539065 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 17 Apr 2024 01:10:20 +0000 Subject: [PATCH 14/45] [Import] Fix header include PiperOrigin-RevId: 625513555 --- src/core/ext/filters/backend_metrics/backend_metric_filter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc index e2caef67939..c3ce55921d8 100644 --- a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +++ b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc @@ -25,7 +25,6 @@ #include #include "absl/strings/string_view.h" -#include "third_party/grpc/src/core/lib/channel/promise_based_filter.h" #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" @@ -35,6 +34,7 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/context.h" +#include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" From 0eb35d2baf44a28626aec014420dad228d208fe4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Tue, 16 Apr 2024 19:27:09 -0700 Subject: [PATCH 15/45] [Sanity] Fix sanity (#36386) Closes #36386 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36386 from yashykt:FixMaster cf8c7c36d3fdae59d97511013ba11859f18eb297 PiperOrigin-RevId: 625529031 --- include/grpc/credentials.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/grpc/credentials.h b/include/grpc/credentials.h index 71d1864dc24..c3a076991c6 100644 --- a/include/grpc/credentials.h +++ b/include/grpc/credentials.h @@ -19,12 +19,11 @@ #ifndef GRPC_CREDENTIALS_H #define GRPC_CREDENTIALS_H -#include - #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -94,10 +93,10 @@ typedef struct { const char* actor_token_type; /* Optional. */ } grpc_sts_credentials_options; -/** Creates an STS credentials following the STS Token Exchanged specifi ed in the - IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - This API is used for experimental purposes for now and may change in the - future. */ +/** Creates an STS credentials following the STS Token Exchanged specified in + the IETF draft + https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. This API is + used for experimental purposes for now and may change in the future. */ GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( const grpc_sts_credentials_options* options, void* reserved); From fceacd7a2cfda6a512fa6b35be5222ab9aafe478 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:00:52 -0700 Subject: [PATCH 16/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36365) Closes #36365 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36365 from tanvi-jagtap:tjagtap_bad_client d769b84024430407b23b06a4ba6e8f714e0f62d1 PiperOrigin-RevId: 625557190 --- CMakeLists.txt | 12 ++++++ build_autogenerated.yaml | 12 ++++++ test/core/bad_client/bad_client.cc | 43 +++++++++---------- test/core/bad_client/generate_tests.bzl | 4 ++ .../core/bad_client/tests/bad_streaming_id.cc | 8 ++-- test/core/bad_client/tests/badreq.cc | 8 ++-- .../bad_client/tests/connection_prefix.cc | 8 ++-- .../core/bad_client/tests/duplicate_header.cc | 12 +++--- .../bad_client/tests/head_of_line_blocking.cc | 6 ++- test/core/bad_client/tests/headers.cc | 9 ++-- .../tests/initial_settings_frame.cc | 17 ++++---- test/core/bad_client/tests/out_of_bounds.cc | 8 ++-- .../tests/server_registered_method.cc | 12 +++--- test/core/bad_client/tests/simple_request.cc | 24 ++++++----- test/core/bad_client/tests/unknown_frame.cc | 8 ++-- test/core/bad_client/tests/window_overflow.cc | 8 ++-- 16 files changed, 124 insertions(+), 75 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ec682d102a..97c724e8b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7763,6 +7763,7 @@ target_include_directories(bad_streaming_id_bad_client_test target_link_libraries(bad_streaming_id_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -7807,6 +7808,7 @@ target_include_directories(badreq_bad_client_test target_link_libraries(badreq_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -11394,6 +11396,7 @@ target_include_directories(connection_prefix_bad_client_test target_link_libraries(connection_prefix_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -12451,6 +12454,7 @@ target_include_directories(duplicate_header_bad_client_test target_link_libraries(duplicate_header_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -16519,6 +16523,7 @@ target_include_directories(head_of_line_blocking_bad_client_test target_link_libraries(head_of_line_blocking_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -16563,6 +16568,7 @@ target_include_directories(headers_bad_client_test target_link_libraries(headers_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -17560,6 +17566,7 @@ target_include_directories(initial_settings_frame_bad_client_test target_link_libraries(initial_settings_frame_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -20788,6 +20795,7 @@ target_include_directories(out_of_bounds_bad_client_test target_link_libraries(out_of_bounds_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -27177,6 +27185,7 @@ target_include_directories(server_registered_method_bad_client_test target_link_libraries(server_registered_method_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -27922,6 +27931,7 @@ target_include_directories(simple_request_bad_client_test target_link_libraries(simple_request_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -31826,6 +31836,7 @@ target_include_directories(unknown_frame_bad_client_test target_link_libraries(unknown_frame_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -32300,6 +32311,7 @@ target_include_directories(window_overflow_bad_client_test target_link_libraries(window_overflow_bad_client_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 2084da2d886..2f2384c9abb 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -5976,6 +5976,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: badreq_bad_client_test gtest: true @@ -5990,6 +5991,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: basic_work_queue_test gtest: true @@ -8273,6 +8275,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: connection_refused_test gtest: true @@ -8726,6 +8729,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: empty_batch_test gtest: true @@ -11002,6 +11006,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: headers_bad_client_test gtest: true @@ -11016,6 +11021,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: health_service_end2end_test gtest: true @@ -11520,6 +11526,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: inproc_test gtest: true @@ -13366,6 +13373,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: outlier_detection_lb_config_parser_test gtest: true @@ -17608,6 +17616,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: server_request_call_test gtest: true @@ -18082,6 +18091,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: simple_request_test gtest: true @@ -19859,6 +19869,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: uri_parser_test gtest: true @@ -20024,6 +20035,7 @@ targets: - test/core/end2end/cq_verifier.cc deps: - gtest + - absl/log:check - grpc_test_util - name: windows_endpoint_test gtest: true diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index f0997e4b13d..7394e109b5e 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -21,6 +21,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -76,7 +78,7 @@ static void server_setup_transport(void* ts, grpc_core::Transport* transport) { thd_args* a = static_cast(ts); grpc_core::ExecCtx exec_ctx; grpc_core::Server* core_server = grpc_core::Server::FromC(a->server); - GPR_ASSERT(GRPC_LOG_IF_ERROR( + CHECK(GRPC_LOG_IF_ERROR( "SetupTransport", core_server->SetupTransport(transport, /*accepting_pollset=*/nullptr, core_server->channel_args(), @@ -135,8 +137,7 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, // Await completion, unless the request is large and write may not finish // before the peer shuts down. if (!(flags & GRPC_BAD_CLIENT_LARGE_REQUEST)) { - GPR_ASSERT( - gpr_event_wait(&done_write, grpc_timeout_seconds_to_deadline(5))); + CHECK(gpr_event_wait(&done_write, grpc_timeout_seconds_to_deadline(5))); } if (flags & GRPC_BAD_CLIENT_DISCONNECT) { @@ -161,13 +162,13 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, /*urgent=*/true, /*min_progress_size=*/1); grpc_core::ExecCtx::Get()->Flush(); do { - GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0); + CHECK_GT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)), 0); // Perform a cq next just to provide a thread that can read incoming // bytes on the client fd - GPR_ASSERT(grpc_completion_queue_next( - client_cq, grpc_timeout_milliseconds_to_deadline(100), - nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + client_cq, grpc_timeout_milliseconds_to_deadline(100), + nullptr) + .type == GRPC_QUEUE_TIMEOUT); } while (!gpr_event_get(&read_done_event)); if (arg->client_validator(&incoming, arg->client_validator_arg)) break; gpr_log(GPR_INFO, @@ -187,10 +188,9 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, // Make sure that the client is done writing while (!gpr_event_get(&done_write)) { - GPR_ASSERT( - grpc_completion_queue_next( - client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } grpc_slice_buffer_destroy(&outgoing); @@ -238,7 +238,7 @@ void grpc_run_bad_client_test( grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq)); // Check a ground truth - GPR_ASSERT(grpc_core::Server::FromC(a.server)->HasOpenConnections()); + CHECK(grpc_core::Server::FromC(a.server)->HasOpenConnections()); gpr_event_init(&a.done_thd); a.validator = server_validator; @@ -251,17 +251,16 @@ void grpc_run_bad_client_test( &sfd, client_cq); } // Wait for server thread to finish - GPR_ASSERT(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(5))); + CHECK(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(5))); // Shutdown. shutdown_client(&sfd.client); server_validator_thd.Join(); shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); grpc_server_shutdown_and_notify(a.server, shutdown_cq, nullptr); - GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr, - grpc_timeout_seconds_to_deadline(1), - nullptr) - .type == GRPC_OP_COMPLETE); + CHECK(grpc_completion_queue_pluck( + shutdown_cq, nullptr, grpc_timeout_seconds_to_deadline(1), nullptr) + .type == GRPC_OP_COMPLETE); grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); @@ -301,7 +300,7 @@ bool rst_stream_client_validator(grpc_slice_buffer* incoming, void* /*arg*/) { grpc_slice_buffer_init(&last_frame_buffer); grpc_slice_buffer_trim_end(incoming, kExpectedFrameLength, &last_frame_buffer); - GPR_ASSERT(last_frame_buffer.count == 1); + CHECK_EQ(last_frame_buffer.count, 1u); grpc_slice last_frame = last_frame_buffer.slices[0]; const uint8_t* p = GRPC_SLICE_START_PTR(last_frame); @@ -340,12 +339,12 @@ void server_verifier_request_call(grpc_server* server, error = grpc_server_request_call(server, &s, &call_details, &request_metadata_recv, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + CHECK_EQ(grpc_slice_str_cmp(call_details.host, "localhost"), 0); + CHECK_EQ(grpc_slice_str_cmp(call_details.method, "/foo/bar"), 0); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 48949315472..4eb204175ec 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -51,6 +51,9 @@ def grpc_bad_client_tests(): "//test/core/end2end:cq_verifier", "//:grpc_http_filters", ], + external_deps = [ + "absl/log:check", + ], ) for t, topt in BAD_CLIENT_TESTS.items(): grpc_cc_test( @@ -59,6 +62,7 @@ def grpc_bad_client_tests(): deps = [":bad_client_test"], tags = ["bad_client_test"], external_deps = [ + "absl/log:check", "gtest", ], ) diff --git a/test/core/bad_client/tests/bad_streaming_id.cc b/test/core/bad_client/tests/bad_streaming_id.cc index 14c676fb0d9..2715f52e8f7 100644 --- a/test/core/bad_client/tests/bad_streaming_id.cc +++ b/test/core/bad_client/tests/bad_streaming_id.cc @@ -20,6 +20,8 @@ #include +#include "absl/log/check.h" + #include #include @@ -80,9 +82,9 @@ namespace { void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc index 856e8851287..9b6b5ea7339 100644 --- a/test/core/bad_client/tests/badreq.cc +++ b/test/core/bad_client/tests/badreq.cc @@ -16,6 +16,8 @@ // // +#include "absl/log/check.h" + #include #include @@ -30,9 +32,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc index 83b513b511c..604e7040f12 100644 --- a/test/core/bad_client/tests/connection_prefix.cc +++ b/test/core/bad_client/tests/connection_prefix.cc @@ -16,6 +16,8 @@ // // +#include "absl/log/check.h" + #include #include @@ -26,9 +28,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/duplicate_header.cc b/test/core/bad_client/tests/duplicate_header.cc index ad5754d1db9..c4edc871355 100644 --- a/test/core/bad_client/tests/duplicate_header.cc +++ b/test/core/bad_client/tests/duplicate_header.cc @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -70,7 +72,7 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, error = grpc_server_request_call(server, &s, &call_details, &request_metadata_recv, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); bool got = false; cqv.Expect(grpc_core::CqVerifier::tag(101), grpc_core::CqVerifier::Maybe{&got}); @@ -84,8 +86,8 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, return; } - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + CHECK_EQ(grpc_slice_str_cmp(call_details.host, "localhost"), 0); + CHECK_EQ(grpc_slice_str_cmp(call_details.method, "/foo/bar"), 0); memset(ops, 0, sizeof(ops)); op = ops; @@ -101,7 +103,7 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, op++; error = grpc_call_start_batch(s, ops, static_cast(op - ops), grpc_core::CqVerifier::tag(102), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(102), grpc_core::CqVerifier::AnyStatus()); @@ -124,7 +126,7 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, op++; error = grpc_call_start_batch(s, ops, static_cast(op - ops), grpc_core::CqVerifier::tag(103), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(103), true); cqv.Verify(); diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc index 7360d8e7e7a..07122148202 100644 --- a/test/core/bad_client/tests/head_of_line_blocking.cc +++ b/test/core/bad_client/tests/head_of_line_blocking.cc @@ -21,6 +21,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -85,11 +87,11 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, error = grpc_server_request_registered_call( server, registered_method, &s, &deadline, &request_metadata_recv, &payload, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(payload != nullptr); + CHECK_NE(payload, nullptr); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_unref(s); diff --git a/test/core/bad_client/tests/headers.cc b/test/core/bad_client/tests/headers.cc index f1b4b14251e..dca232d2afa 100644 --- a/test/core/bad_client/tests/headers.cc +++ b/test/core/bad_client/tests/headers.cc @@ -16,8 +16,9 @@ // // +#include "absl/log/check.h" + #include -#include #include "src/core/lib/surface/server.h" #include "test/core/bad_client/bad_client.h" @@ -30,9 +31,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/initial_settings_frame.cc b/test/core/bad_client/tests/initial_settings_frame.cc index 384d1662ab2..8b992b0b220 100644 --- a/test/core/bad_client/tests/initial_settings_frame.cc +++ b/test/core/bad_client/tests/initial_settings_frame.cc @@ -16,11 +16,11 @@ // // +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include #include -#include #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/surface/server.h" @@ -87,9 +87,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } @@ -109,13 +109,14 @@ static void single_request_verifier(grpc_server* server, error = grpc_server_request_call(server, &s, &call_details, &request_metadata_recv, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, - absl::StrCat("/foo/bar", i).c_str())); + CHECK_EQ(grpc_slice_str_cmp(call_details.host, "localhost"), 0); + CHECK_EQ(grpc_slice_str_cmp(call_details.method, + absl::StrCat("/foo/bar", i).c_str()), + 0); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); diff --git a/test/core/bad_client/tests/out_of_bounds.cc b/test/core/bad_client/tests/out_of_bounds.cc index 00eda5db9b8..e23ec13df21 100644 --- a/test/core/bad_client/tests/out_of_bounds.cc +++ b/test/core/bad_client/tests/out_of_bounds.cc @@ -20,6 +20,8 @@ #include +#include "absl/log/check.h" + #include #include @@ -35,9 +37,9 @@ namespace { void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc index 2b9059bda19..67a67b744e8 100644 --- a/test/core/bad_client/tests/server_registered_method.cc +++ b/test/core/bad_client/tests/server_registered_method.cc @@ -16,6 +16,8 @@ // // +#include "absl/log/check.h" + #include #include #include @@ -55,11 +57,11 @@ static void verifier_succeeds(grpc_server* server, grpc_completion_queue* cq, error = grpc_server_request_registered_call( server, registered_method, &s, &deadline, &request_metadata_recv, &payload, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(payload != nullptr); + CHECK_NE(payload, nullptr); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_unref(s); @@ -69,9 +71,9 @@ static void verifier_succeeds(grpc_server* server, grpc_completion_queue* cq, static void verifier_fails(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc index dcc650194fe..d3c90ed81d6 100644 --- a/test/core/bad_client/tests/simple_request.cc +++ b/test/core/bad_client/tests/simple_request.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "absl/log/check.h" + #include #include #include @@ -116,12 +118,12 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, error = grpc_server_request_call(server, &s, &call_details, &request_metadata_recv, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + CHECK_EQ(grpc_slice_str_cmp(call_details.host, "localhost"), 0); + CHECK_EQ(grpc_slice_str_cmp(call_details.method, "/foo/bar"), 0); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); @@ -144,12 +146,12 @@ static void VerifyRpcDoesNotGetCanceled(grpc_server* server, error = grpc_server_request_call(server, &s, &call_details, &request_metadata_recv, cq, cq, grpc_core::CqVerifier::tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(101), true); cqv.Verify(); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + CHECK_EQ(grpc_slice_str_cmp(call_details.host, "localhost"), 0); + CHECK_EQ(grpc_slice_str_cmp(call_details.method, "/foo/bar"), 0); grpc_op* op; grpc_op ops[6]; @@ -176,13 +178,13 @@ static void VerifyRpcDoesNotGetCanceled(grpc_server* server, op++; error = grpc_call_start_batch(s, ops, static_cast(op - ops), grpc_core::CqVerifier::tag(103), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); cqv.Expect(grpc_core::CqVerifier::tag(103), true); cqv.Verify(); // If the call had an error, `was_cancelled` would be 1. - // GPR_ASSERT(was_cancelled == 1); + // CHECK_EQ(was_cancelled, 1); grpc_metadata_array_destroy(&request_metadata_recv); grpc_call_details_destroy(&call_details); @@ -192,9 +194,9 @@ static void VerifyRpcDoesNotGetCanceled(grpc_server* server, static void failure_verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index 6fa368870fc..8eb847bd119 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -20,6 +20,8 @@ #include +#include "absl/log/check.h" + #include #include @@ -30,9 +32,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index 401d1bbce71..f16645a0789 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -17,6 +17,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -45,9 +47,9 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq, void* /*registered_method*/) { while (grpc_core::Server::FromC(server)->HasOpenConnections()) { - GPR_ASSERT(grpc_completion_queue_next( - cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + CHECK(grpc_completion_queue_next( + cq, grpc_timeout_milliseconds_to_deadline(20), nullptr) + .type == GRPC_QUEUE_TIMEOUT); } } From f7962578c1ab7388bf2b080dc6de6ae9fb21f0b8 Mon Sep 17 00:00:00 2001 From: Alisha Nanda Date: Wed, 17 Apr 2024 13:11:46 -0700 Subject: [PATCH 17/45] [gRPC CLI] Add a --channel_args string flag (a=b,c=d). PiperOrigin-RevId: 625783208 --- test/cpp/util/grpc_tool.cc | 22 ++++++++++++++++- test/cpp/util/grpc_tool_test.cc | 42 +++++++++++++++++++++++++++++---- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index c1ebecd333b..95c8bc3d83b 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -25,9 +25,12 @@ #include #include #include +#include #include "absl/flags/flag.h" -#include "absl/memory/memory.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" #include #include @@ -82,6 +85,9 @@ ABSL_FLAG( int, max_recv_msg_size, 0, "Specify the max receive message size in bytes for all RPCs. -1 indicates " "unlimited. The default value of 0 means to use the gRPC default."); +ABSL_FLAG(std::string, channel_args, "", + "Comma-separated list of key=value gRPC ChannelArgs to apply " + "(a=b,c=d,...). Values may be integers or strings."); namespace grpc { namespace testing { @@ -244,6 +250,20 @@ std::shared_ptr CreateCliChannel( // See |GRPC_ARG_MAX_METADATA_SIZE| in |grpc_types.h|. // Set to large enough size (10M) that should work for most use cases. args.SetInt(GRPC_ARG_MAX_METADATA_SIZE, 10 * 1024 * 1024); + + // Extend channel args according to flag --channel_args. + const auto flag = absl::GetFlag(FLAGS_channel_args); + for (absl::string_view arg : + absl::StrSplit(flag, ',', absl::SkipWhitespace())) { + std::pair kv = + absl::StrSplit(arg, absl::MaxSplits('=', 1), absl::SkipWhitespace()); + int ival; + if (absl::SimpleAtoi(kv.second, &ival)) { + args.SetInt(kv.first, ival); + } else if (!kv.second.empty()) { + args.SetString(kv.first, kv.second); + } + } return grpc::CreateCustomChannel(server_address, cred.GetCredentials(), args); } diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index 1148c182666..057a0008b8e 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -133,6 +133,7 @@ ABSL_DECLARE_FLAG(std::string, proto_path); ABSL_DECLARE_FLAG(std::string, default_service_config); ABSL_DECLARE_FLAG(double, timeout); ABSL_DECLARE_FLAG(int, max_recv_msg_size); +ABSL_DECLARE_FLAG(std::string, channel_args); namespace grpc { namespace testing { @@ -1299,11 +1300,11 @@ TEST_F(GrpcToolTest, CallMaxRecvMessageSizeSmall) { // Set max_recv_msg_size to 4 which is not enough. absl::SetFlag(&FLAGS_max_recv_msg_size, 4); - - // This should fail. EXPECT_FALSE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), std::bind(PrintStream, &output_stream, std::placeholders::_1))); + absl::SetFlag(&FLAGS_max_recv_msg_size, 0); + // No output expected. EXPECT_TRUE(0 == output_stream.tellp()); ShutdownServer(); @@ -1320,10 +1321,11 @@ TEST_F(GrpcToolTest, CallMaxRecvMessageSizeEnough) { // Set max_recv_msg_size to a large enough number. absl::SetFlag(&FLAGS_max_recv_msg_size, 1024 * 1024); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), std::bind(PrintStream, &output_stream, std::placeholders::_1))); + absl::SetFlag(&FLAGS_max_recv_msg_size, 0); + // Expected output: "message: \"Hello\"" EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello\"")); @@ -1341,10 +1343,10 @@ TEST_F(GrpcToolTest, CallMaxRecvMessageSizeDefault) { // Set max_recv_msg_size to gRPC default, which should suffice. absl::SetFlag(&FLAGS_max_recv_msg_size, 0); - 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\"")); @@ -1362,16 +1364,46 @@ TEST_F(GrpcToolTest, CallMaxRecvMessageSizeUnlimited) { // Set max_recv_msg_size to unlimited (-1), which should work. absl::SetFlag(&FLAGS_max_recv_msg_size, -1); - EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), std::bind(PrintStream, &output_stream, std::placeholders::_1))); + absl::SetFlag(&FLAGS_max_recv_msg_size, 0); + // Expected output: "message: \"Hello\"" EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello\"")); ShutdownServer(); } +// This duplicates CallMaxRecvMessageSizeSmall, but using --channel_args. +TEST_F(GrpcToolTest, CallWithChannelArgs) { + std::stringstream output_stream; + const std::string server_address = SetUpServer(); + // Test input "grpc_cli call localhost:10000 Echo "message: 'Hello' + // --channel_args=grpc.max_receive_message_length=4" + const char* argv[] = {"grpc_cli", "call", server_address.c_str(), + "grpc.testing.EchoTestService.Echo", + "message: 'Hello'"}; + + // Set max receive size to 4 bytes which is not enough. + absl::SetFlag(&FLAGS_channel_args, + "x=y,grpc.max_receive_message_length=4,z=1"); + EXPECT_FALSE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + absl::SetFlag(&FLAGS_channel_args, ""); + + // Then try again with large enough size, which should succeed. + absl::SetFlag(&FLAGS_channel_args, + ",grpc.max_receive_message_length=1000000,"); + EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(), + std::bind(PrintStream, &output_stream, + std::placeholders::_1))); + absl::SetFlag(&FLAGS_channel_args, ""); + + ShutdownServer(); +} + TEST_F(GrpcToolTest, ListCommandOverrideSslHostName) { const std::string server_address = SetUpServer(true); From e82382fc7c3efe4b083cbb23060a6ae665df3bcf Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 17 Apr 2024 14:17:04 -0700 Subject: [PATCH 18/45] [OTel C++] Amend visibility rules for internal target PiperOrigin-RevId: 625804033 --- bazel/grpc_build_system.bzl | 1 + src/cpp/ext/otel/BUILD | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 784547dc230..54bb074ab2e 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -117,6 +117,7 @@ def _update_visibility(visibility): "iomgr_internal_errqueue": PRIVATE, "iomgr_buffer_list": PRIVATE, "json_reader_legacy": PRIVATE, + "otel_plugin": PRIVATE, "public": PUBLIC, "ref_counted_ptr": PRIVATE, "tcp_tracer": PRIVATE, diff --git a/src/cpp/ext/otel/BUILD b/src/cpp/ext/otel/BUILD index 588c769652d..8a1ca1affa6 100644 --- a/src/cpp/ext/otel/BUILD +++ b/src/cpp/ext/otel/BUILD @@ -57,7 +57,7 @@ grpc_cc_library( "otel/api", ], language = "c++", - visibility = ["//:__subpackages__"], + visibility = ["@grpc:otel_plugin"], deps = [ "//:call_tracer", "//:config", From f61049f6414efd299367ef8264e07ec5a1c75471 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Wed, 17 Apr 2024 16:15:02 -0700 Subject: [PATCH 19/45] [surface] Reland: Add an API to inject connected endpoints into servers PiperOrigin-RevId: 625837807 --- BUILD | 7 +- CMakeLists.txt | 7 + Makefile | 1 + Package.swift | 1 + build_autogenerated.yaml | 8 + gRPC-C++.podspec | 1 + gRPC-Core.podspec | 1 + grpc.gemspec | 1 + include/grpc/module.modulemap | 1 + include/grpc/passive_listener.h | 62 ++++ include/grpcpp/passive_listener.h | 27 ++ include/grpcpp/security/server_credentials.h | 1 + include/grpcpp/server_builder.h | 29 ++ package.xml | 1 + src/core/BUILD | 2 + .../transport/binder/server/binder_server.cc | 7 +- .../server/chaotic_good_server.cc | 7 +- .../chaotic_good/server/chaotic_good_server.h | 4 +- .../transport/chttp2/server/chttp2_server.cc | 287 ++++++++++++------ .../transport/chttp2/server/chttp2_server.h | 33 ++ .../lib/event_engine/extensions/supports_fd.h | 7 + .../event_engine/posix_engine/posix_engine.cc | 18 +- .../event_engine/posix_engine/posix_engine.h | 2 + src/core/lib/surface/server.h | 14 +- src/cpp/server/server_builder.cc | 61 +++- .../event_engine/event_engine_test_utils.h | 65 ++++ test/cpp/server/BUILD | 1 + test/cpp/server/server_builder_test.cc | 55 ++++ .../distrib/check_namespace_qualification.py | 4 + .../check_redundant_namespace_qualifiers.py | 9 + tools/doxygen/Doxyfile.c++ | 2 + tools/doxygen/Doxyfile.c++.internal | 2 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 34 files changed, 615 insertions(+), 115 deletions(-) create mode 100644 include/grpc/passive_listener.h create mode 100644 include/grpcpp/passive_listener.h diff --git a/BUILD b/BUILD index 894186b35f2..7941edf3c42 100644 --- a/BUILD +++ b/BUILD @@ -291,6 +291,7 @@ GRPC_PUBLIC_HDRS = [ "include/grpc/grpc_posix.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", + "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", @@ -452,6 +453,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/impl/service_type.h", "include/grpcpp/impl/status.h", "include/grpcpp/impl/sync.h", + "include/grpcpp/passive_listener.h", "include/grpcpp/resource_quota.h", "include/grpcpp/security/audit_logging.h", "include/grpcpp/security/tls_crl_provider.h", @@ -876,7 +878,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_public_hdrs", - hdrs = GRPC_PUBLIC_HDRS, + hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, external_deps = [ "absl/status:statusor", "absl/strings", @@ -2470,6 +2472,7 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_crl_provider", "//src/core:grpc_service_config", + "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:json", "//src/core:json_reader", @@ -2527,6 +2530,7 @@ grpc_cc_library( "grpc_security_base", "grpc_service_config_impl", "grpc_trace", + "grpc_transport_chttp2", "grpc_unsecure", "grpcpp_backend_metric_recorder", "grpcpp_call_metric_recorder", @@ -2548,6 +2552,7 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_insecure_credentials", "//src/core:grpc_service_config", + "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:ref_counted", "//src/core:resource_quota", diff --git a/CMakeLists.txt b/CMakeLists.txt index 97c724e8b86..abc70d6ea8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2742,6 +2742,7 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h + include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -3444,6 +3445,7 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h + include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -4313,6 +4315,7 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h + include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5053,6 +5056,7 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h + include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5502,6 +5506,7 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h + include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -26670,6 +26675,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h + test/core/event_engine/event_engine_test_utils.cc test/core/util/cmdline.cc test/core/util/fuzzer_util.cc test/core/util/grpc_profiler.cc @@ -26714,6 +26720,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) target_link_libraries(server_builder_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc++_unsecure grpc_test_util_unsecure ) diff --git a/Makefile b/Makefile index 30be778e03d..5a7f90db9cc 100644 --- a/Makefile +++ b/Makefile @@ -1776,6 +1776,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ + include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/Package.swift b/Package.swift index ce9e5e1bed5..22f0e7cac9f 100644 --- a/Package.swift +++ b/Package.swift @@ -93,6 +93,7 @@ let package = Package( "include/grpc/impl/propagation_bits.h", "include/grpc/impl/slice_type.h", "include/grpc/load_reporting.h", + "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 2f2384c9abb..5bb103e8b40 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -197,6 +197,7 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h + - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -2185,6 +2186,7 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h + - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -3795,6 +3797,7 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h + - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4223,6 +4226,7 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h + - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4371,6 +4375,7 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h + - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -17391,6 +17396,7 @@ targets: build: test language: c++ headers: + - test/core/event_engine/event_engine_test_utils.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h - test/core/util/fuzzer_util.h @@ -17407,6 +17413,7 @@ targets: - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/simple_messages.proto - src/proto/grpc/testing/xds/v3/orca_load_report.proto + - test/core/event_engine/event_engine_test_utils.cc - test/core/util/cmdline.cc - test/core/util/fuzzer_util.cc - test/core/util/grpc_profiler.cc @@ -17419,6 +17426,7 @@ targets: - test/cpp/server/server_builder_test.cc deps: - gtest + - absl/log:check - grpc++_unsecure - grpc_test_util_unsecure platforms: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 9114af3c0d9..0ac465034a2 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -175,6 +175,7 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/service_type.h', 'include/grpcpp/impl/status.h', 'include/grpcpp/impl/sync.h', + 'include/grpcpp/passive_listener.h', 'include/grpcpp/resource_quota.h', 'include/grpcpp/security/audit_logging.h', 'include/grpcpp/security/auth_context.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1624bceaeb2..b711dd5bc02 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -167,6 +167,7 @@ Pod::Spec.new do |s| 'include/grpc/impl/propagation_bits.h', 'include/grpc/impl/slice_type.h', 'include/grpc/load_reporting.h', + 'include/grpc/passive_listener.h', 'include/grpc/slice.h', 'include/grpc/slice_buffer.h', 'include/grpc/status.h', diff --git a/grpc.gemspec b/grpc.gemspec index 3a986b6d65e..9283dd994ed 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -99,6 +99,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/propagation_bits.h ) s.files += %w( include/grpc/impl/slice_type.h ) s.files += %w( include/grpc/load_reporting.h ) + s.files += %w( include/grpc/passive_listener.h ) s.files += %w( include/grpc/slice.h ) s.files += %w( include/grpc/slice_buffer.h ) s.files += %w( include/grpc/status.h ) diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index c9219532826..30427e21d05 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -38,6 +38,7 @@ header "byte_buffer.h" header "impl/propagation_bits.h" header "impl/slice_type.h" header "load_reporting.h" + header "passive_listener.h" header "slice.h" header "slice_buffer.h" header "status.h" diff --git a/include/grpc/passive_listener.h b/include/grpc/passive_listener.h new file mode 100644 index 00000000000..91fea25cc6a --- /dev/null +++ b/include/grpc/passive_listener.h @@ -0,0 +1,62 @@ +// Copyright 2024 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef GRPC_PASSIVE_LISTENER_H +#define GRPC_PASSIVE_LISTENER_H + +#include + +#include +#include +#include + +namespace grpc_core { +class Server; + +namespace experimental { +class PassiveListenerImpl; + +/// -- EXPERIMENTAL API -- +/// Interface for used for Server Endpoint injection. +class PassiveListener { + public: + virtual ~PassiveListener() = default; + /// -- EXPERIMENTAL API -- + /// + /// Takes an Endpoint for an established connection, and treats it as if the + /// connection had been accepted by the server. + /// + /// The server must be started before endpoints can be accepted. + virtual absl::Status AcceptConnectedEndpoint( + std::unique_ptr + endpoint) = 0; + + /// -- EXPERIMENTAL API -- + /// + /// Takes a connected file descriptor, and treats it as if the server had + /// accepted the connection itself. + /// + /// Returns a failure status if the server's active EventEngine does not + /// support Endpoint creation from fds. + virtual absl::Status AcceptConnectedFd(int fd) = 0; +}; + +} // namespace experimental +} // namespace grpc_core + +absl::Status grpc_server_add_passive_listener( + grpc_core::Server* server, grpc_server_credentials* credentials, + std::shared_ptr + passive_listener); + +#endif /* GRPC_PASSIVE_LISTENER_H */ diff --git a/include/grpcpp/passive_listener.h b/include/grpcpp/passive_listener.h new file mode 100644 index 00000000000..8def9592b5e --- /dev/null +++ b/include/grpcpp/passive_listener.h @@ -0,0 +1,27 @@ +// Copyright 2024 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef GRPCPP_PASSIVE_LISTENER_H +#define GRPCPP_PASSIVE_LISTENER_H + +#include + +namespace grpc { +namespace experimental { + +using grpc_core::experimental::PassiveListener; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_PASSIVE_LISTENER_H diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index fe8c546190d..e3f5c2bbbfe 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -84,6 +84,7 @@ class ServerCredentials : private grpc::internal::GrpcLibrary { // Needed for access to AddPortToServer. friend class Server; // Needed for access to c_creds_. + friend class ServerBuilder; friend std::shared_ptr grpc::XdsServerCredentials( const std::shared_ptr& fallback_credentials); diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index e6266a90d98..eceaa5c6c73 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -25,13 +25,17 @@ #include #include +#include +#include #include #include #include #include #include #include +#include #include +#include #include #include #include @@ -58,6 +62,7 @@ class ExternalConnectionAcceptorImpl; class CallbackGenericService; namespace experimental { + // EXPERIMENTAL API: // Interface for a grpc server to build transports with connections created out // of band. @@ -291,6 +296,18 @@ class ServerBuilder { void EnableCallMetricRecording( experimental::ServerMetricRecorder* server_metric_recorder = nullptr); + // Creates a passive listener for Server Endpoint injection. + /// + /// \a PasiveListener lets applications provide pre-established connections + /// to gRPC Servers. The server will behave as if it accepted the connection + /// itself on its own listening addresses. + /// + /// This can be called multiple times to create passive listeners with + /// different server credentials. + ServerBuilder& AddPassiveListener( + std::shared_ptr creds, + std::unique_ptr& passive_listener); + private: ServerBuilder* builder_; }; @@ -364,6 +381,17 @@ class ServerBuilder { private: friend class grpc::testing::ServerBuilderPluginTest; + struct UnstartedPassiveListener { + std::weak_ptr + passive_listener; + std::shared_ptr credentials; + UnstartedPassiveListener( + std::weak_ptr listener, + std::shared_ptr creds) + : passive_listener(std::move(listener)), + credentials(std::move(creds)) {} + }; + struct SyncServerSettings { SyncServerSettings() : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} @@ -388,6 +416,7 @@ class ServerBuilder { std::vector> options_; std::vector> services_; std::vector ports_; + std::vector unstarted_passive_listeners_; SyncServerSettings sync_server_settings_; diff --git a/package.xml b/package.xml index 6a184f74d73..f90a7d2186d 100644 --- a/package.xml +++ b/package.xml @@ -81,6 +81,7 @@ + diff --git a/src/core/BUILD b/src/core/BUILD index 23040cc5fe8..14577b9f67e 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -6800,6 +6800,8 @@ grpc_cc_library( "connection_quota", "error", "error_utils", + "event_engine_extensions", + "event_engine_query_extensions", "grpc_insecure_credentials", "handshaker_registry", "iomgr_fwd", diff --git a/src/core/ext/transport/binder/server/binder_server.cc b/src/core/ext/transport/binder/server/binder_server.cc index 994d8f82cb8..58d26b6949c 100644 --- a/src/core/ext/transport/binder/server/binder_server.cc +++ b/src/core/ext/transport/binder/server/binder_server.cc @@ -159,7 +159,7 @@ class BinderServerListener : public Server::ListenerInterface { on_destroy_done_ = on_destroy_done; } - void Orphan() override { delete this; } + void Orphan() override { Unref(); } ~BinderServerListener() override { ExecCtx::Get()->Flush(); @@ -239,9 +239,8 @@ bool AddBinderPort(const std::string& addr, grpc_server* server, } std::string conn_id = addr.substr(kBinderUriScheme.size()); Server* core_server = Server::FromC(server); - core_server->AddListener( - OrphanablePtr(new BinderServerListener( - core_server, conn_id, std::move(factory), security_policy))); + core_server->AddListener(MakeOrphanable( + core_server, conn_id, std::move(factory), security_policy)); return true; } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index c1022e95c43..f3a9de5783c 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -102,8 +102,8 @@ absl::StatusOr ChaoticGoodServerListener::Bind( str.ok() ? str->c_str() : str.status().ToString().c_str()); } EventEngine::Listener::AcceptCallback accept_cb = - [self = Ref()](std::unique_ptr ep, - MemoryAllocator) { + [self = RefAsSubclass()]( + std::unique_ptr ep, MemoryAllocator) { ExecCtx exec_ctx; MutexLock lock(&self->mu_); if (self->shutdown_) return; @@ -148,7 +148,8 @@ absl::Status ChaoticGoodServerListener::StartListening() { ChaoticGoodServerListener::ActiveConnection::ActiveConnection( RefCountedPtr listener, std::unique_ptr endpoint) - : memory_allocator_(listener->memory_allocator_), listener_(listener) { + : memory_allocator_(listener->memory_allocator_), + listener_(std::move(listener)) { handshaking_state_ = MakeRefCounted(Ref()); handshaking_state_->Start(std::move(endpoint)); } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index ed90dd45d1d..a34fbee3f18 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -49,9 +49,7 @@ namespace grpc_core { namespace chaotic_good { -class ChaoticGoodServerListener final - : public Server::ListenerInterface, - public RefCounted { +class ChaoticGoodServerListener final : public Server::ListenerInterface { public: static absl::AnyInvocable DefaultConnectionIDGenerator() { return [bitgen = absl::BitGen()]() mutable { diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 2e97b207ed2..4496189cd6a 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,8 @@ #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" +#include "src/core/lib/event_engine/extensions/supports_fd.h" +#include "src/core/lib/event_engine/query_extensions.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -64,6 +67,7 @@ #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/event_engine_shims/endpoint.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -92,9 +96,11 @@ #endif // GPR_SUPPORT_CHANNELS_FROM_FD namespace grpc_core { -namespace { -using ::grpc_event_engine::experimental::EventEngine; +using grpc_event_engine::experimental::ChannelArgsEndpointConfig; +using grpc_event_engine::experimental::EventEngine; +using grpc_event_engine::experimental::EventEngineSupportsFdExtension; +using grpc_event_engine::experimental::QueryExtension; const char kUnixUriPrefix[] = "unix:"; const char kUnixAbstractUriPrefix[] = "unix-abstract:"; @@ -111,14 +117,23 @@ class Chttp2ServerListener : public Server::ListenerInterface { Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier); + static Chttp2ServerListener* CreateForPassiveListener( + Server* server, const ChannelArgs& args, + std::shared_ptr passive_listener); + // Do not instantiate directly. Use one of the factory methods above. Chttp2ServerListener(Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier); + Chttp2ServerArgsModifier args_modifier, + grpc_server_config_fetcher* config_fetcher, + std::shared_ptr + passive_listener = nullptr); ~Chttp2ServerListener() override; void Start(Server* server, const std::vector* pollsets) override; + void AcceptConnectedEndpoint(std::unique_ptr endpoint); + channelz::ListenSocketNode* channelz_listen_socket_node() const override { return channelz_listen_socket_.get(); } @@ -128,6 +143,8 @@ class Chttp2ServerListener : public Server::ListenerInterface { void Orphan() override; private: + friend class experimental::PassiveListenerImpl; + class ConfigFetcherWatcher : public grpc_server_config_fetcher::WatcherInterface { public: @@ -234,34 +251,8 @@ class Chttp2ServerListener : public Server::ListenerInterface { static void DestroyListener(Server* /*server*/, void* arg, grpc_closure* destroy_done); - // The interface required by RefCountedPtr<> has been manually implemented - // here to take a ref on tcp_server_ instead. Note that, the handshaker - // needs tcp_server_ to exist for the lifetime of the handshake since it's - // needed by acceptor. Sharing refs between the listener and tcp_server_ is - // just an optimization to avoid taking additional refs on the listener, - // since TcpServerShutdownComplete already holds a ref to the listener. - void IncrementRefCount() { grpc_tcp_server_ref(tcp_server_); } - void IncrementRefCount(const DebugLocation& /* location */, - const char* /* reason */) { - IncrementRefCount(); - } - - GRPC_MUST_USE_RESULT RefCountedPtr Ref() { - IncrementRefCount(); - return RefCountedPtr(this); - } - GRPC_MUST_USE_RESULT RefCountedPtr Ref( - const DebugLocation& /* location */, const char* /* reason */) { - return Ref(); - } - - void Unref() { grpc_tcp_server_unref(tcp_server_); } - void Unref(const DebugLocation& /* location */, const char* /* reason */) { - Unref(); - } - - Server* const server_; - grpc_tcp_server* tcp_server_; + Server* const server_ = nullptr; + grpc_tcp_server* tcp_server_ = nullptr; grpc_resolved_address resolved_address_; Chttp2ServerArgsModifier const args_modifier_; ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr; @@ -284,6 +275,10 @@ class Chttp2ServerListener : public Server::ListenerInterface { RefCountedPtr channelz_listen_socket_; MemoryQuotaRefPtr memory_quota_; ConnectionQuotaRefPtr connection_quota_; + grpc_server_config_fetcher* config_fetcher_ = nullptr; + // TODO(yashykt): consider using absl::variant<> to minimize memory usage for + // disjoint cases where different fields are used. + std::shared_ptr passive_listener_; }; // @@ -380,13 +375,17 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState( handshake_mgr_(MakeRefCounted()), deadline_(GetConnectionDeadline(args)), interested_parties_(grpc_pollset_set_create()) { - grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); + if (accepting_pollset != nullptr) { + grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); + } CoreConfiguration::Get().handshaker_registry().AddHandshakers( HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get()); } Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() { - grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); + if (accepting_pollset_ != nullptr) { + grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); + } grpc_pollset_set_destroy(interested_parties_); gpr_free(acceptor_); } @@ -708,83 +707,82 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() { grpc_error_handle Chttp2ServerListener::Create( Server* server, grpc_resolved_address* addr, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier, int* port_num) { - Chttp2ServerListener* listener = nullptr; - // The bulk of this method is inside of a lambda to make cleanup - // easier without using goto. - grpc_error_handle error = [&]() { - grpc_error_handle error; - // Create Chttp2ServerListener. - listener = new Chttp2ServerListener(server, args, args_modifier); - error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, - grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), - OnAccept, listener, &listener->tcp_server_); + // Create Chttp2ServerListener. + OrphanablePtr listener = + MakeOrphanable(server, args, args_modifier, + server->config_fetcher()); + // The tcp_server will be unreffed when the listener is orphaned, which could + // be at the end of this function if the listener was not added to the + // server's set of listeners. + grpc_error_handle error = grpc_tcp_server_create( + &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), + OnAccept, listener.get(), &listener->tcp_server_); + if (!error.ok()) return error; + if (listener->config_fetcher_ != nullptr) { + listener->resolved_address_ = *addr; + // TODO(yashykt): Consider binding so as to be able to return the port + // number. + } else { + error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); if (!error.ok()) return error; - if (server->config_fetcher() != nullptr) { - listener->resolved_address_ = *addr; - // TODO(yashykt): Consider binding so as to be able to return the port - // number. - } else { - error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); - if (!error.ok()) return error; - } - // Create channelz node. - if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) - .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { - auto string_address = grpc_sockaddr_to_uri(addr); - if (!string_address.ok()) { - return GRPC_ERROR_CREATE(string_address.status().ToString()); - } - listener->channelz_listen_socket_ = - MakeRefCounted( - *string_address, - absl::StrCat("chttp2 listener ", *string_address)); - } - // Register with the server only upon success - server->AddListener(OrphanablePtr(listener)); - return absl::OkStatus(); - }(); - if (!error.ok()) { - if (listener != nullptr) { - if (listener->tcp_server_ != nullptr) { - // listener is deleted when tcp_server_ is shutdown. - grpc_tcp_server_unref(listener->tcp_server_); - } else { - delete listener; - } + } + // Create channelz node. + if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) + .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { + auto string_address = grpc_sockaddr_to_uri(addr); + if (!string_address.ok()) { + return GRPC_ERROR_CREATE(string_address.status().ToString()); } + listener->channelz_listen_socket_ = + MakeRefCounted( + *string_address, absl::StrCat("chttp2 listener ", *string_address)); } - return error; + // Register with the server only upon success + server->AddListener(std::move(listener)); + return absl::OkStatus(); } grpc_error_handle Chttp2ServerListener::CreateWithAcceptor( Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier) { - Chttp2ServerListener* listener = - new Chttp2ServerListener(server, args, args_modifier); + auto listener = MakeOrphanable( + server, args, args_modifier, server->config_fetcher()); grpc_error_handle error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, - grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), - OnAccept, listener, &listener->tcp_server_); - if (!error.ok()) { - delete listener; - return error; - } + &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), + OnAccept, listener.get(), &listener->tcp_server_); + if (!error.ok()) return error; // TODO(yangg) channelz TcpServerFdHandler** arg_val = args.GetPointer(name); *arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_); - server->AddListener(OrphanablePtr(listener)); + server->AddListener(std::move(listener)); return absl::OkStatus(); } +Chttp2ServerListener* Chttp2ServerListener::CreateForPassiveListener( + Server* server, const ChannelArgs& args, + std::shared_ptr passive_listener) { + // TODO(hork): figure out how to handle channelz in this case + auto listener = MakeOrphanable( + server, args, /*args_modifier=*/ + [](const ChannelArgs& args, grpc_error_handle*) { return args; }, nullptr, + std::move(passive_listener)); + auto listener_ptr = listener.get(); + server->AddListener(std::move(listener)); + return listener_ptr; +} + Chttp2ServerListener::Chttp2ServerListener( Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier) + Chttp2ServerArgsModifier args_modifier, + grpc_server_config_fetcher* config_fetcher, + std::shared_ptr passive_listener) : server_(server), args_modifier_(args_modifier), args_(args), memory_quota_(args.GetObject()->memory_quota()), - connection_quota_(MakeRefCounted()) { + connection_quota_(MakeRefCounted()), + config_fetcher_(config_fetcher), + passive_listener_(std::move(passive_listener)) { auto max_allowed_incoming_connections = args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS); if (max_allowed_incoming_connections.has_value()) { @@ -799,6 +797,9 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Flush queued work before destroying handshaker factory, since that // may do a synchronous unref. ExecCtx::Get()->Flush(); + if (passive_listener_ != nullptr) { + passive_listener_->ListenerDestroyed(); + } if (on_destroy_done_ != nullptr) { ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus()); ExecCtx::Get()->Flush(); @@ -808,10 +809,11 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Server callback: start listening on our ports void Chttp2ServerListener::Start( Server* /*server*/, const std::vector* /* pollsets */) { - if (server_->config_fetcher() != nullptr) { - auto watcher = std::make_unique(Ref()); + if (config_fetcher_ != nullptr) { + auto watcher = std::make_unique( + RefAsSubclass()); config_fetcher_watcher_ = watcher.get(); - server_->config_fetcher()->StartWatch( + config_fetcher_->StartWatch( grpc_sockaddr_to_string(&resolved_address_, false).value(), std::move(watcher)); } else { @@ -825,7 +827,9 @@ void Chttp2ServerListener::Start( } void Chttp2ServerListener::StartListening() { - grpc_tcp_server_start(tcp_server_, &server_->pollsets()); + if (tcp_server_ != nullptr) { + grpc_tcp_server_start(tcp_server_, &server_->pollsets()); + } } void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { @@ -833,6 +837,12 @@ void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { on_destroy_done_ = on_destroy_done; } +void Chttp2ServerListener::AcceptConnectedEndpoint( + std::unique_ptr endpoint) { + OnAccept(this, grpc_event_engine_endpoint_create(std::move(endpoint)), + /*accepting_pollset=*/nullptr, /*acceptor=*/nullptr); +} + void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor) { @@ -857,7 +867,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, endpoint_cleanup(error); return; } - if (self->server_->config_fetcher() != nullptr) { + if (self->config_fetcher_ != nullptr) { if (connection_manager == nullptr) { grpc_error_handle error = GRPC_ERROR_CREATE( "No ConnectionManager configured. Closing connection."); @@ -898,7 +908,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, // heap-use-after-free issues where `Ref()` is invoked when the ref of // tcp_server_ has already reached 0. (Ref() implementation of // Chttp2ServerListener is grpc_tcp_server_ref().) - listener_ref = self->Ref(); + listener_ref = self->RefAsSubclass(); self->connections_.emplace(connection.get(), std::move(connection)); } } @@ -913,7 +923,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete( void* arg, grpc_error_handle /*error*/) { Chttp2ServerListener* self = static_cast(arg); self->channelz_listen_socket_.reset(); - delete self; + self->Unref(); } // Server callback: destroy the tcp listener (so we don't generate further @@ -922,7 +932,8 @@ void Chttp2ServerListener::Orphan() { // Cancel the watch before shutting down so as to avoid holding a ref to the // listener in the watcher. if (config_fetcher_watcher_ != nullptr) { - server_->config_fetcher()->CancelWatch(config_fetcher_watcher_); + GPR_ASSERT(config_fetcher_ != nullptr); + config_fetcher_->CancelWatch(config_fetcher_watcher_); } std::map> connections; grpc_tcp_server* tcp_server; @@ -940,12 +951,14 @@ void Chttp2ServerListener::Orphan() { } tcp_server = tcp_server_; } - grpc_tcp_server_shutdown_listeners(tcp_server); - grpc_tcp_server_unref(tcp_server); + if (tcp_server != nullptr) { + grpc_tcp_server_shutdown_listeners(tcp_server); + grpc_tcp_server_unref(tcp_server); + } else { + Unref(); + } } -} // namespace - // // Chttp2ServerAddPort() // @@ -1046,6 +1059,50 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args, } } // namespace + +namespace experimental { + +absl::Status PassiveListenerImpl::AcceptConnectedEndpoint( + std::unique_ptr endpoint) { + GPR_ASSERT(server_ != nullptr); + RefCountedPtr listener; + { + MutexLock lock(&mu_); + if (listener_ != nullptr) { + listener = + listener_->RefIfNonZero().TakeAsSubclass(); + } + } + if (listener == nullptr) { + return absl::UnavailableError("passive listener already shut down"); + } + ExecCtx exec_ctx; + listener->AcceptConnectedEndpoint(std::move(endpoint)); + return absl::OkStatus(); +} + +absl::Status PassiveListenerImpl::AcceptConnectedFd(int fd) { + GPR_ASSERT(server_ != nullptr); + ExecCtx exec_ctx; + auto& args = server_->channel_args(); + auto* supports_fd = QueryExtension( + /*engine=*/args.GetObjectRef().get()); + if (supports_fd == nullptr) { + return absl::UnimplementedError( + "The server's EventEngine does not support adding endpoints from " + "connected file descriptors."); + } + auto endpoint = + supports_fd->CreateEndpointFromFd(fd, ChannelArgsEndpointConfig(args)); + return AcceptConnectedEndpoint(std::move(endpoint)); +} + +void PassiveListenerImpl::ListenerDestroyed() { + MutexLock lock(&mu_); + listener_ = nullptr; +} + +} // namespace experimental } // namespace grpc_core int grpc_server_add_http2_port(grpc_server* server, const char* addr, @@ -1143,3 +1200,31 @@ void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */, } #endif // GPR_SUPPORT_CHANNELS_FROM_FD + +absl::Status grpc_server_add_passive_listener( + grpc_core::Server* server, grpc_server_credentials* credentials, + std::shared_ptr + passive_listener) { + grpc_core::ExecCtx exec_ctx; + GRPC_API_TRACE("grpc_server_add_passive_listener(server=%p, credentials=%p)", + 2, (server, credentials)); + // Create security context. + if (credentials == nullptr) { + return absl::UnavailableError( + "No credentials specified for passive listener"); + } + auto sc = credentials->create_security_connector(grpc_core::ChannelArgs()); + if (sc == nullptr) { + return absl::UnavailableError( + absl::StrCat("Unable to create secure server with credentials of type ", + credentials->type().name())); + } + auto args = server->channel_args() + .SetObject(credentials->Ref()) + .SetObject(std::move(sc)); + passive_listener->listener_ = + grpc_core::Chttp2ServerListener::CreateForPassiveListener( + server, args, passive_listener); + passive_listener->server_ = server->Ref(); + return absl::OkStatus(); +} diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index f7eb7a23c66..0e296873b3d 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -21,6 +21,7 @@ #include +#include #include #include "src/core/lib/channel/channel_args.h" @@ -42,6 +43,38 @@ grpc_error_handle Chttp2ServerAddPort( Server* server, const char* addr, const ChannelArgs& args, Chttp2ServerArgsModifier connection_args_modifier, int* port_num); +class Chttp2ServerListener; +namespace experimental { + +// An implementation of the public C++ passive listener interface. +// The server builder holds a weak_ptr to one of these objects, and the +// application owns the instance. +class PassiveListenerImpl final : public PassiveListener { + public: + absl::Status AcceptConnectedEndpoint( + std::unique_ptr + endpoint) override ABSL_LOCKS_EXCLUDED(mu_); + + absl::Status AcceptConnectedFd(GRPC_UNUSED int fd) override + ABSL_LOCKS_EXCLUDED(mu_); + + void ListenerDestroyed() ABSL_LOCKS_EXCLUDED(mu_); + + private: + // note: the grpc_core::Server redundant namespace qualification is + // required for older gcc versions. + friend absl::Status(::grpc_server_add_passive_listener)( + grpc_core::Server* server, grpc_server_credentials* credentials, + std::shared_ptr + passive_listener); + + Mutex mu_; + // Data members will be populated when initialized. + RefCountedPtr server_; + Chttp2ServerListener* listener_; +}; + +} // namespace experimental } // namespace grpc_core #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H diff --git a/src/core/lib/event_engine/extensions/supports_fd.h b/src/core/lib/event_engine/extensions/supports_fd.h index 66ea1c2b345..30f0d2ad0e6 100644 --- a/src/core/lib/event_engine/extensions/supports_fd.h +++ b/src/core/lib/event_engine/extensions/supports_fd.h @@ -112,6 +112,13 @@ class EventEngineSupportsFdExtension { int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) = 0; + /// Creates an EventEngine::Endpoint from an fd which is already assumed to be + /// connected to a remote peer. See \a CreatePosixEndpointFromFd for details. + /// This has the same behavior, but the \a memory_allocator is taken from the + /// EndpointConfig's resource quota. + virtual std::unique_ptr CreateEndpointFromFd( + int fd, const EndpointConfig& config) = 0; + /// Called when the posix listener has accepted a new client connection. /// \a listener_fd - The listening socket fd that accepted the new client /// connection. diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc index 275e0dcbf65..0ac3dfcebfe 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -661,7 +661,7 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) { #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING - GPR_DEBUG_ASSERT(fd > 0); + GPR_ASSERT(fd > 0); PosixEventPoller* poller = poller_manager_->Poller(); GPR_DEBUG_ASSERT(poller != nullptr); EventHandle* handle = @@ -676,6 +676,22 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING } +std::unique_ptr PosixEventEngine::CreateEndpointFromFd( + int fd, const EndpointConfig& config) { + auto options = TcpOptionsFromEndpointConfig(config); + MemoryAllocator allocator; + if (options.memory_allocator_factory != nullptr) { + return CreatePosixEndpointFromFd( + fd, config, + options.memory_allocator_factory->CreateMemoryAllocator( + absl::StrCat("allocator:", fd))); + } + return CreatePosixEndpointFromFd( + fd, config, + options.resource_quota->memory_quota()->CreateMemoryAllocator( + absl::StrCat("allocator:", fd))); +} + absl::StatusOr> PosixEventEngine::CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.h b/src/core/lib/event_engine/posix_engine/posix_engine.h index 257cd6b34b5..ea426c379c9 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -172,6 +172,8 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, std::unique_ptr CreatePosixEndpointFromFd( int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) override; + std::unique_ptr CreateEndpointFromFd( + int fd, const EndpointConfig& config) override; absl::StatusOr> CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 356bcc40269..66f7b6683e0 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -39,6 +39,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include @@ -74,6 +75,9 @@ "grpc.server.max_pending_requests_hard_limit" namespace grpc_core { +namespace experimental { +class PassiveListenerImpl; +} // namespace experimental extern TraceFlag grpc_server_channel_trace; @@ -112,7 +116,7 @@ class Server : public ServerInterface, /// Interface for listeners. /// Implementations must override the Orphan() method, which should stop /// listening and initiate destruction of the listener. - class ListenerInterface : public Orphanable { + class ListenerInterface : public InternallyRefCounted { public: ~ListenerInterface() override = default; @@ -212,6 +216,14 @@ class Server : public ServerInterface, void SendGoaways() ABSL_LOCKS_EXCLUDED(mu_global_, mu_call_); private: + // note: the grpc_core::Server redundant namespace qualification is + // required for older gcc versions. + // TODO(yashykt): eliminate this friend statement as part of your upcoming + // server listener refactoring. + friend absl::Status(::grpc_server_add_passive_listener)( + grpc_core::Server* server, grpc_server_credentials* credentials, + std::shared_ptr + passive_listener); struct RequestedCall; class RequestMatcherInterface; diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 6d5924404f4..d79f3df4d1f 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -15,7 +15,6 @@ // limitations under the License. // // - #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -45,11 +45,38 @@ #include #include +#include "src/core/ext/transport/chttp2/server/chttp2_server.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/surface/server.h" #include "src/cpp/server/external_connection_acceptor_impl.h" namespace grpc { +namespace { + +// A PIMPL wrapper class that owns the only ref to the passive listener +// implementation. This is returned to the application. +class PassiveListenerOwner final + : public grpc_core::experimental::PassiveListener { + public: + explicit PassiveListenerOwner(std::shared_ptr listener) + : listener_(std::move(listener)) {} + + absl::Status AcceptConnectedEndpoint( + std::unique_ptr + endpoint) override { + return listener_->AcceptConnectedEndpoint(std::move(endpoint)); + } + + absl::Status AcceptConnectedFd(int fd) override { + return listener_->AcceptConnectedFd(fd); + } + + private: + std::shared_ptr listener_; +}; + +} // namespace static std::vector (*)()>* g_plugin_factory_list; @@ -223,6 +250,18 @@ ServerBuilder& ServerBuilder::SetResourceQuota( return *this; } +ServerBuilder& ServerBuilder::experimental_type::AddPassiveListener( + std::shared_ptr creds, + std::unique_ptr& passive_listener) { + auto core_passive_listener = + std::make_shared(); + builder_->unstarted_passive_listeners_.emplace_back(core_passive_listener, + std::move(creds)); + passive_listener = + std::make_unique(std::move(core_passive_listener)); + return *builder_; +} + ServerBuilder& ServerBuilder::AddListeningPort( const std::string& addr_uri, std::shared_ptr creds, int* selected_port) { @@ -396,6 +435,26 @@ std::unique_ptr ServerBuilder::BuildAndStart() { cq->RegisterServer(server.get()); } + for (auto& unstarted_listener : unstarted_passive_listeners_) { + has_frequently_polled_cqs = true; + auto passive_listener = unstarted_listener.passive_listener.lock(); + auto* core_server = grpc_core::Server::FromC(server->c_server()); + if (passive_listener != nullptr) { + auto* creds = unstarted_listener.credentials->c_creds(); + if (creds == nullptr) { + gpr_log(GPR_ERROR, "Credentials missing for PassiveListener"); + return nullptr; + } + auto success = grpc_server_add_passive_listener( + core_server, creds, std::move(passive_listener)); + if (!success.ok()) { + gpr_log(GPR_ERROR, "Failed to create a passive listener: %s", + success.ToString().c_str()); + return nullptr; + } + } + } + if (!has_frequently_polled_cqs) { gpr_log(GPR_ERROR, "At least one of the completion queues must be frequently polled"); diff --git a/test/core/event_engine/event_engine_test_utils.h b/test/core/event_engine/event_engine_test_utils.h index 67bbe42d35d..debef7a0449 100644 --- a/test/core/event_engine/event_engine_test_utils.h +++ b/test/core/event_engine/event_engine_test_utils.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -159,6 +160,70 @@ class NotifyOnDelete { grpc_core::Notification* signal_; }; +// An endpoint implementation that supports Read and Write via std::threads. +// Passing a grpc_core::Notification will allow owners to know when all +// in-flight callbacks have been run, and all endpoint state has been destroyed. +class ThreadedNoopEndpoint : public EventEngine::Endpoint { + public: + explicit ThreadedNoopEndpoint(grpc_core::Notification* destroyed) + : state_(std::make_shared(destroyed)) {} + ~ThreadedNoopEndpoint() override { + std::thread deleter([state = state_]() { + CleanupThread(state->read); + CleanupThread(state->write); + }); + deleter.detach(); + } + + bool Read(absl::AnyInvocable on_read, SliceBuffer* buffer, + const ReadArgs* /* args */) override { + buffer->Clear(); + CleanupThread(state_->read); + state_->read = new std::thread([cb = std::move(on_read)]() mutable { + cb(absl::UnknownError("test")); + }); + return false; + } + + bool Write(absl::AnyInvocable on_writable, + SliceBuffer* data, const WriteArgs* /* args */) override { + data->Clear(); + CleanupThread(state_->write); + state_->write = new std::thread([cb = std::move(on_writable)]() mutable { + cb(absl::UnknownError("test")); + }); + return false; + } + + const EventEngine::ResolvedAddress& GetPeerAddress() const override { + return peer_; + } + + const EventEngine::ResolvedAddress& GetLocalAddress() const override { + return local_; + } + + private: + struct EndpointState { + explicit EndpointState(grpc_core::Notification* deleter) + : delete_notifier_(deleter) {} + std::thread* read = nullptr; + std::thread* write = nullptr; + NotifyOnDelete delete_notifier_; + }; + + static void CleanupThread(std::thread* thd) { + if (thd != nullptr) { + thd->join(); + delete thd; + } + } + + std::shared_ptr state_; + EventEngine::ResolvedAddress peer_; + EventEngine::ResolvedAddress local_; +}; + } // namespace experimental } // namespace grpc_event_engine diff --git a/test/cpp/server/BUILD b/test/cpp/server/BUILD index 0927de6c7a0..063e6cf2a4c 100644 --- a/test/cpp/server/BUILD +++ b/test/cpp/server/BUILD @@ -28,6 +28,7 @@ grpc_cc_test( deps = [ "//:grpc++_unsecure", "//src/proto/grpc/testing:echo_proto", + "//test/core/event_engine:event_engine_test_utils", "//test/core/util:grpc_test_util_base", "//test/core/util:grpc_test_util_unsecure", ], diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc index 14eaa5efb7d..476eb41686c 100644 --- a/test/cpp/server/server_builder_test.cc +++ b/test/cpp/server/server_builder_test.cc @@ -16,14 +16,19 @@ // // +#include + #include +#include #include #include #include #include +#include "src/core/lib/gprpp/notification.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/event_engine/event_engine_test_utils.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -83,6 +88,56 @@ TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { nullptr); } +TEST_F(ServerBuilderTest, AddPassiveListener) { + std::unique_ptr passive_listener; + auto server = + ServerBuilder() + .experimental() + .AddPassiveListener(InsecureServerCredentials(), passive_listener) + .BuildAndStart(); + server->Shutdown(); +} + +TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedFd) { + std::unique_ptr passive_listener; + ServerBuilder builder; + auto cq = builder.AddCompletionQueue(); + // TODO(hork): why is the service necessary? Queue isn't drained otherwise. + auto server = + builder.RegisterService(&g_service) + .experimental() + .AddPassiveListener(InsecureServerCredentials(), passive_listener) + .BuildAndStart(); + ASSERT_NE(server.get(), nullptr); +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + int fd = socket(AF_INET, SOCK_STREAM, 0); + auto accept_status = passive_listener->AcceptConnectedFd(fd); + ASSERT_TRUE(accept_status.ok()) << accept_status; +#else + int fd = -1; + auto accept_status = passive_listener->AcceptConnectedFd(fd); + ASSERT_FALSE(accept_status.ok()) << accept_status; +#endif + server->Shutdown(); +} + +TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) { + std::unique_ptr passive_listener; + auto server = + ServerBuilder() + .experimental() + .AddPassiveListener(InsecureServerCredentials(), passive_listener) + .BuildAndStart(); + grpc_core::Notification endpoint_destroyed; + auto success = passive_listener->AcceptConnectedEndpoint( + std::make_unique( + &endpoint_destroyed)); + ASSERT_TRUE(success.ok()) + << "AcceptConnectedEndpoint failure: " << success.ToString(); + endpoint_destroyed.WaitForNotification(); + server->Shutdown(); +} + } // namespace } // namespace grpc diff --git a/tools/distrib/check_namespace_qualification.py b/tools/distrib/check_namespace_qualification.py index 6634d8b8830..bf13f0cd729 100755 --- a/tools/distrib/check_namespace_qualification.py +++ b/tools/distrib/check_namespace_qualification.py @@ -77,6 +77,10 @@ IGNORED_FILES = [ "src/core/lib/gprpp/global_config_env.h", "src/core/lib/profiling/timers.h", "src/core/lib/gprpp/crash.h", + # The grpc_core::Server redundant namespace qualification is required for + # older gcc versions. + "src/core/ext/transport/chttp2/server/chttp2_server.h", + "src/core/lib/surface/server.h", ] # find our home diff --git a/tools/distrib/check_redundant_namespace_qualifiers.py b/tools/distrib/check_redundant_namespace_qualifiers.py index 0322332209b..db89796db6f 100755 --- a/tools/distrib/check_redundant_namespace_qualifiers.py +++ b/tools/distrib/check_redundant_namespace_qualifiers.py @@ -21,6 +21,13 @@ import os import re import sys +IGNORED_FILES = [ + # note: the grpc_core::Server redundant namespace qualification is required + # for older gcc versions. + "src/core/ext/transport/chttp2/server/chttp2_server.h", + "src/core/lib/surface/server.h", +] + def find_closing_mustache(contents, initial_depth): """Find the closing mustache for a given number of open mustaches.""" @@ -166,6 +173,8 @@ for config in _CONFIGURATION: for file in files: if file.endswith(".cc") or file.endswith(".h"): path = os.path.join(root, file) + if path in IGNORED_FILES: + continue try: with open(path) as f: contents = f.read() diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 6e0f4316174..c630913e944 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -928,6 +928,7 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ +include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1040,6 +1041,7 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ +include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 45745a6b3c8..b2b6d5cf0f8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -928,6 +928,7 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ +include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1040,6 +1041,7 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ +include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 224d9f2d10b..42c1ae40ce8 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -861,6 +861,7 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ +include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 73cb5cdb1c6..e9a74dd745e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -861,6 +861,7 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ +include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ From 2fcc5f22b4b7f70b45873ac2e57404c2fa5ae55f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 17 Apr 2024 18:58:17 -0700 Subject: [PATCH 20/45] [clang-format] Remove requirement that port_platform.h is at the top (#36294) Closes #36294 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36294 from ctiller:port_platform-src-core-resolver-clang-format 6418ff82bf7416fcb26d250754de38ac144d6d2c PiperOrigin-RevId: 625877317 --- src/core/resolver/.clang-format | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/resolver/.clang-format b/src/core/resolver/.clang-format index 64387e9e515..5f150ef6edb 100644 --- a/src/core/resolver/.clang-format +++ b/src/core/resolver/.clang-format @@ -5,9 +5,6 @@ DerivePointerAlignment: false PointerAlignment: Left IncludeBlocks: Regroup IncludeCategories: - # port_platform.h is before almost everything - - Regex: '^' - Priority: -100 # ruby.h is even more first if it's included - Regex: '^' Priority: -200 From 5898d310221bff35567bf1964720731da53ab8f8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 17 Apr 2024 19:05:19 -0700 Subject: [PATCH 21/45] [gcc7] fix for compilation error (#36390) Closes #36390 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36390 from ctiller:7-ish e5e04f6f0860f75dca0298e18f0034d51ebdb31b PiperOrigin-RevId: 625878832 --- test/core/transport/test_suite/test.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/core/transport/test_suite/test.h b/test/core/transport/test_suite/test.h index f0451a4488d..5b0862a2744 100644 --- a/test/core/transport/test_suite/test.h +++ b/test/core/transport/test_suite/test.h @@ -130,9 +130,9 @@ PromiseSpawner SpawnerForContext( template using NextSpawner = absl::AnyInvocable; -template +template Promise WrapPromiseAndNext(std::shared_ptr action_state, - Promise promise, NextSpawner next) { + P promise, NextSpawner next) { return Promise(OnCancel( [action_state, promise = std::move(promise), next = std::move(next)]() mutable -> Poll { @@ -172,8 +172,7 @@ NextSpawner WrapFollowUps(NameAndLocation loc, action_state->Set(ActionState::kNotStarted); spawner(name, WrapPromiseAndNext(std::move(action_state), - Promise(factory.Make(std::move(arg))), - std::move(next))); + factory.Make(std::move(arg)), std::move(next))); }; } @@ -191,9 +190,9 @@ void StartSeq(NameAndLocation loc, ActionStateFactory action_state_factory, [spawner, first = Factory(std::move(first)), next = std::move(next), action_state = std::move(action_state), name = loc.name()]() mutable { action_state->Set(ActionState::kNotStarted); + auto promise = first.Make(); spawner(name, WrapPromiseAndNext(std::move(action_state), - Promise(first.Make()), - std::move(next))); + std::move(promise), std::move(next))); return Empty{}; }); } From d51155be8f6c07fd52c9033f367b052920c1bfa3 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Thu, 18 Apr 2024 02:31:06 -0700 Subject: [PATCH 22/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36366) Closes #36366 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36366 from tanvi-jagtap:tjagtap_test_01 a74c57ea7e54e37b82ff4d5656014453e0fd84c4 PiperOrigin-RevId: 625963461 --- CMakeLists.txt | 1 + build_autogenerated.yaml | 1 + test/core/security/BUILD | 5 +- test/core/security/credentials_test.cc | 822 +++++++++++++------------ 4 files changed, 421 insertions(+), 408 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abc70d6ea8d..131121baa1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30001,6 +30001,7 @@ target_include_directories(test_core_security_credentials_test target_link_libraries(test_core_security_credentials_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 5bb103e8b40..0a699c30309 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -19045,6 +19045,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: test_core_security_ssl_credentials_test gtest: true diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 2899bc9f523..58c2c6d63f5 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -95,7 +95,10 @@ grpc_cc_test( grpc_cc_test( name = "credentials_test", srcs = ["credentials_test.cc"], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 5ee501d431c..70d8077282c 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -26,6 +26,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -323,12 +324,11 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingOk) { absl::optional token_value; Duration token_lifetime; grpc_http_response response = http_response(200, valid_oauth2_json_response); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_OK); - GPR_ASSERT(token_lifetime == Duration::Seconds(3599)); - GPR_ASSERT(token_value->as_string_view() == - "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == GRPC_CREDENTIALS_OK); + CHECK(token_lifetime == Duration::Seconds(3599)); + CHECK(token_value->as_string_view() == + "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"); grpc_http_response_destroy(&response); } @@ -337,9 +337,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingBadHttpStatus) { absl::optional token_value; Duration token_lifetime; grpc_http_response response = http_response(401, valid_oauth2_json_response); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -348,9 +348,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingEmptyHttpBody) { absl::optional token_value; Duration token_lifetime; grpc_http_response response = http_response(200, ""); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -363,9 +363,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingInvalidJson) { "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," " \"expires_in\":3599, " " \"token_type\":\"Bearer\""); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -377,9 +377,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingMissingToken) { "{" " \"expires_in\":3599, " " \"token_type\":\"Bearer\"}"); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -392,9 +392,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingMissingTokenType) { "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," " \"expires_in\":3599, " "}"); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -406,9 +406,9 @@ TEST(CredentialsTest, TestOauth2TokenFetcherCredsParsingMissingTokenLifetime) { http_response(200, "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," " \"token_type\":\"Bearer\"}"); - GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( - &response, &token_value, &token_lifetime) == - GRPC_CREDENTIALS_ERROR); + CHECK(grpc_oauth2_token_fetcher_credentials_parse_server_response( + &response, &token_value, &token_lifetime) == + GRPC_CREDENTIALS_ERROR); grpc_http_response_destroy(&response); } @@ -447,7 +447,7 @@ class RequestMetadataState : public RefCounted { &get_request_metadata_args_), [this](absl::StatusOr metadata) { if (metadata.ok()) { - GPR_ASSERT(metadata->get() == &md_); + CHECK(metadata->get() == &md_); } return metadata.status(); }); @@ -498,15 +498,15 @@ class RequestMetadataState : public RefCounted { StatusToString(expected_error_).c_str()); gpr_log(GPR_INFO, "actual_error: %s", StatusToString(error).c_str()); if (expected_error_.ok()) { - GPR_ASSERT(error.ok()); + CHECK_OK(error); } else { std::string expected_error; - GPR_ASSERT(grpc_error_get_str( - expected_error_, StatusStrProperty::kDescription, &expected_error)); + CHECK(grpc_error_get_str(expected_error_, StatusStrProperty::kDescription, + &expected_error)); std::string actual_error; - GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription, - &actual_error)); - GPR_ASSERT(expected_error == actual_error); + CHECK(grpc_error_get_str(error, StatusStrProperty::kDescription, + &actual_error)); + CHECK(expected_error == actual_error); } md_.Remove(HttpAuthorityMetadata()); md_.Remove(HttpPathMetadata()); @@ -537,7 +537,7 @@ TEST(CredentialsTest, TestGoogleIamCreds) { test_google_iam_authorization_token, test_google_iam_authority_selector, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); creds->Unref(); @@ -549,9 +549,9 @@ TEST(CredentialsTest, TestAccessTokenCreds) { "authorization: Bearer blah"); grpc_call_credentials* creds = grpc_access_token_credentials_create("blah", nullptr); - GPR_ASSERT(creds->type() == grpc_access_token_credentials::Type()); + CHECK(creds->type() == grpc_access_token_credentials::Type()); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); creds->Unref(); @@ -562,9 +562,9 @@ class check_channel_oauth2 final : public grpc_channel_credentials { RefCountedPtr create_security_connector( RefCountedPtr call_creds, const char* /*target*/, ChannelArgs* /*new_args*/) override { - GPR_ASSERT(type() == Type()); - GPR_ASSERT(call_creds != nullptr); - GPR_ASSERT(call_creds->type() == grpc_access_token_credentials::Type()); + CHECK(type() == Type()); + CHECK(call_creds != nullptr); + CHECK(call_creds->type() == grpc_access_token_credentials::Type()); return nullptr; } @@ -612,7 +612,7 @@ TEST(CredentialsTest, TestOauth2GoogleIamCompositeCreds) { "authorization", test_oauth2_bearer_token); // Check security level of fake credentials. - GPR_ASSERT(oauth2_creds->min_security_level() == GRPC_SECURITY_NONE); + CHECK_EQ(oauth2_creds->min_security_level(), GRPC_SECURITY_NONE); grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, @@ -621,19 +621,17 @@ TEST(CredentialsTest, TestOauth2GoogleIamCompositeCreds) { grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds, nullptr); // Check security level of composite credentials. - GPR_ASSERT(composite_creds->min_security_level() == - GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(composite_creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); oauth2_creds->Unref(); google_iam_creds->Unref(); - GPR_ASSERT(composite_creds->type() == - grpc_composite_call_credentials::Type()); + CHECK(composite_creds->type() == grpc_composite_call_credentials::Type()); const grpc_composite_call_credentials::CallCredentialsList& creds_list = static_cast(composite_creds) ->inner(); - GPR_ASSERT(creds_list.size() == 2); - GPR_ASSERT(creds_list[0]->type() == grpc_md_only_test_credentials::Type()); - GPR_ASSERT(creds_list[1]->type() == grpc_google_iam_credentials::Type()); + CHECK_EQ(creds_list.size(), 2); + CHECK(creds_list[0]->type() == grpc_md_only_test_credentials::Type()); + CHECK(creds_list[1]->type() == grpc_google_iam_credentials::Type()); state->RunRequestMetadataTest(composite_creds, kTestUrlScheme, kTestAuthority, kTestPath); composite_creds->Unref(); @@ -644,14 +642,14 @@ class check_channel_oauth2_google_iam final : public grpc_channel_credentials { RefCountedPtr create_security_connector( RefCountedPtr call_creds, const char* /*target*/, ChannelArgs* /*new_args*/) override { - GPR_ASSERT(type() == Type()); - GPR_ASSERT(call_creds != nullptr); - GPR_ASSERT(call_creds->type() == grpc_composite_call_credentials::Type()); + CHECK(type() == Type()); + CHECK(call_creds != nullptr); + CHECK(call_creds->type() == grpc_composite_call_credentials::Type()); const grpc_composite_call_credentials::CallCredentialsList& creds_list = static_cast(call_creds.get()) ->inner(); - GPR_ASSERT(creds_list[0]->type() == grpc_access_token_credentials::Type()); - GPR_ASSERT(creds_list[1]->type() == grpc_google_iam_credentials::Type()); + CHECK(creds_list[0]->type() == grpc_access_token_credentials::Type()); + CHECK(creds_list[1]->type() == grpc_google_iam_credentials::Type()); return nullptr; } @@ -700,14 +698,14 @@ TEST(CredentialsTest, TestChannelOauth2GoogleIamCompositeCreds) { void validate_compute_engine_http_request(const grpc_http_request* request, const char* host, const char* path) { - GPR_ASSERT(strcmp(host, "metadata.google.internal.") == 0); - GPR_ASSERT( + CHECK_EQ(strcmp(host, "metadata.google.internal."), 0); + CHECK_EQ( strcmp(path, - "/computeMetadata/v1/instance/service-accounts/default/token") == + "/computeMetadata/v1/instance/service-accounts/default/token"), 0); - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Metadata-Flavor") == 0); - GPR_ASSERT(strcmp(request->hdrs[0].value, "Google") == 0); + CHECK_EQ(request->hdr_count, 1); + CHECK_EQ(strcmp(request->hdrs[0].key, "Metadata-Flavor"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "Google"), 0); } int compute_engine_httpcli_get_success_override( @@ -735,7 +733,7 @@ int httpcli_post_should_not_be_called( const char* /*path*/, const char* /*body_bytes*/, size_t /*body_size*/, Timestamp /*deadline*/, grpc_closure* /*on_done*/, grpc_http_response* /*response*/) { - GPR_ASSERT("HTTP POST should not be called" == nullptr); + CHECK(false) << "HTTP POST should not be called"; return 1; } @@ -744,7 +742,7 @@ int httpcli_get_should_not_be_called(const grpc_http_request* /*request*/, Timestamp /*deadline*/, grpc_closure* /*on_done*/, grpc_http_response* /*response*/) { - GPR_ASSERT("HTTP GET should not be called" == nullptr); + CHECK(false) << "HTTP GET should not be called"; return 1; } @@ -755,7 +753,7 @@ int httpcli_put_should_not_be_called(const grpc_http_request* /*request*/, Timestamp /*deadline*/, grpc_closure* /*on_done*/, grpc_http_response* /*response*/) { - GPR_ASSERT("HTTP PUT should not be called" == nullptr); + CHECK(false) << "HTTP PUT should not be called"; return 1; } @@ -768,7 +766,7 @@ TEST(CredentialsTest, TestComputeEngineCredsSuccess) { grpc_call_credentials* creds = grpc_google_compute_engine_credentials_create(nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http get should be called. auto state = RequestMetadataState::NewInstance(absl::OkStatus(), emd); @@ -788,8 +786,8 @@ TEST(CredentialsTest, TestComputeEngineCredsSuccess) { kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); } @@ -808,8 +806,8 @@ TEST(CredentialsTest, TestComputeEngineCredsFailure) { httpcli_put_should_not_be_called); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); } @@ -818,20 +816,20 @@ void validate_refresh_token_http_request(const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size) { // The content of the assertion is tested extensively in json_token_test. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); std::string expected_body = absl::StrFormat( GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, "32555999999.apps.googleusercontent.com", "EmssLNjJy1332hD4KFsecret", "1/Blahblasj424jladJDSGNf-u4Sua3HDA2ngjd42"); - GPR_ASSERT(expected_body.size() == body_size); - GPR_ASSERT(memcmp(expected_body.data(), body, body_size) == 0); - GPR_ASSERT(strcmp(host, GRPC_GOOGLE_OAUTH2_SERVICE_HOST) == 0); - GPR_ASSERT(strcmp(path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH) == 0); - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); + CHECK_EQ(expected_body.size(), body_size); + CHECK_EQ(memcmp(expected_body.data(), body, body_size), 0); + CHECK_EQ(strcmp(host, GRPC_GOOGLE_OAUTH2_SERVICE_HOST), 0); + CHECK_EQ(strcmp(path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH), 0); + CHECK_EQ(request->hdr_count, 1); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); } int refresh_token_httpcli_post_success(const grpc_http_request* request, @@ -866,7 +864,7 @@ TEST(CredentialsTest, TestRefreshTokenCredsSuccess) { test_refresh_token_str, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance(absl::OkStatus(), emd); @@ -885,8 +883,8 @@ TEST(CredentialsTest, TestRefreshTokenCredsSuccess) { state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -906,8 +904,8 @@ TEST(CredentialsTest, TestRefreshTokenCredsFailure) { httpcli_put_should_not_be_called); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -926,12 +924,12 @@ TEST(CredentialsTest, TestValidStsCredsOptions) { nullptr // actor_token_type }; absl::StatusOr sts_url = ValidateStsCredentialsOptions(&valid_options); - GPR_ASSERT(sts_url.ok()); + CHECK_OK(sts_url); absl::string_view host; absl::string_view port; - GPR_ASSERT(SplitHostPort(sts_url->authority(), &host, &port)); - GPR_ASSERT(host == "foo.com"); - GPR_ASSERT(port == "5555"); + CHECK(SplitHostPort(sts_url->authority(), &host, &port)); + CHECK(host == "foo.com"); + CHECK(port == "5555"); } TEST(CredentialsTest, TestInvalidStsCredsOptions) { @@ -948,7 +946,7 @@ TEST(CredentialsTest, TestInvalidStsCredsOptions) { }; absl::StatusOr url_should_be_invalid = ValidateStsCredentialsOptions(&invalid_options); - GPR_ASSERT(!url_should_be_invalid.ok()); + CHECK(!url_should_be_invalid.ok()); invalid_options = { test_sts_endpoint_url, // sts_endpoint_url @@ -962,7 +960,7 @@ TEST(CredentialsTest, TestInvalidStsCredsOptions) { nullptr // actor_token_type }; url_should_be_invalid = ValidateStsCredentialsOptions(&invalid_options); - GPR_ASSERT(!url_should_be_invalid.ok()); + CHECK(!url_should_be_invalid.ok()); invalid_options = { nullptr, // sts_endpoint_url (Required) @@ -976,7 +974,7 @@ TEST(CredentialsTest, TestInvalidStsCredsOptions) { nullptr // actor_token_type }; url_should_be_invalid = ValidateStsCredentialsOptions(&invalid_options); - GPR_ASSERT(!url_should_be_invalid.ok()); + CHECK(!url_should_be_invalid.ok()); invalid_options = { "not_a_valid_uri", // sts_endpoint_url @@ -990,7 +988,7 @@ TEST(CredentialsTest, TestInvalidStsCredsOptions) { nullptr // actor_token_type }; url_should_be_invalid = ValidateStsCredentialsOptions(&invalid_options); - GPR_ASSERT(!url_should_be_invalid.ok()); + CHECK(!url_should_be_invalid.ok()); invalid_options = { "ftp://ftp.is.not.a.valid.scheme/bar", // sts_endpoint_url @@ -1004,18 +1002,18 @@ TEST(CredentialsTest, TestInvalidStsCredsOptions) { nullptr // actor_token_type }; url_should_be_invalid = ValidateStsCredentialsOptions(&invalid_options); - GPR_ASSERT(!url_should_be_invalid.ok()); + CHECK(!url_should_be_invalid.ok()); } void assert_query_parameters(const URI& uri, absl::string_view expected_key, absl::string_view expected_val) { const auto it = uri.query_parameter_map().find(expected_key); - GPR_ASSERT(it != uri.query_parameter_map().end()); + CHECK(it != uri.query_parameter_map().end()); if (it->second != expected_val) { gpr_log(GPR_ERROR, "%s!=%s", std::string(it->second).c_str(), std::string(expected_val).c_str()); } - GPR_ASSERT(it->second == expected_val); + CHECK(it->second == expected_val); } void validate_sts_token_http_request(const grpc_http_request* request, @@ -1023,14 +1021,14 @@ void validate_sts_token_http_request(const grpc_http_request* request, const char* body, size_t body_size, bool expect_actor_token) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); std::string get_url_equivalent = absl::StrFormat("%s?%s", test_sts_endpoint_url, body); absl::StatusOr url = URI::Parse(get_url_equivalent); if (!url.ok()) { gpr_log(GPR_ERROR, "%s", url.status().ToString().c_str()); - GPR_ASSERT(url.ok()); + CHECK_OK(url); } assert_query_parameters(*url, "resource", "resource"); assert_query_parameters(*url, "audience", "audience"); @@ -1044,19 +1042,19 @@ void validate_sts_token_http_request(const grpc_http_request* request, assert_query_parameters(*url, "actor_token_type", test_signed_jwt_token_type2); } else { - GPR_ASSERT(url->query_parameter_map().find("actor_token") == - url->query_parameter_map().end()); - GPR_ASSERT(url->query_parameter_map().find("actor_token_type") == - url->query_parameter_map().end()); + CHECK(url->query_parameter_map().find("actor_token") == + url->query_parameter_map().end()); + CHECK(url->query_parameter_map().find("actor_token_type") == + url->query_parameter_map().end()); } // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/v1/token-exchange") == 0); - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/v1/token-exchange"), 0); + CHECK_EQ(request->hdr_count, 1); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); } int sts_token_httpcli_post_success(const grpc_http_request* request, @@ -1084,10 +1082,10 @@ int sts_token_httpcli_post_success_no_actor_token( char* write_tmp_jwt_file(const char* jwt_contents) { char* path; FILE* tmp = gpr_tmpfile(test_signed_jwt_path_prefix, &path); - GPR_ASSERT(path != nullptr); - GPR_ASSERT(tmp != nullptr); + CHECK_NE(path, nullptr); + CHECK_NE(tmp, nullptr); size_t jwt_length = strlen(jwt_contents); - GPR_ASSERT(fwrite(jwt_contents, 1, jwt_length, tmp) == jwt_length); + CHECK_EQ(fwrite(jwt_contents, 1, jwt_length, tmp), jwt_length); fclose(tmp); return path; } @@ -1115,7 +1113,7 @@ TEST(CredentialsTest, TestStsCredsSuccess) { grpc_sts_credentials_create(&valid_options, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance(absl::OkStatus(), emd); @@ -1134,8 +1132,8 @@ TEST(CredentialsTest, TestStsCredsSuccess) { state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -1160,7 +1158,7 @@ TEST(CredentialsTest, TestStsCredsTokenFileNotFound) { grpc_sts_credentials_create(&valid_options, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( GRPC_ERROR_CREATE("Error occurred when fetching oauth2 token."), {}); @@ -1198,7 +1196,7 @@ TEST(CredentialsTest, TestStsCredsNoActorTokenSuccess) { grpc_sts_credentials_create(&valid_options, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance(absl::OkStatus(), emd); @@ -1217,8 +1215,8 @@ TEST(CredentialsTest, TestStsCredsNoActorTokenSuccess) { state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -1250,8 +1248,8 @@ TEST(CredentialsTest, TestStsCredsLoadTokenFailure) { httpcli_put_should_not_be_called); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -1284,8 +1282,8 @@ TEST(CredentialsTest, TestStsCredsHttpFailure) { httpcli_put_should_not_be_called); state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); gpr_free(test_signed_jwt_path); @@ -1294,30 +1292,30 @@ TEST(CredentialsTest, TestStsCredsHttpFailure) { void validate_jwt_encode_and_sign_params(const grpc_auth_json_key* json_key, const char* scope, gpr_timespec token_lifetime) { - GPR_ASSERT(grpc_auth_json_key_is_valid(json_key)); - GPR_ASSERT(json_key->private_key != nullptr); + CHECK(grpc_auth_json_key_is_valid(json_key)); + CHECK_NE(json_key->private_key, nullptr); #if OPENSSL_VERSION_NUMBER < 0x30000000L - GPR_ASSERT(RSA_check_key(json_key->private_key)); + CHECK(RSA_check_key(json_key->private_key)); #else EVP_PKEY_CTX* ctx = EVP_PKEY_CTX_new(json_key->private_key, NULL); - GPR_ASSERT(EVP_PKEY_private_check(ctx)); + CHECK(EVP_PKEY_private_check(ctx)); EVP_PKEY_CTX_free(ctx); #endif - GPR_ASSERT(json_key->type != nullptr && - strcmp(json_key->type, "service_account") == 0); - GPR_ASSERT(json_key->private_key_id != nullptr && - strcmp(json_key->private_key_id, - "e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0); - GPR_ASSERT(json_key->client_id != nullptr && - strcmp(json_key->client_id, - "777-abaslkan11hlb6nmim3bpspl31ud.apps." - "googleusercontent.com") == 0); - GPR_ASSERT(json_key->client_email != nullptr && - strcmp(json_key->client_email, - "777-abaslkan11hlb6nmim3bpspl31ud@developer." - "gserviceaccount.com") == 0); - if (scope != nullptr) GPR_ASSERT(strcmp(scope, test_scope) == 0); - GPR_ASSERT(gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()) == 0); + CHECK(json_key->type != nullptr && + strcmp(json_key->type, "service_account") == 0); + CHECK(json_key->private_key_id != nullptr && + strcmp(json_key->private_key_id, + "e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0); + CHECK(json_key->client_id != nullptr && + strcmp(json_key->client_id, + "777-abaslkan11hlb6nmim3bpspl31ud.apps." + "googleusercontent.com") == 0); + CHECK(json_key->client_email != nullptr && + strcmp(json_key->client_email, + "777-abaslkan11hlb6nmim3bpspl31ud@developer." + "gserviceaccount.com") == 0); + if (scope != nullptr) CHECK_EQ(strcmp(scope, test_scope), 0); + CHECK_EQ(gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()), 0); } char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key, @@ -1343,15 +1341,14 @@ char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key, char* encode_and_sign_jwt_should_not_be_called( const grpc_auth_json_key* /*json_key*/, const char* /*audience*/, gpr_timespec /*token_lifetime*/, const char* /*scope*/) { - GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == nullptr); + CHECK_EQ("grpc_jwt_encode_and_sign should not be called", nullptr); return nullptr; } grpc_service_account_jwt_access_credentials* creds_as_jwt( grpc_call_credentials* creds) { - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(creds->type() == - grpc_service_account_jwt_access_credentials::Type()); + CHECK(creds != nullptr); + CHECK(creds->type() == grpc_service_account_jwt_access_credentials::Type()); return reinterpret_cast(creds); } @@ -1363,25 +1360,28 @@ TEST(CredentialsTest, TestJwtCredsLifetime) { grpc_call_credentials* jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime(), nullptr); - GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), - grpc_max_auth_token_lifetime()) == 0); + CHECK_EQ(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), + grpc_max_auth_token_lifetime()), + 0); // Check security level. - GPR_ASSERT(jwt_creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); - GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + CHECK_EQ(jwt_creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)), + 0); grpc_call_credentials_release(jwt_creds); // Shorter lifetime. gpr_timespec token_lifetime = {10, 0, GPR_TIMESPAN}; - GPR_ASSERT(gpr_time_cmp(grpc_max_auth_token_lifetime(), token_lifetime) > 0); + CHECK_GT(gpr_time_cmp(grpc_max_auth_token_lifetime(), token_lifetime), 0); jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, token_lifetime, nullptr); - GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), - token_lifetime) == 0); - GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + CHECK_EQ( + gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), token_lifetime), 0); + CHECK_EQ(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)), + 0); grpc_call_credentials_release(jwt_creds); // Cropped lifetime. @@ -1389,11 +1389,11 @@ TEST(CredentialsTest, TestJwtCredsLifetime) { token_lifetime = gpr_time_add(grpc_max_auth_token_lifetime(), add_to_max); jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, token_lifetime, nullptr); - GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), - grpc_max_auth_token_lifetime()) == 0); - GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + CHECK(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), + grpc_max_auth_token_lifetime()) == 0); + CHECK(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); gpr_free(json_key_string); @@ -1401,12 +1401,12 @@ TEST(CredentialsTest, TestJwtCredsLifetime) { TEST(CredentialsTest, TestRemoveServiceFromJwtUri) { const char wrong_uri[] = "hello world"; - GPR_ASSERT(!RemoveServiceNameFromJwtUri(wrong_uri).ok()); + CHECK(!RemoveServiceNameFromJwtUri(wrong_uri).ok()); const char valid_uri[] = "https://foo.com/get/"; const char expected_uri[] = "https://foo.com/"; auto output = RemoveServiceNameFromJwtUri(valid_uri); - GPR_ASSERT(output.ok()); - GPR_ASSERT(strcmp(output->c_str(), expected_uri) == 0); + CHECK_OK(output); + CHECK_EQ(strcmp(output->c_str(), expected_uri), 0); } TEST(CredentialsTest, TestJwtCredsSuccess) { @@ -1443,9 +1443,10 @@ TEST(CredentialsTest, TestJwtCredsSuccess) { state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestOtherAuthority, kTestOtherPath); ExecCtx::Get()->Flush(); - GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + CHECK_EQ( + strncmp(expected_creds_debug_string_prefix, creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)), + 0); creds->Unref(); gpr_free(json_key_string); @@ -1468,9 +1469,10 @@ TEST(CredentialsTest, TestJwtCredsSigningFailure) { kTestPath); gpr_free(json_key_string); - GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + CHECK_EQ( + strncmp(expected_creds_debug_string_prefix, creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)), + 0); creds->Unref(); grpc_jwt_encode_and_sign_set_override(nullptr); @@ -1481,9 +1483,9 @@ void set_google_default_creds_env_var_with_file_contents( size_t contents_len = strlen(contents); char* creds_file_name; FILE* creds_file = gpr_tmpfile(file_prefix, &creds_file_name); - GPR_ASSERT(creds_file_name != nullptr); - GPR_ASSERT(creds_file != nullptr); - GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len); + CHECK_NE(creds_file_name, nullptr); + CHECK_NE(creds_file, nullptr); + CHECK_EQ(fwrite(contents, 1, contents_len, creds_file), contents_len); fclose(creds_file); SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, creds_file_name); gpr_free(creds_file_name); @@ -1514,15 +1516,15 @@ TEST(CredentialsTest, TestGoogleDefaultCredsAuthKey) { auto* default_creds = reinterpret_cast( creds->inner_creds()); - GPR_ASSERT(default_creds->ssl_creds() != nullptr); + CHECK_NE(default_creds->ssl_creds(), nullptr); auto* jwt = reinterpret_cast( creds->call_creds()); - GPR_ASSERT( + CHECK_EQ( strcmp(jwt->key().client_id, - "777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") == + "777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com"), 0); - GPR_ASSERT(g_test_gce_tenancy_checker_called == false); + CHECK_EQ(g_test_gce_tenancy_checker_called, false); creds->Unref(); SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); // Reset. grpc_override_well_known_credentials_path_getter(nullptr); @@ -1541,12 +1543,13 @@ TEST(CredentialsTest, TestGoogleDefaultCredsRefreshToken) { auto* default_creds = reinterpret_cast( creds->inner_creds()); - GPR_ASSERT(default_creds->ssl_creds() != nullptr); + CHECK_NE(default_creds->ssl_creds(), nullptr); auto* refresh = reinterpret_cast( creds->call_creds()); - GPR_ASSERT(strcmp(refresh->refresh_token().client_id, - "32555999999.apps.googleusercontent.com") == 0); + CHECK_EQ(strcmp(refresh->refresh_token().client_id, + "32555999999.apps.googleusercontent.com"), + 0); creds->Unref(); SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); // Reset. grpc_override_well_known_credentials_path_getter(nullptr); @@ -1566,10 +1569,10 @@ TEST(CredentialsTest, TestGoogleDefaultCredsExternalAccountCredentialsPscSts) { auto* default_creds = reinterpret_cast( creds->inner_creds()); - GPR_ASSERT(default_creds->ssl_creds() != nullptr); + CHECK_NE(default_creds->ssl_creds(), nullptr); auto* external = reinterpret_cast(creds->call_creds()); - GPR_ASSERT(external != nullptr); + CHECK_NE(external, nullptr); creds->Unref(); SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); // Reset. grpc_override_well_known_credentials_path_getter(nullptr); @@ -1589,10 +1592,10 @@ TEST(CredentialsTest, TestGoogleDefaultCredsExternalAccountCredentialsPscIam) { auto* default_creds = reinterpret_cast( creds->inner_creds()); - GPR_ASSERT(default_creds->ssl_creds() != nullptr); + CHECK_NE(default_creds->ssl_creds(), nullptr); auto* external = reinterpret_cast(creds->call_creds()); - GPR_ASSERT(external != nullptr); + CHECK_NE(external, nullptr); creds->Unref(); SetEnv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); // Reset. grpc_override_well_known_credentials_path_getter(nullptr); @@ -1609,8 +1612,8 @@ int default_creds_metadata_server_detection_httpcli_get_success_override( headers[0].value = gpr_strdup("Google"); response->hdr_count = 1; response->hdrs = headers; - GPR_ASSERT(strcmp(path, "/") == 0); - GPR_ASSERT(strcmp(host, "metadata.google.internal.") == 0); + CHECK_EQ(strcmp(path, "/"), 0); + CHECK_EQ(strcmp(host, "metadata.google.internal."), 0); ExecCtx::Run(DEBUG_LOCATION, on_done, absl::OkStatus()); return 1; } @@ -1634,8 +1637,8 @@ TEST(CredentialsTest, TestGoogleDefaultCredsGce) { grpc_google_default_credentials_create(nullptr)); // Verify that the default creds actually embeds a GCE creds. - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(creds->call_creds() != nullptr); + CHECK(creds != nullptr); + CHECK_NE(creds->call_creds(), nullptr); HttpRequest::SetOverride(compute_engine_httpcli_get_success_override, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); @@ -1643,7 +1646,7 @@ TEST(CredentialsTest, TestGoogleDefaultCredsGce) { kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT(g_test_gce_tenancy_checker_called == true); + CHECK_EQ(g_test_gce_tenancy_checker_called, true); // Cleanup. creds->Unref(); @@ -1671,15 +1674,15 @@ TEST(CredentialsTest, TestGoogleDefaultCredsNonGce) { reinterpret_cast( grpc_google_default_credentials_create(nullptr)); // Verify that the default creds actually embeds a GCE creds. - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(creds->call_creds() != nullptr); + CHECK(creds != nullptr); + CHECK_NE(creds->call_creds(), nullptr); HttpRequest::SetOverride(compute_engine_httpcli_get_success_override, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); state->RunRequestMetadataTest(creds->mutable_call_creds(), kTestUrlScheme, kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); - GPR_ASSERT(g_test_gce_tenancy_checker_called == true); + CHECK_EQ(g_test_gce_tenancy_checker_called, true); // Cleanup. creds->Unref(); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -1691,8 +1694,8 @@ int default_creds_gce_detection_httpcli_get_failure_override( Timestamp /*deadline*/, grpc_closure* on_done, grpc_http_response* response) { // No magic header. - GPR_ASSERT(strcmp(path, "/") == 0); - GPR_ASSERT(strcmp(host, "metadata.google.internal.") == 0); + CHECK_EQ(strcmp(path, "/"), 0); + CHECK_EQ(strcmp(host, "metadata.google.internal."), 0); *response = http_response(200, ""); ExecCtx::Run(DEBUG_LOCATION, on_done, absl::OkStatus()); return 1; @@ -1710,11 +1713,11 @@ TEST(CredentialsTest, TestNoGoogleDefaultCreds) { default_creds_gce_detection_httpcli_get_failure_override, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); // Simulate a successful detection of GCE. - GPR_ASSERT(grpc_google_default_credentials_create(nullptr) == nullptr); + CHECK_EQ(grpc_google_default_credentials_create(nullptr), nullptr); // Try a second one. GCE detection should occur again. g_test_gce_tenancy_checker_called = false; - GPR_ASSERT(grpc_google_default_credentials_create(nullptr) == nullptr); - GPR_ASSERT(g_test_gce_tenancy_checker_called == true); + CHECK_EQ(grpc_google_default_credentials_create(nullptr), nullptr); + CHECK_EQ(g_test_gce_tenancy_checker_called, true); // Cleanup. grpc_override_well_known_credentials_path_getter(nullptr); HttpRequest::SetOverride(nullptr, nullptr, nullptr); @@ -1737,9 +1740,9 @@ TEST(CredentialsTest, TestGoogleDefaultCredsCallCredsSpecified) { grpc_composite_channel_credentials* channel_creds = reinterpret_cast( grpc_google_default_credentials_create(call_creds)); - GPR_ASSERT(g_test_gce_tenancy_checker_called == false); - GPR_ASSERT(channel_creds != nullptr); - GPR_ASSERT(channel_creds->call_creds() != nullptr); + CHECK_EQ(g_test_gce_tenancy_checker_called, false); + CHECK_NE(channel_creds, nullptr); + CHECK_NE(channel_creds->call_creds(), nullptr); HttpRequest::SetOverride(compute_engine_httpcli_get_success_override, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); @@ -1787,9 +1790,9 @@ TEST(CredentialsTest, TestGoogleDefaultCredsNotDefault) { grpc_composite_channel_credentials* channel_creds = reinterpret_cast( grpc_google_default_credentials_create(call_creds.release())); - GPR_ASSERT(g_test_gce_tenancy_checker_called == false); - GPR_ASSERT(channel_creds != nullptr); - GPR_ASSERT(channel_creds->call_creds() != nullptr); + CHECK_EQ(g_test_gce_tenancy_checker_called, false); + CHECK_NE(channel_creds, nullptr); + CHECK_NE(channel_creds->call_creds(), nullptr); state->RunRequestMetadataTest(channel_creds->mutable_call_creds(), kTestUrlScheme, kTestAuthority, kTestPath); ExecCtx::Get()->Flush(); @@ -1812,11 +1815,11 @@ int plugin_get_metadata_success( grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t* num_creds_md, grpc_status_code* /*status*/, const char** /*error_details*/) { - GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); - GPR_ASSERT(strcmp(context.method_name, test_method) == 0); - GPR_ASSERT(context.channel_auth_context == nullptr); - GPR_ASSERT(context.reserved == nullptr); - GPR_ASSERT(plugin_md.size() < GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX); + CHECK_EQ(strcmp(context.service_url, test_service_url), 0); + CHECK_EQ(strcmp(context.method_name, test_method), 0); + CHECK_EQ(context.channel_auth_context, nullptr); + CHECK_EQ(context.reserved, nullptr); + CHECK_LT(plugin_md.size(), GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX); plugin_state* s = static_cast(state); *s = PLUGIN_GET_METADATA_CALLED_STATE; size_t i = 0; @@ -1838,10 +1841,10 @@ int plugin_get_metadata_failure( grpc_metadata /*creds_md*/[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t* /*num_creds_md*/, grpc_status_code* status, const char** error_details) { - GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); - GPR_ASSERT(strcmp(context.method_name, test_method) == 0); - GPR_ASSERT(context.channel_auth_context == nullptr); - GPR_ASSERT(context.reserved == nullptr); + CHECK_EQ(strcmp(context.service_url, test_service_url), 0); + CHECK_EQ(strcmp(context.method_name, test_method), 0); + CHECK_EQ(context.channel_auth_context, nullptr); + CHECK_EQ(context.reserved, nullptr); plugin_state* s = static_cast(state); *s = PLUGIN_GET_METADATA_CALLED_STATE; *status = GRPC_STATUS_UNAUTHENTICATED; @@ -1891,16 +1894,16 @@ TEST(CredentialsTest, TestMetadataPluginSuccess) { grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin( plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr); // Check security level. - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); - GPR_ASSERT(state == PLUGIN_INITIAL_STATE); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(state, PLUGIN_INITIAL_STATE); md_state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(state, PLUGIN_GET_METADATA_CALLED_STATE); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); - GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); + CHECK_EQ(state, PLUGIN_DESTROY_CALLED_STATE); } TEST(CredentialsTest, TestMetadataPluginFailure) { @@ -1923,15 +1926,15 @@ TEST(CredentialsTest, TestMetadataPluginFailure) { grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin( plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr); - GPR_ASSERT(state == PLUGIN_INITIAL_STATE); + CHECK_EQ(state, PLUGIN_INITIAL_STATE); md_state->RunRequestMetadataTest(creds, kTestUrlScheme, kTestAuthority, kTestPath); - GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); - GPR_ASSERT( - strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); + CHECK_EQ(state, PLUGIN_GET_METADATA_CALLED_STATE); + CHECK_EQ(strcmp(creds->debug_string().c_str(), expected_creds_debug_string), + 0); creds->Unref(); - GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); + CHECK_EQ(state, PLUGIN_DESTROY_CALLED_STATE); } TEST(CredentialsTest, TestGetWellKnownGoogleCredentialsFilePath) { @@ -1946,12 +1949,12 @@ TEST(CredentialsTest, TestGetWellKnownGoogleCredentialsFilePath) { #endif // defined(GRPC_BAZEL_BUILD) && (defined(GPR_POSIX_ENV) || // defined(GPR_LINUX_ENV)) std::string path = grpc_get_well_known_google_credentials_file_path(); - GPR_ASSERT(!path.empty()); + CHECK(!path.empty()); #if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) restore_home_env = true; UnsetEnv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); - GPR_ASSERT(path.empty()); + CHECK(path.empty()); #endif // GPR_POSIX_ENV || GPR_LINUX_ENV if (restore_home_env) { SetOrUnsetEnv("HOME", home); @@ -1968,7 +1971,7 @@ TEST(CredentialsTest, TestChannelCredsDuplicateWithoutCallCreds) { RefCountedPtr dup = channel_creds->duplicate_without_call_credentials(); - GPR_ASSERT(dup == channel_creds); + CHECK(dup == channel_creds); dup.reset(); grpc_call_credentials* call_creds = @@ -1976,12 +1979,13 @@ TEST(CredentialsTest, TestChannelCredsDuplicateWithoutCallCreds) { grpc_channel_credentials* composite_creds = grpc_composite_channel_credentials_create(channel_creds, call_creds, nullptr); - GPR_ASSERT(strcmp(call_creds->debug_string().c_str(), - expected_creds_debug_string) == 0); + CHECK_EQ( + strcmp(call_creds->debug_string().c_str(), expected_creds_debug_string), + 0); call_creds->Unref(); dup = composite_creds->duplicate_without_call_credentials(); - GPR_ASSERT(dup == channel_creds); + CHECK(dup == channel_creds); dup.reset(); channel_creds->Unref(); @@ -2093,7 +2097,7 @@ TEST(CredentialsTest, TestAuthMetadataContext) { test_cases[i].desired_method_name, auth_md_context.method_name)); } - GPR_ASSERT(auth_md_context.channel_auth_context == nullptr); + CHECK_EQ(auth_md_context.channel_auth_context, nullptr); grpc_slice_unref(call_host); grpc_slice_unref(call_method); grpc_auth_metadata_context_reset(&auth_md_context); @@ -2104,14 +2108,14 @@ void validate_external_account_creds_token_exchage_request( const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size, bool /*expect_actor_token*/) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); std::string get_url_equivalent = absl::StrFormat("%s?%s", "https://foo.com:5555/token", body); absl::StatusOr uri = URI::Parse(get_url_equivalent); if (!uri.ok()) { gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str()); - GPR_ASSERT(uri.ok()); + CHECK_OK(uri); } assert_query_parameters(*uri, "audience", "audience"); assert_query_parameters(*uri, "grant_type", @@ -2124,24 +2128,25 @@ void validate_external_account_creds_token_exchage_request( "https://www.googleapis.com/auth/cloud-platform"); // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/token") == 0); - GPR_ASSERT(request->hdr_count == 3); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); - GPR_ASSERT(strcmp(request->hdrs[2].key, "Authorization") == 0); - GPR_ASSERT(strcmp(request->hdrs[2].value, - "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/token"), 0); + CHECK_EQ(request->hdr_count, 3); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); + CHECK_EQ(strcmp(request->hdrs[2].key, "Authorization"), 0); + CHECK_EQ( + strcmp(request->hdrs[2].value, "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ="), + 0); } void validate_external_account_creds_token_exchage_request_with_url_encode( const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size, bool /*expect_actor_token*/) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); - GPR_ASSERT( + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); + CHECK_EQ( strcmp( std::string(body, body_size).c_str(), "audience=audience_!%40%23%24&grant_type=urn%3Aietf%3Aparams%3Aoauth%" @@ -2149,56 +2154,58 @@ void validate_external_account_creds_token_exchage_request_with_url_encode( "3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=" "subject_token_type_!%40%23%24&subject_token=test_subject_token&" "scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&" - "options=%7B%7D") == 0); + "options=%7B%7D"), + 0); // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/token_url_encode") == 0); - GPR_ASSERT(request->hdr_count == 3); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); - GPR_ASSERT(strcmp(request->hdrs[2].key, "Authorization") == 0); - GPR_ASSERT(strcmp(request->hdrs[2].value, - "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/token_url_encode"), 0); + CHECK_EQ(request->hdr_count, 3); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); + CHECK_EQ(strcmp(request->hdrs[2].key, "Authorization"), 0); + CHECK_EQ( + strcmp(request->hdrs[2].value, "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ="), + 0); } void validate_external_account_creds_service_account_impersonation_request( const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size, bool /*expect_actor_token*/) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); - GPR_ASSERT(strcmp(body, "scope=scope_1%20scope_2&lifetime=3600s") == 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); + CHECK_EQ(strcmp(body, "scope=scope_1%20scope_2&lifetime=3600s"), 0); // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/service_account_impersonation") == 0); - GPR_ASSERT(request->hdr_count == 2); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); - GPR_ASSERT(strcmp(request->hdrs[1].key, "Authorization") == 0); - GPR_ASSERT(strcmp(request->hdrs[1].value, - "Bearer token_exchange_access_token") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/service_account_impersonation"), 0); + CHECK_EQ(request->hdr_count, 2); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); + CHECK_EQ(strcmp(request->hdrs[1].key, "Authorization"), 0); + CHECK_EQ(strcmp(request->hdrs[1].value, "Bearer token_exchange_access_token"), + 0); } void validate_external_account_creds_serv_acc_imp_custom_lifetime_request( const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size, bool /*expect_actor_token*/) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); - GPR_ASSERT(strcmp(body, "scope=scope_1%20scope_2&lifetime=1800s") == 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); + CHECK_EQ(strcmp(body, "scope=scope_1%20scope_2&lifetime=1800s"), 0); // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/service_account_impersonation") == 0); - GPR_ASSERT(request->hdr_count == 2); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); - GPR_ASSERT(strcmp(request->hdrs[1].key, "Authorization") == 0); - GPR_ASSERT(strcmp(request->hdrs[1].value, - "Bearer token_exchange_access_token") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/service_account_impersonation"), 0); + CHECK_EQ(request->hdr_count, 2); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); + CHECK_EQ(strcmp(request->hdrs[1].key, "Authorization"), 0); + CHECK_EQ(strcmp(request->hdrs[1].value, "Bearer token_exchange_access_token"), + 0); } int external_acc_creds_serv_acc_imp_custom_lifetime_httpcli_post_success( @@ -2290,15 +2297,15 @@ void validate_aws_external_account_creds_token_exchage_request( const grpc_http_request* request, const char* host, const char* path, const char* body, size_t body_size, bool /*expect_actor_token*/) { // Check that the body is constructed properly. - GPR_ASSERT(body != nullptr); - GPR_ASSERT(body_size != 0); + CHECK_NE(body, nullptr); + CHECK_NE(body_size, 0); // Check that the regional_cred_verification_url got constructed // with the correct AWS Region ("test_regionz" or "test_region"). - GPR_ASSERT(strstr(body, "regional_cred_verification_url_test_region")); + CHECK(strstr(body, "regional_cred_verification_url_test_region")); std::string get_url_equivalent = absl::StrFormat("%s?%s", "https://foo.com:5555/token", body); absl::StatusOr uri = URI::Parse(get_url_equivalent); - GPR_ASSERT(uri.ok()); + CHECK_OK(uri); assert_query_parameters(*uri, "audience", "audience"); assert_query_parameters(*uri, "grant_type", "urn:ietf:params:oauth:grant-type:token-exchange"); @@ -2308,21 +2315,22 @@ void validate_aws_external_account_creds_token_exchage_request( assert_query_parameters(*uri, "scope", "https://www.googleapis.com/auth/cloud-platform"); // Check the rest of the request. - GPR_ASSERT(strcmp(host, "foo.com:5555") == 0); - GPR_ASSERT(strcmp(path, "/token") == 0); - GPR_ASSERT(request->hdr_count == 3); - GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0); - GPR_ASSERT( - strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0); - GPR_ASSERT(strcmp(request->hdrs[1].key, "x-goog-api-client") == 0); + CHECK_EQ(strcmp(host, "foo.com:5555"), 0); + CHECK_EQ(strcmp(path, "/token"), 0); + CHECK_EQ(request->hdr_count, 3); + CHECK_EQ(strcmp(request->hdrs[0].key, "Content-Type"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded"), + 0); + CHECK_EQ(strcmp(request->hdrs[1].key, "x-goog-api-client"), 0); EXPECT_EQ( request->hdrs[1].value, absl::StrFormat("gl-cpp/unknown auth/%s google-byoid-sdk source/aws " "sa-impersonation/false config-lifetime/false", grpc_version_string())); - GPR_ASSERT(strcmp(request->hdrs[2].key, "Authorization") == 0); - GPR_ASSERT(strcmp(request->hdrs[2].value, - "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=") == 0); + CHECK_EQ(strcmp(request->hdrs[2].key, "Authorization"), 0); + CHECK_EQ( + strcmp(request->hdrs[2].value, "Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ="), + 0); } int aws_external_account_creds_httpcli_get_success( @@ -2346,9 +2354,9 @@ int aws_external_account_creds_httpcli_get_success( int aws_imdsv2_external_account_creds_httpcli_get_success( const grpc_http_request* request, const char* host, const char* path, Timestamp deadline, grpc_closure* on_done, grpc_http_response* response) { - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, "x-aws-ec2-metadata-token") == 0); - GPR_ASSERT(strcmp(request->hdrs[0].value, aws_imdsv2_session_token) == 0); + CHECK_EQ(request->hdr_count, 1); + CHECK_EQ(strcmp(request->hdrs[0].key, "x-aws-ec2-metadata-token"), 0); + CHECK_EQ(strcmp(request->hdrs[0].value, aws_imdsv2_session_token), 0); return aws_external_account_creds_httpcli_get_success( request, host, path, deadline, on_done, response); } @@ -2357,11 +2365,11 @@ int aws_imdsv2_external_account_creds_httpcli_put_success( const grpc_http_request* request, const char* /*host*/, const char* path, const char* /*body*/, size_t /*body_size*/, Timestamp /*deadline*/, grpc_closure* on_done, grpc_http_response* response) { - GPR_ASSERT(request->hdr_count == 1); - GPR_ASSERT(strcmp(request->hdrs[0].key, - "x-aws-ec2-metadata-token-ttl-seconds") == 0); - GPR_ASSERT(strcmp(request->hdrs[0].value, "300") == 0); - GPR_ASSERT(strcmp(path, "/imdsv2_session_token_url") == 0); + CHECK_EQ(request->hdr_count, 1); + CHECK_EQ(strcmp(request->hdrs[0].key, "x-aws-ec2-metadata-token-ttl-seconds"), + 0); + CHECK_EQ(strcmp(request->hdrs[0].value, "300"), 0); + CHECK_EQ(strcmp(path, "/imdsv2_session_token_url"), 0); *response = http_response(200, aws_imdsv2_session_token); ExecCtx::Run(DEBUG_LOCATION, on_done, absl::OkStatus()); return 1; @@ -2507,7 +2515,7 @@ TEST(CredentialsTest, TestExternalAccountCredsSuccess) { }; TestExternalAccountCredentials creds(options, {}); // Check security level. - GPR_ASSERT(creds.min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds.min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); @@ -2586,7 +2594,7 @@ TEST(CredentialsTest, }; TestExternalAccountCredentials creds(options, {"scope_1", "scope_2"}); // Check security level. - GPR_ASSERT(creds.min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds.min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance( absl::OkStatus(), @@ -2624,7 +2632,7 @@ TEST( }; TestExternalAccountCredentials creds(options, {"scope_1", "scope_2"}); // Check security level. - GPR_ASSERT(creds.min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK_EQ(creds.min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); // First request: http put should be called. auto state = RequestMetadataState::NewInstance( absl::OkStatus(), @@ -2658,12 +2666,12 @@ TEST( "\"client_id\":\"client_id\",\"client_secret\":\"client_secret\"}"; grpc_error_handle error1, error2; auto json1 = JsonParse(options_string1); - GPR_ASSERT(json1.ok()); + CHECK_OK(json1); ExternalAccountCredentials::Create(*json1, {"scope1", "scope2"}, &error1); std::string actual_error1, expected_error1 = "token_lifetime_seconds must be more than 600s"; grpc_error_get_str(error1, StatusStrProperty::kDescription, &actual_error1); - GPR_ASSERT(strcmp(actual_error1.c_str(), expected_error1.c_str()) == 0); + CHECK_EQ(strcmp(actual_error1.c_str(), expected_error1.c_str()), 0); const char* options_string2 = "{\"type\":\"external_account\",\"audience\":\"audience\"," @@ -2680,12 +2688,12 @@ TEST( "token\"}},\"quota_project_id\":\"quota_project_id\"," "\"client_id\":\"client_id\",\"client_secret\":\"client_secret\"}"; auto json2 = JsonParse(options_string2); - GPR_ASSERT(json2.ok()); + CHECK_OK(json2); ExternalAccountCredentials::Create(*json2, {"scope1", "scope2"}, &error2); std::string actual_error2, expected_error2 = "token_lifetime_seconds must be less than 43200s"; grpc_error_get_str(error2, StatusStrProperty::kDescription, &actual_error2); - GPR_ASSERT(strcmp(actual_error2.c_str(), expected_error2.c_str()) == 0); + CHECK_EQ(strcmp(actual_error2.c_str(), expected_error2.c_str()), 0); } TEST(CredentialsTest, TestExternalAccountCredsFailureInvalidTokenUrl) { @@ -2803,7 +2811,7 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatText) { ExecCtx exec_ctx; auto credential_source = JsonParse( valid_url_external_account_creds_options_credential_source_format_text); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -2823,9 +2831,9 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatText) { }; grpc_error_handle error; auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(url_external_account_creds_httpcli_get_success, @@ -2844,7 +2852,7 @@ TEST(CredentialsTest, ExecCtx exec_ctx; auto credential_source = JsonParse( valid_url_external_account_creds_options_credential_source_with_qurey_params_format_text); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -2864,9 +2872,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(url_external_account_creds_httpcli_get_success, @@ -2882,7 +2890,7 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatJson) { ExecCtx exec_ctx; auto credential_source = JsonParse( valid_url_external_account_creds_options_credential_source_format_json); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -2902,9 +2910,9 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsSuccessFormatJson) { }; grpc_error_handle error; auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(url_external_account_creds_httpcli_get_success, @@ -2920,7 +2928,7 @@ TEST(CredentialsTest, TestUrlExternalAccountCredsFailureInvalidCredentialSourceUrl) { auto credential_source = JsonParse(invalid_url_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -2940,11 +2948,11 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = UrlExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds == nullptr); + CHECK(creds == nullptr); std::string actual_error; - GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription, - &actual_error)); - GPR_ASSERT(absl::StartsWith(actual_error, "Invalid credential source url.")); + CHECK(grpc_error_get_str(error, StatusStrProperty::kDescription, + &actual_error)); + CHECK(absl::StartsWith(actual_error, "Invalid credential source url.")); } TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { @@ -2953,7 +2961,7 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { auto credential_source = JsonParse(absl::StrFormat( "{\"file\":\"%s\"}", absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -2973,9 +2981,9 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatText) { }; grpc_error_handle error; auto creds = FileExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(httpcli_get_should_not_be_called, @@ -3002,7 +3010,7 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { "}\n" "}", absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3022,9 +3030,9 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { }; grpc_error_handle error; auto creds = FileExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(httpcli_get_should_not_be_called, @@ -3040,7 +3048,7 @@ TEST(CredentialsTest, TestFileExternalAccountCredsSuccessFormatJson) { TEST(CredentialsTest, TestFileExternalAccountCredsFailureFileNotFound) { ExecCtx exec_ctx; auto credential_source = JsonParse("{\"file\":\"non_exisiting_file\"}"); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3060,8 +3068,8 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureFileNotFound) { }; grpc_error_handle error; auto creds = FileExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); + CHECK(creds != nullptr); + CHECK_OK(error); HttpRequest::SetOverride(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); @@ -3088,7 +3096,7 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureInvalidJsonContent) { "}\n" "}", absl::StrReplaceAll(subject_token_path, {{"\\", "\\\\"}}))); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3108,8 +3116,8 @@ TEST(CredentialsTest, TestFileExternalAccountCredsFailureInvalidJsonContent) { }; grpc_error_handle error; auto creds = FileExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); + CHECK(creds != nullptr); + CHECK_OK(error); HttpRequest::SetOverride(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called, httpcli_put_should_not_be_called); @@ -3129,7 +3137,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccess) { ExecCtx exec_ctx; auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3149,9 +3157,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccess) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3167,7 +3175,7 @@ TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { ExecCtx exec_ctx; auto credential_source = JsonParse( valid_aws_imdsv2_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3187,9 +3195,9 @@ TEST(CredentialsTest, TestAwsImdsv2ExternalAccountCredsSuccess) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride( @@ -3211,7 +3219,7 @@ TEST(CredentialsTest, SetEnv("AWS_SESSION_TOKEN", "test_token"); auto credential_source = JsonParse( valid_aws_imdsv2_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3231,9 +3239,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3258,7 +3266,7 @@ TEST( SetEnv("AWS_SECRET_ACCESS_KEY", "test_secret_access_key"); auto credential_source = JsonParse( valid_aws_imdsv2_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3278,9 +3286,9 @@ TEST( }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3299,7 +3307,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessIpv6) { ExecCtx exec_ctx; auto credential_source = JsonParse( valid_aws_external_account_creds_options_credential_source_ipv6); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3319,9 +3327,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessIpv6) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride( @@ -3339,7 +3347,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { SetEnv("AWS_REGION", "test_regionz"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3359,9 +3367,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysUrl) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3380,7 +3388,7 @@ TEST(CredentialsTest, SetEnv("AWS_DEFAULT_REGION", "test_regionz"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3400,9 +3408,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3423,7 +3431,7 @@ TEST(CredentialsTest, SetEnv("AWS_DEFAULT_REGION", "ERROR_REGION"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3443,9 +3451,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3466,7 +3474,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { SetEnv("AWS_SESSION_TOKEN", "test_token"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3486,9 +3494,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionUrlKeysEnv) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3511,7 +3519,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { SetEnv("AWS_SESSION_TOKEN", "test_token"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3531,9 +3539,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsSuccessPathRegionEnvKeysEnv) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3560,7 +3568,7 @@ TEST(CredentialsTest, SetEnv("AWS_SESSION_TOKEN", "test_token"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3580,9 +3588,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3609,7 +3617,7 @@ TEST(CredentialsTest, SetEnv("AWS_SESSION_TOKEN", "test_token"); auto credential_source = JsonParse(valid_aws_external_account_creds_options_credential_source); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3629,9 +3637,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); auto state = RequestMetadataState::NewInstance( absl::OkStatus(), "authorization: Bearer token_exchange_access_token"); HttpRequest::SetOverride(aws_external_account_creds_httpcli_get_success, @@ -3665,7 +3673,7 @@ TEST(CredentialsTest, TestExternalAccountCredentialsCreateSuccess) { const char* url_scopes_string = "scope1,scope2"; grpc_call_credentials* url_creds = grpc_external_account_credentials_create( url_options_string, url_scopes_string); - GPR_ASSERT(url_creds != nullptr); + CHECK_NE(url_creds, nullptr); url_creds->Unref(); // file credentials const char* file_options_string = @@ -3681,7 +3689,7 @@ TEST(CredentialsTest, TestExternalAccountCredentialsCreateSuccess) { const char* file_scopes_string = "scope1,scope2"; grpc_call_credentials* file_creds = grpc_external_account_credentials_create( file_options_string, file_scopes_string); - GPR_ASSERT(file_creds != nullptr); + CHECK_NE(file_creds, nullptr); file_creds->Unref(); // aws credentials const char* aws_options_string = @@ -3701,7 +3709,7 @@ TEST(CredentialsTest, TestExternalAccountCredentialsCreateSuccess) { const char* aws_scopes_string = "scope1,scope2"; grpc_call_credentials* aws_creds = grpc_external_account_credentials_create( aws_options_string, aws_scopes_string); - GPR_ASSERT(aws_creds != nullptr); + CHECK_NE(aws_creds, nullptr); aws_creds->Unref(); } @@ -3709,7 +3717,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureUnmatchedEnvironmentId) { auto credential_source = JsonParse( invalid_aws_external_account_creds_options_credential_source_unmatched_environment_id); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3729,12 +3737,12 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds == nullptr); + CHECK(creds == nullptr); std::string expected_error = "environment_id does not match."; std::string actual_error; - GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription, - &actual_error)); - GPR_ASSERT(expected_error == actual_error); + CHECK(grpc_error_get_str(error, StatusStrProperty::kDescription, + &actual_error)); + CHECK(expected_error == actual_error); } TEST(CredentialsTest, @@ -3742,7 +3750,7 @@ TEST(CredentialsTest, ExecCtx exec_ctx; auto credential_source = JsonParse( invalid_aws_external_account_creds_options_credential_source_invalid_regional_cred_verification_url); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3762,9 +3770,9 @@ TEST(CredentialsTest, }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); error = GRPC_ERROR_CREATE("Creating aws request signer failed."); grpc_error_handle expected_error = GRPC_ERROR_CREATE_REFERENCING( "Error occurred when fetching oauth2 token.", &error, 1); @@ -3782,7 +3790,7 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureMissingRoleName) { ExecCtx exec_ctx; auto credential_source = JsonParse( invalid_aws_external_account_creds_options_credential_source_missing_role_name); - GPR_ASSERT(credential_source.ok()); + CHECK_OK(credential_source); TestExternalAccountCredentials::ServiceAccountImpersonation service_account_impersonation; service_account_impersonation.token_lifetime_seconds = 3600; @@ -3802,9 +3810,9 @@ TEST(CredentialsTest, TestAwsExternalAccountCredsFailureMissingRoleName) { }; grpc_error_handle error; auto creds = AwsExternalAccountCredentials::Create(options, {}, &error); - GPR_ASSERT(creds != nullptr); - GPR_ASSERT(error.ok()); - GPR_ASSERT(creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + CHECK(creds != nullptr); + CHECK_OK(error); + CHECK_EQ(creds->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY); error = GRPC_ERROR_CREATE("Missing role name when retrieving signing keys."); grpc_error_handle expected_error = GRPC_ERROR_CREATE_REFERENCING( "Error occurred when fetching oauth2 token.", &error, 1); @@ -3823,7 +3831,7 @@ TEST(CredentialsTest, const char* options_string = "invalid_json"; grpc_call_credentials* creds = grpc_external_account_credentials_create(options_string, ""); - GPR_ASSERT(creds == nullptr); + CHECK(creds == nullptr); } TEST(CredentialsTest, @@ -3831,7 +3839,7 @@ TEST(CredentialsTest, const char* options_string = "{\"random_key\":\"random_value\"}"; grpc_call_credentials* creds = grpc_external_account_credentials_create(options_string, ""); - GPR_ASSERT(creds == nullptr); + CHECK(creds == nullptr); } TEST( @@ -3849,7 +3857,7 @@ TEST( "secret\"}"; grpc_call_credentials* creds = grpc_external_account_credentials_create(options_string, ""); - GPR_ASSERT(creds == nullptr); + CHECK(creds == nullptr); } TEST(CredentialsTest, @@ -3871,7 +3879,7 @@ TEST(CredentialsTest, const char* url_scopes_string = "scope1,scope2"; grpc_call_credentials* url_creds = grpc_external_account_credentials_create( url_options_string, url_scopes_string); - GPR_ASSERT(url_creds != nullptr); + CHECK_NE(url_creds, nullptr); url_creds->Unref(); } @@ -3894,7 +3902,7 @@ TEST(CredentialsTest, const char* url_scopes_string = "scope1,scope2"; grpc_call_credentials* url_creds = grpc_external_account_credentials_create( url_options_string, url_scopes_string); - GPR_ASSERT(url_creds == nullptr); + CHECK_EQ(url_creds, nullptr); } TEST(CredentialsTest, TestInsecureCredentialsCompareSuccess) { @@ -3932,14 +3940,14 @@ TEST(CredentialsTest, TestInsecureCredentialsSingletonCreate) { TEST(CredentialsTest, TestFakeCallCredentialsCompareSuccess) { auto call_creds = MakeRefCounted(); - GPR_ASSERT(call_creds->cmp(call_creds.get()) == 0); + CHECK_EQ(call_creds->cmp(call_creds.get()), 0); } TEST(CredentialsTest, TestFakeCallCredentialsCompareFailure) { auto fake_creds = MakeRefCounted(); auto* md_creds = grpc_md_only_test_credentials_create("key", "value"); - GPR_ASSERT(fake_creds->cmp(md_creds) != 0); - GPR_ASSERT(md_creds->cmp(fake_creds.get()) != 0); + CHECK_NE(fake_creds->cmp(md_creds), 0); + CHECK_NE(md_creds->cmp(fake_creds.get()), 0); grpc_call_credentials_release(md_creds); } From 6dc64db1a886116316cc82e52693030629a8d653 Mon Sep 17 00:00:00 2001 From: gRPC Team Bot Date: Thu, 18 Apr 2024 09:39:32 -0700 Subject: [PATCH 23/45] Automated rollback of commit f61049f6414efd299367ef8264e07ec5a1c75471. PiperOrigin-RevId: 626062841 --- BUILD | 7 +- CMakeLists.txt | 7 - Makefile | 1 - Package.swift | 1 - build_autogenerated.yaml | 8 - gRPC-C++.podspec | 1 - gRPC-Core.podspec | 1 - grpc.gemspec | 1 - include/grpc/module.modulemap | 1 - include/grpc/passive_listener.h | 62 ---- include/grpcpp/passive_listener.h | 27 -- include/grpcpp/security/server_credentials.h | 1 - include/grpcpp/server_builder.h | 29 -- package.xml | 1 - src/core/BUILD | 2 - .../transport/binder/server/binder_server.cc | 7 +- .../server/chaotic_good_server.cc | 7 +- .../chaotic_good/server/chaotic_good_server.h | 4 +- .../transport/chttp2/server/chttp2_server.cc | 287 ++++++------------ .../transport/chttp2/server/chttp2_server.h | 33 -- .../lib/event_engine/extensions/supports_fd.h | 7 - .../event_engine/posix_engine/posix_engine.cc | 18 +- .../event_engine/posix_engine/posix_engine.h | 2 - src/core/lib/surface/server.h | 14 +- src/cpp/server/server_builder.cc | 61 +--- .../event_engine/event_engine_test_utils.h | 65 ---- test/cpp/server/BUILD | 1 - test/cpp/server/server_builder_test.cc | 55 ---- .../distrib/check_namespace_qualification.py | 4 - .../check_redundant_namespace_qualifiers.py | 9 - tools/doxygen/Doxyfile.c++ | 2 - tools/doxygen/Doxyfile.c++.internal | 2 - tools/doxygen/Doxyfile.core | 1 - tools/doxygen/Doxyfile.core.internal | 1 - 34 files changed, 115 insertions(+), 615 deletions(-) delete mode 100644 include/grpc/passive_listener.h delete mode 100644 include/grpcpp/passive_listener.h diff --git a/BUILD b/BUILD index 7941edf3c42..894186b35f2 100644 --- a/BUILD +++ b/BUILD @@ -291,7 +291,6 @@ GRPC_PUBLIC_HDRS = [ "include/grpc/grpc_posix.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", - "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", @@ -453,7 +452,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/impl/service_type.h", "include/grpcpp/impl/status.h", "include/grpcpp/impl/sync.h", - "include/grpcpp/passive_listener.h", "include/grpcpp/resource_quota.h", "include/grpcpp/security/audit_logging.h", "include/grpcpp/security/tls_crl_provider.h", @@ -878,7 +876,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_public_hdrs", - hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, + hdrs = GRPC_PUBLIC_HDRS, external_deps = [ "absl/status:statusor", "absl/strings", @@ -2472,7 +2470,6 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_crl_provider", "//src/core:grpc_service_config", - "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:json", "//src/core:json_reader", @@ -2530,7 +2527,6 @@ grpc_cc_library( "grpc_security_base", "grpc_service_config_impl", "grpc_trace", - "grpc_transport_chttp2", "grpc_unsecure", "grpcpp_backend_metric_recorder", "grpcpp_call_metric_recorder", @@ -2552,7 +2548,6 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_insecure_credentials", "//src/core:grpc_service_config", - "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:ref_counted", "//src/core:resource_quota", diff --git a/CMakeLists.txt b/CMakeLists.txt index 131121baa1a..b2bb8d2151e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2742,7 +2742,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -3445,7 +3444,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -4315,7 +4313,6 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h - include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5056,7 +5053,6 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h - include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5506,7 +5502,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -26675,7 +26670,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h - test/core/event_engine/event_engine_test_utils.cc test/core/util/cmdline.cc test/core/util/fuzzer_util.cc test/core/util/grpc_profiler.cc @@ -26720,7 +26714,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) target_link_libraries(server_builder_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest - absl::check grpc++_unsecure grpc_test_util_unsecure ) diff --git a/Makefile b/Makefile index 5a7f90db9cc..30be778e03d 100644 --- a/Makefile +++ b/Makefile @@ -1776,7 +1776,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ - include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/Package.swift b/Package.swift index 22f0e7cac9f..ce9e5e1bed5 100644 --- a/Package.swift +++ b/Package.swift @@ -93,7 +93,6 @@ let package = Package( "include/grpc/impl/propagation_bits.h", "include/grpc/impl/slice_type.h", "include/grpc/load_reporting.h", - "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 0a699c30309..aa277f8adf6 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -197,7 +197,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -2186,7 +2185,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -3797,7 +3795,6 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h - - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4226,7 +4223,6 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h - - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4375,7 +4371,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -17396,7 +17391,6 @@ targets: build: test language: c++ headers: - - test/core/event_engine/event_engine_test_utils.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h - test/core/util/fuzzer_util.h @@ -17413,7 +17407,6 @@ targets: - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/simple_messages.proto - src/proto/grpc/testing/xds/v3/orca_load_report.proto - - test/core/event_engine/event_engine_test_utils.cc - test/core/util/cmdline.cc - test/core/util/fuzzer_util.cc - test/core/util/grpc_profiler.cc @@ -17426,7 +17419,6 @@ targets: - test/cpp/server/server_builder_test.cc deps: - gtest - - absl/log:check - grpc++_unsecure - grpc_test_util_unsecure platforms: diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 0ac465034a2..9114af3c0d9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -175,7 +175,6 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/service_type.h', 'include/grpcpp/impl/status.h', 'include/grpcpp/impl/sync.h', - 'include/grpcpp/passive_listener.h', 'include/grpcpp/resource_quota.h', 'include/grpcpp/security/audit_logging.h', 'include/grpcpp/security/auth_context.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b711dd5bc02..1624bceaeb2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -167,7 +167,6 @@ Pod::Spec.new do |s| 'include/grpc/impl/propagation_bits.h', 'include/grpc/impl/slice_type.h', 'include/grpc/load_reporting.h', - 'include/grpc/passive_listener.h', 'include/grpc/slice.h', 'include/grpc/slice_buffer.h', 'include/grpc/status.h', diff --git a/grpc.gemspec b/grpc.gemspec index 9283dd994ed..3a986b6d65e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -99,7 +99,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/propagation_bits.h ) s.files += %w( include/grpc/impl/slice_type.h ) s.files += %w( include/grpc/load_reporting.h ) - s.files += %w( include/grpc/passive_listener.h ) s.files += %w( include/grpc/slice.h ) s.files += %w( include/grpc/slice_buffer.h ) s.files += %w( include/grpc/status.h ) diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 30427e21d05..c9219532826 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -38,7 +38,6 @@ header "byte_buffer.h" header "impl/propagation_bits.h" header "impl/slice_type.h" header "load_reporting.h" - header "passive_listener.h" header "slice.h" header "slice_buffer.h" header "status.h" diff --git a/include/grpc/passive_listener.h b/include/grpc/passive_listener.h deleted file mode 100644 index 91fea25cc6a..00000000000 --- a/include/grpc/passive_listener.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2024 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef GRPC_PASSIVE_LISTENER_H -#define GRPC_PASSIVE_LISTENER_H - -#include - -#include -#include -#include - -namespace grpc_core { -class Server; - -namespace experimental { -class PassiveListenerImpl; - -/// -- EXPERIMENTAL API -- -/// Interface for used for Server Endpoint injection. -class PassiveListener { - public: - virtual ~PassiveListener() = default; - /// -- EXPERIMENTAL API -- - /// - /// Takes an Endpoint for an established connection, and treats it as if the - /// connection had been accepted by the server. - /// - /// The server must be started before endpoints can be accepted. - virtual absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) = 0; - - /// -- EXPERIMENTAL API -- - /// - /// Takes a connected file descriptor, and treats it as if the server had - /// accepted the connection itself. - /// - /// Returns a failure status if the server's active EventEngine does not - /// support Endpoint creation from fds. - virtual absl::Status AcceptConnectedFd(int fd) = 0; -}; - -} // namespace experimental -} // namespace grpc_core - -absl::Status grpc_server_add_passive_listener( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); - -#endif /* GRPC_PASSIVE_LISTENER_H */ diff --git a/include/grpcpp/passive_listener.h b/include/grpcpp/passive_listener.h deleted file mode 100644 index 8def9592b5e..00000000000 --- a/include/grpcpp/passive_listener.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2024 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef GRPCPP_PASSIVE_LISTENER_H -#define GRPCPP_PASSIVE_LISTENER_H - -#include - -namespace grpc { -namespace experimental { - -using grpc_core::experimental::PassiveListener; - -} // namespace experimental -} // namespace grpc - -#endif // GRPCPP_PASSIVE_LISTENER_H diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index e3f5c2bbbfe..fe8c546190d 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -84,7 +84,6 @@ class ServerCredentials : private grpc::internal::GrpcLibrary { // Needed for access to AddPortToServer. friend class Server; // Needed for access to c_creds_. - friend class ServerBuilder; friend std::shared_ptr grpc::XdsServerCredentials( const std::shared_ptr& fallback_credentials); diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index eceaa5c6c73..e6266a90d98 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -25,17 +25,13 @@ #include #include -#include -#include #include #include #include #include #include #include -#include #include -#include #include #include #include @@ -62,7 +58,6 @@ class ExternalConnectionAcceptorImpl; class CallbackGenericService; namespace experimental { - // EXPERIMENTAL API: // Interface for a grpc server to build transports with connections created out // of band. @@ -296,18 +291,6 @@ class ServerBuilder { void EnableCallMetricRecording( experimental::ServerMetricRecorder* server_metric_recorder = nullptr); - // Creates a passive listener for Server Endpoint injection. - /// - /// \a PasiveListener lets applications provide pre-established connections - /// to gRPC Servers. The server will behave as if it accepted the connection - /// itself on its own listening addresses. - /// - /// This can be called multiple times to create passive listeners with - /// different server credentials. - ServerBuilder& AddPassiveListener( - std::shared_ptr creds, - std::unique_ptr& passive_listener); - private: ServerBuilder* builder_; }; @@ -381,17 +364,6 @@ class ServerBuilder { private: friend class grpc::testing::ServerBuilderPluginTest; - struct UnstartedPassiveListener { - std::weak_ptr - passive_listener; - std::shared_ptr credentials; - UnstartedPassiveListener( - std::weak_ptr listener, - std::shared_ptr creds) - : passive_listener(std::move(listener)), - credentials(std::move(creds)) {} - }; - struct SyncServerSettings { SyncServerSettings() : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} @@ -416,7 +388,6 @@ class ServerBuilder { std::vector> options_; std::vector> services_; std::vector ports_; - std::vector unstarted_passive_listeners_; SyncServerSettings sync_server_settings_; diff --git a/package.xml b/package.xml index f90a7d2186d..6a184f74d73 100644 --- a/package.xml +++ b/package.xml @@ -81,7 +81,6 @@ - diff --git a/src/core/BUILD b/src/core/BUILD index 14577b9f67e..23040cc5fe8 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -6800,8 +6800,6 @@ grpc_cc_library( "connection_quota", "error", "error_utils", - "event_engine_extensions", - "event_engine_query_extensions", "grpc_insecure_credentials", "handshaker_registry", "iomgr_fwd", diff --git a/src/core/ext/transport/binder/server/binder_server.cc b/src/core/ext/transport/binder/server/binder_server.cc index 58d26b6949c..994d8f82cb8 100644 --- a/src/core/ext/transport/binder/server/binder_server.cc +++ b/src/core/ext/transport/binder/server/binder_server.cc @@ -159,7 +159,7 @@ class BinderServerListener : public Server::ListenerInterface { on_destroy_done_ = on_destroy_done; } - void Orphan() override { Unref(); } + void Orphan() override { delete this; } ~BinderServerListener() override { ExecCtx::Get()->Flush(); @@ -239,8 +239,9 @@ bool AddBinderPort(const std::string& addr, grpc_server* server, } std::string conn_id = addr.substr(kBinderUriScheme.size()); Server* core_server = Server::FromC(server); - core_server->AddListener(MakeOrphanable( - core_server, conn_id, std::move(factory), security_policy)); + core_server->AddListener( + OrphanablePtr(new BinderServerListener( + core_server, conn_id, std::move(factory), security_policy))); return true; } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index f3a9de5783c..c1022e95c43 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -102,8 +102,8 @@ absl::StatusOr ChaoticGoodServerListener::Bind( str.ok() ? str->c_str() : str.status().ToString().c_str()); } EventEngine::Listener::AcceptCallback accept_cb = - [self = RefAsSubclass()]( - std::unique_ptr ep, MemoryAllocator) { + [self = Ref()](std::unique_ptr ep, + MemoryAllocator) { ExecCtx exec_ctx; MutexLock lock(&self->mu_); if (self->shutdown_) return; @@ -148,8 +148,7 @@ absl::Status ChaoticGoodServerListener::StartListening() { ChaoticGoodServerListener::ActiveConnection::ActiveConnection( RefCountedPtr listener, std::unique_ptr endpoint) - : memory_allocator_(listener->memory_allocator_), - listener_(std::move(listener)) { + : memory_allocator_(listener->memory_allocator_), listener_(listener) { handshaking_state_ = MakeRefCounted(Ref()); handshaking_state_->Start(std::move(endpoint)); } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index a34fbee3f18..ed90dd45d1d 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -49,7 +49,9 @@ namespace grpc_core { namespace chaotic_good { -class ChaoticGoodServerListener final : public Server::ListenerInterface { +class ChaoticGoodServerListener final + : public Server::ListenerInterface, + public RefCounted { public: static absl::AnyInvocable DefaultConnectionIDGenerator() { return [bitgen = absl::BitGen()]() mutable { diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 4496189cd6a..2e97b207ed2 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -56,8 +55,6 @@ #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" -#include "src/core/lib/event_engine/extensions/supports_fd.h" -#include "src/core/lib/event_engine/query_extensions.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -67,7 +64,6 @@ #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/event_engine_shims/endpoint.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -96,11 +92,9 @@ #endif // GPR_SUPPORT_CHANNELS_FROM_FD namespace grpc_core { +namespace { -using grpc_event_engine::experimental::ChannelArgsEndpointConfig; -using grpc_event_engine::experimental::EventEngine; -using grpc_event_engine::experimental::EventEngineSupportsFdExtension; -using grpc_event_engine::experimental::QueryExtension; +using ::grpc_event_engine::experimental::EventEngine; const char kUnixUriPrefix[] = "unix:"; const char kUnixAbstractUriPrefix[] = "unix-abstract:"; @@ -117,23 +111,14 @@ class Chttp2ServerListener : public Server::ListenerInterface { Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier); - static Chttp2ServerListener* CreateForPassiveListener( - Server* server, const ChannelArgs& args, - std::shared_ptr passive_listener); - // Do not instantiate directly. Use one of the factory methods above. Chttp2ServerListener(Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier, - grpc_server_config_fetcher* config_fetcher, - std::shared_ptr - passive_listener = nullptr); + Chttp2ServerArgsModifier args_modifier); ~Chttp2ServerListener() override; void Start(Server* server, const std::vector* pollsets) override; - void AcceptConnectedEndpoint(std::unique_ptr endpoint); - channelz::ListenSocketNode* channelz_listen_socket_node() const override { return channelz_listen_socket_.get(); } @@ -143,8 +128,6 @@ class Chttp2ServerListener : public Server::ListenerInterface { void Orphan() override; private: - friend class experimental::PassiveListenerImpl; - class ConfigFetcherWatcher : public grpc_server_config_fetcher::WatcherInterface { public: @@ -251,8 +234,34 @@ class Chttp2ServerListener : public Server::ListenerInterface { static void DestroyListener(Server* /*server*/, void* arg, grpc_closure* destroy_done); - Server* const server_ = nullptr; - grpc_tcp_server* tcp_server_ = nullptr; + // The interface required by RefCountedPtr<> has been manually implemented + // here to take a ref on tcp_server_ instead. Note that, the handshaker + // needs tcp_server_ to exist for the lifetime of the handshake since it's + // needed by acceptor. Sharing refs between the listener and tcp_server_ is + // just an optimization to avoid taking additional refs on the listener, + // since TcpServerShutdownComplete already holds a ref to the listener. + void IncrementRefCount() { grpc_tcp_server_ref(tcp_server_); } + void IncrementRefCount(const DebugLocation& /* location */, + const char* /* reason */) { + IncrementRefCount(); + } + + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { + IncrementRefCount(); + return RefCountedPtr(this); + } + GRPC_MUST_USE_RESULT RefCountedPtr Ref( + const DebugLocation& /* location */, const char* /* reason */) { + return Ref(); + } + + void Unref() { grpc_tcp_server_unref(tcp_server_); } + void Unref(const DebugLocation& /* location */, const char* /* reason */) { + Unref(); + } + + Server* const server_; + grpc_tcp_server* tcp_server_; grpc_resolved_address resolved_address_; Chttp2ServerArgsModifier const args_modifier_; ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr; @@ -275,10 +284,6 @@ class Chttp2ServerListener : public Server::ListenerInterface { RefCountedPtr channelz_listen_socket_; MemoryQuotaRefPtr memory_quota_; ConnectionQuotaRefPtr connection_quota_; - grpc_server_config_fetcher* config_fetcher_ = nullptr; - // TODO(yashykt): consider using absl::variant<> to minimize memory usage for - // disjoint cases where different fields are used. - std::shared_ptr passive_listener_; }; // @@ -375,17 +380,13 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState( handshake_mgr_(MakeRefCounted()), deadline_(GetConnectionDeadline(args)), interested_parties_(grpc_pollset_set_create()) { - if (accepting_pollset != nullptr) { - grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); - } + grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); CoreConfiguration::Get().handshaker_registry().AddHandshakers( HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get()); } Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() { - if (accepting_pollset_ != nullptr) { - grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); - } + grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); grpc_pollset_set_destroy(interested_parties_); gpr_free(acceptor_); } @@ -707,82 +708,83 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() { grpc_error_handle Chttp2ServerListener::Create( Server* server, grpc_resolved_address* addr, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier, int* port_num) { - // Create Chttp2ServerListener. - OrphanablePtr listener = - MakeOrphanable(server, args, args_modifier, - server->config_fetcher()); - // The tcp_server will be unreffed when the listener is orphaned, which could - // be at the end of this function if the listener was not added to the - // server's set of listeners. - grpc_error_handle error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), - OnAccept, listener.get(), &listener->tcp_server_); - if (!error.ok()) return error; - if (listener->config_fetcher_ != nullptr) { - listener->resolved_address_ = *addr; - // TODO(yashykt): Consider binding so as to be able to return the port - // number. - } else { - error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); + Chttp2ServerListener* listener = nullptr; + // The bulk of this method is inside of a lambda to make cleanup + // easier without using goto. + grpc_error_handle error = [&]() { + grpc_error_handle error; + // Create Chttp2ServerListener. + listener = new Chttp2ServerListener(server, args, args_modifier); + error = grpc_tcp_server_create( + &listener->tcp_server_shutdown_complete_, + grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), + OnAccept, listener, &listener->tcp_server_); if (!error.ok()) return error; - } - // Create channelz node. - if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) - .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { - auto string_address = grpc_sockaddr_to_uri(addr); - if (!string_address.ok()) { - return GRPC_ERROR_CREATE(string_address.status().ToString()); + if (server->config_fetcher() != nullptr) { + listener->resolved_address_ = *addr; + // TODO(yashykt): Consider binding so as to be able to return the port + // number. + } else { + error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); + if (!error.ok()) return error; + } + // Create channelz node. + if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) + .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { + auto string_address = grpc_sockaddr_to_uri(addr); + if (!string_address.ok()) { + return GRPC_ERROR_CREATE(string_address.status().ToString()); + } + listener->channelz_listen_socket_ = + MakeRefCounted( + *string_address, + absl::StrCat("chttp2 listener ", *string_address)); + } + // Register with the server only upon success + server->AddListener(OrphanablePtr(listener)); + return absl::OkStatus(); + }(); + if (!error.ok()) { + if (listener != nullptr) { + if (listener->tcp_server_ != nullptr) { + // listener is deleted when tcp_server_ is shutdown. + grpc_tcp_server_unref(listener->tcp_server_); + } else { + delete listener; + } } - listener->channelz_listen_socket_ = - MakeRefCounted( - *string_address, absl::StrCat("chttp2 listener ", *string_address)); } - // Register with the server only upon success - server->AddListener(std::move(listener)); - return absl::OkStatus(); + return error; } grpc_error_handle Chttp2ServerListener::CreateWithAcceptor( Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier) { - auto listener = MakeOrphanable( - server, args, args_modifier, server->config_fetcher()); + Chttp2ServerListener* listener = + new Chttp2ServerListener(server, args, args_modifier); grpc_error_handle error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), - OnAccept, listener.get(), &listener->tcp_server_); - if (!error.ok()) return error; + &listener->tcp_server_shutdown_complete_, + grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), + OnAccept, listener, &listener->tcp_server_); + if (!error.ok()) { + delete listener; + return error; + } // TODO(yangg) channelz TcpServerFdHandler** arg_val = args.GetPointer(name); *arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_); - server->AddListener(std::move(listener)); + server->AddListener(OrphanablePtr(listener)); return absl::OkStatus(); } -Chttp2ServerListener* Chttp2ServerListener::CreateForPassiveListener( - Server* server, const ChannelArgs& args, - std::shared_ptr passive_listener) { - // TODO(hork): figure out how to handle channelz in this case - auto listener = MakeOrphanable( - server, args, /*args_modifier=*/ - [](const ChannelArgs& args, grpc_error_handle*) { return args; }, nullptr, - std::move(passive_listener)); - auto listener_ptr = listener.get(); - server->AddListener(std::move(listener)); - return listener_ptr; -} - Chttp2ServerListener::Chttp2ServerListener( Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier, - grpc_server_config_fetcher* config_fetcher, - std::shared_ptr passive_listener) + Chttp2ServerArgsModifier args_modifier) : server_(server), args_modifier_(args_modifier), args_(args), memory_quota_(args.GetObject()->memory_quota()), - connection_quota_(MakeRefCounted()), - config_fetcher_(config_fetcher), - passive_listener_(std::move(passive_listener)) { + connection_quota_(MakeRefCounted()) { auto max_allowed_incoming_connections = args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS); if (max_allowed_incoming_connections.has_value()) { @@ -797,9 +799,6 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Flush queued work before destroying handshaker factory, since that // may do a synchronous unref. ExecCtx::Get()->Flush(); - if (passive_listener_ != nullptr) { - passive_listener_->ListenerDestroyed(); - } if (on_destroy_done_ != nullptr) { ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus()); ExecCtx::Get()->Flush(); @@ -809,11 +808,10 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Server callback: start listening on our ports void Chttp2ServerListener::Start( Server* /*server*/, const std::vector* /* pollsets */) { - if (config_fetcher_ != nullptr) { - auto watcher = std::make_unique( - RefAsSubclass()); + if (server_->config_fetcher() != nullptr) { + auto watcher = std::make_unique(Ref()); config_fetcher_watcher_ = watcher.get(); - config_fetcher_->StartWatch( + server_->config_fetcher()->StartWatch( grpc_sockaddr_to_string(&resolved_address_, false).value(), std::move(watcher)); } else { @@ -827,9 +825,7 @@ void Chttp2ServerListener::Start( } void Chttp2ServerListener::StartListening() { - if (tcp_server_ != nullptr) { - grpc_tcp_server_start(tcp_server_, &server_->pollsets()); - } + grpc_tcp_server_start(tcp_server_, &server_->pollsets()); } void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { @@ -837,12 +833,6 @@ void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { on_destroy_done_ = on_destroy_done; } -void Chttp2ServerListener::AcceptConnectedEndpoint( - std::unique_ptr endpoint) { - OnAccept(this, grpc_event_engine_endpoint_create(std::move(endpoint)), - /*accepting_pollset=*/nullptr, /*acceptor=*/nullptr); -} - void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor) { @@ -867,7 +857,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, endpoint_cleanup(error); return; } - if (self->config_fetcher_ != nullptr) { + if (self->server_->config_fetcher() != nullptr) { if (connection_manager == nullptr) { grpc_error_handle error = GRPC_ERROR_CREATE( "No ConnectionManager configured. Closing connection."); @@ -908,7 +898,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, // heap-use-after-free issues where `Ref()` is invoked when the ref of // tcp_server_ has already reached 0. (Ref() implementation of // Chttp2ServerListener is grpc_tcp_server_ref().) - listener_ref = self->RefAsSubclass(); + listener_ref = self->Ref(); self->connections_.emplace(connection.get(), std::move(connection)); } } @@ -923,7 +913,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete( void* arg, grpc_error_handle /*error*/) { Chttp2ServerListener* self = static_cast(arg); self->channelz_listen_socket_.reset(); - self->Unref(); + delete self; } // Server callback: destroy the tcp listener (so we don't generate further @@ -932,8 +922,7 @@ void Chttp2ServerListener::Orphan() { // Cancel the watch before shutting down so as to avoid holding a ref to the // listener in the watcher. if (config_fetcher_watcher_ != nullptr) { - GPR_ASSERT(config_fetcher_ != nullptr); - config_fetcher_->CancelWatch(config_fetcher_watcher_); + server_->config_fetcher()->CancelWatch(config_fetcher_watcher_); } std::map> connections; grpc_tcp_server* tcp_server; @@ -951,14 +940,12 @@ void Chttp2ServerListener::Orphan() { } tcp_server = tcp_server_; } - if (tcp_server != nullptr) { - grpc_tcp_server_shutdown_listeners(tcp_server); - grpc_tcp_server_unref(tcp_server); - } else { - Unref(); - } + grpc_tcp_server_shutdown_listeners(tcp_server); + grpc_tcp_server_unref(tcp_server); } +} // namespace + // // Chttp2ServerAddPort() // @@ -1059,50 +1046,6 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args, } } // namespace - -namespace experimental { - -absl::Status PassiveListenerImpl::AcceptConnectedEndpoint( - std::unique_ptr endpoint) { - GPR_ASSERT(server_ != nullptr); - RefCountedPtr listener; - { - MutexLock lock(&mu_); - if (listener_ != nullptr) { - listener = - listener_->RefIfNonZero().TakeAsSubclass(); - } - } - if (listener == nullptr) { - return absl::UnavailableError("passive listener already shut down"); - } - ExecCtx exec_ctx; - listener->AcceptConnectedEndpoint(std::move(endpoint)); - return absl::OkStatus(); -} - -absl::Status PassiveListenerImpl::AcceptConnectedFd(int fd) { - GPR_ASSERT(server_ != nullptr); - ExecCtx exec_ctx; - auto& args = server_->channel_args(); - auto* supports_fd = QueryExtension( - /*engine=*/args.GetObjectRef().get()); - if (supports_fd == nullptr) { - return absl::UnimplementedError( - "The server's EventEngine does not support adding endpoints from " - "connected file descriptors."); - } - auto endpoint = - supports_fd->CreateEndpointFromFd(fd, ChannelArgsEndpointConfig(args)); - return AcceptConnectedEndpoint(std::move(endpoint)); -} - -void PassiveListenerImpl::ListenerDestroyed() { - MutexLock lock(&mu_); - listener_ = nullptr; -} - -} // namespace experimental } // namespace grpc_core int grpc_server_add_http2_port(grpc_server* server, const char* addr, @@ -1200,31 +1143,3 @@ void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */, } #endif // GPR_SUPPORT_CHANNELS_FROM_FD - -absl::Status grpc_server_add_passive_listener( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener) { - grpc_core::ExecCtx exec_ctx; - GRPC_API_TRACE("grpc_server_add_passive_listener(server=%p, credentials=%p)", - 2, (server, credentials)); - // Create security context. - if (credentials == nullptr) { - return absl::UnavailableError( - "No credentials specified for passive listener"); - } - auto sc = credentials->create_security_connector(grpc_core::ChannelArgs()); - if (sc == nullptr) { - return absl::UnavailableError( - absl::StrCat("Unable to create secure server with credentials of type ", - credentials->type().name())); - } - auto args = server->channel_args() - .SetObject(credentials->Ref()) - .SetObject(std::move(sc)); - passive_listener->listener_ = - grpc_core::Chttp2ServerListener::CreateForPassiveListener( - server, args, passive_listener); - passive_listener->server_ = server->Ref(); - return absl::OkStatus(); -} diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index 0e296873b3d..f7eb7a23c66 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -21,7 +21,6 @@ #include -#include #include #include "src/core/lib/channel/channel_args.h" @@ -43,38 +42,6 @@ grpc_error_handle Chttp2ServerAddPort( Server* server, const char* addr, const ChannelArgs& args, Chttp2ServerArgsModifier connection_args_modifier, int* port_num); -class Chttp2ServerListener; -namespace experimental { - -// An implementation of the public C++ passive listener interface. -// The server builder holds a weak_ptr to one of these objects, and the -// application owns the instance. -class PassiveListenerImpl final : public PassiveListener { - public: - absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) override ABSL_LOCKS_EXCLUDED(mu_); - - absl::Status AcceptConnectedFd(GRPC_UNUSED int fd) override - ABSL_LOCKS_EXCLUDED(mu_); - - void ListenerDestroyed() ABSL_LOCKS_EXCLUDED(mu_); - - private: - // note: the grpc_core::Server redundant namespace qualification is - // required for older gcc versions. - friend absl::Status(::grpc_server_add_passive_listener)( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); - - Mutex mu_; - // Data members will be populated when initialized. - RefCountedPtr server_; - Chttp2ServerListener* listener_; -}; - -} // namespace experimental } // namespace grpc_core #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H diff --git a/src/core/lib/event_engine/extensions/supports_fd.h b/src/core/lib/event_engine/extensions/supports_fd.h index 30f0d2ad0e6..66ea1c2b345 100644 --- a/src/core/lib/event_engine/extensions/supports_fd.h +++ b/src/core/lib/event_engine/extensions/supports_fd.h @@ -112,13 +112,6 @@ class EventEngineSupportsFdExtension { int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) = 0; - /// Creates an EventEngine::Endpoint from an fd which is already assumed to be - /// connected to a remote peer. See \a CreatePosixEndpointFromFd for details. - /// This has the same behavior, but the \a memory_allocator is taken from the - /// EndpointConfig's resource quota. - virtual std::unique_ptr CreateEndpointFromFd( - int fd, const EndpointConfig& config) = 0; - /// Called when the posix listener has accepted a new client connection. /// \a listener_fd - The listening socket fd that accepted the new client /// connection. diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc index 0ac3dfcebfe..275e0dcbf65 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -661,7 +661,7 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) { #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING - GPR_ASSERT(fd > 0); + GPR_DEBUG_ASSERT(fd > 0); PosixEventPoller* poller = poller_manager_->Poller(); GPR_DEBUG_ASSERT(poller != nullptr); EventHandle* handle = @@ -676,22 +676,6 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING } -std::unique_ptr PosixEventEngine::CreateEndpointFromFd( - int fd, const EndpointConfig& config) { - auto options = TcpOptionsFromEndpointConfig(config); - MemoryAllocator allocator; - if (options.memory_allocator_factory != nullptr) { - return CreatePosixEndpointFromFd( - fd, config, - options.memory_allocator_factory->CreateMemoryAllocator( - absl::StrCat("allocator:", fd))); - } - return CreatePosixEndpointFromFd( - fd, config, - options.resource_quota->memory_quota()->CreateMemoryAllocator( - absl::StrCat("allocator:", fd))); -} - absl::StatusOr> PosixEventEngine::CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.h b/src/core/lib/event_engine/posix_engine/posix_engine.h index ea426c379c9..257cd6b34b5 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -172,8 +172,6 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, std::unique_ptr CreatePosixEndpointFromFd( int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) override; - std::unique_ptr CreateEndpointFromFd( - int fd, const EndpointConfig& config) override; absl::StatusOr> CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 66f7b6683e0..356bcc40269 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -39,7 +39,6 @@ #include "absl/types/optional.h" #include -#include #include #include #include @@ -75,9 +74,6 @@ "grpc.server.max_pending_requests_hard_limit" namespace grpc_core { -namespace experimental { -class PassiveListenerImpl; -} // namespace experimental extern TraceFlag grpc_server_channel_trace; @@ -116,7 +112,7 @@ class Server : public ServerInterface, /// Interface for listeners. /// Implementations must override the Orphan() method, which should stop /// listening and initiate destruction of the listener. - class ListenerInterface : public InternallyRefCounted { + class ListenerInterface : public Orphanable { public: ~ListenerInterface() override = default; @@ -216,14 +212,6 @@ class Server : public ServerInterface, void SendGoaways() ABSL_LOCKS_EXCLUDED(mu_global_, mu_call_); private: - // note: the grpc_core::Server redundant namespace qualification is - // required for older gcc versions. - // TODO(yashykt): eliminate this friend statement as part of your upcoming - // server listener refactoring. - friend absl::Status(::grpc_server_add_passive_listener)( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); struct RequestedCall; class RequestMatcherInterface; diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index d79f3df4d1f..6d5924404f4 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -15,6 +15,7 @@ // limitations under the License. // // + #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -45,38 +45,11 @@ #include #include -#include "src/core/ext/transport/chttp2/server/chttp2_server.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/surface/server.h" #include "src/cpp/server/external_connection_acceptor_impl.h" namespace grpc { -namespace { - -// A PIMPL wrapper class that owns the only ref to the passive listener -// implementation. This is returned to the application. -class PassiveListenerOwner final - : public grpc_core::experimental::PassiveListener { - public: - explicit PassiveListenerOwner(std::shared_ptr listener) - : listener_(std::move(listener)) {} - - absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) override { - return listener_->AcceptConnectedEndpoint(std::move(endpoint)); - } - - absl::Status AcceptConnectedFd(int fd) override { - return listener_->AcceptConnectedFd(fd); - } - - private: - std::shared_ptr listener_; -}; - -} // namespace static std::vector (*)()>* g_plugin_factory_list; @@ -250,18 +223,6 @@ ServerBuilder& ServerBuilder::SetResourceQuota( return *this; } -ServerBuilder& ServerBuilder::experimental_type::AddPassiveListener( - std::shared_ptr creds, - std::unique_ptr& passive_listener) { - auto core_passive_listener = - std::make_shared(); - builder_->unstarted_passive_listeners_.emplace_back(core_passive_listener, - std::move(creds)); - passive_listener = - std::make_unique(std::move(core_passive_listener)); - return *builder_; -} - ServerBuilder& ServerBuilder::AddListeningPort( const std::string& addr_uri, std::shared_ptr creds, int* selected_port) { @@ -435,26 +396,6 @@ std::unique_ptr ServerBuilder::BuildAndStart() { cq->RegisterServer(server.get()); } - for (auto& unstarted_listener : unstarted_passive_listeners_) { - has_frequently_polled_cqs = true; - auto passive_listener = unstarted_listener.passive_listener.lock(); - auto* core_server = grpc_core::Server::FromC(server->c_server()); - if (passive_listener != nullptr) { - auto* creds = unstarted_listener.credentials->c_creds(); - if (creds == nullptr) { - gpr_log(GPR_ERROR, "Credentials missing for PassiveListener"); - return nullptr; - } - auto success = grpc_server_add_passive_listener( - core_server, creds, std::move(passive_listener)); - if (!success.ok()) { - gpr_log(GPR_ERROR, "Failed to create a passive listener: %s", - success.ToString().c_str()); - return nullptr; - } - } - } - if (!has_frequently_polled_cqs) { gpr_log(GPR_ERROR, "At least one of the completion queues must be frequently polled"); diff --git a/test/core/event_engine/event_engine_test_utils.h b/test/core/event_engine/event_engine_test_utils.h index debef7a0449..67bbe42d35d 100644 --- a/test/core/event_engine/event_engine_test_utils.h +++ b/test/core/event_engine/event_engine_test_utils.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -160,70 +159,6 @@ class NotifyOnDelete { grpc_core::Notification* signal_; }; -// An endpoint implementation that supports Read and Write via std::threads. -// Passing a grpc_core::Notification will allow owners to know when all -// in-flight callbacks have been run, and all endpoint state has been destroyed. -class ThreadedNoopEndpoint : public EventEngine::Endpoint { - public: - explicit ThreadedNoopEndpoint(grpc_core::Notification* destroyed) - : state_(std::make_shared(destroyed)) {} - ~ThreadedNoopEndpoint() override { - std::thread deleter([state = state_]() { - CleanupThread(state->read); - CleanupThread(state->write); - }); - deleter.detach(); - } - - bool Read(absl::AnyInvocable on_read, SliceBuffer* buffer, - const ReadArgs* /* args */) override { - buffer->Clear(); - CleanupThread(state_->read); - state_->read = new std::thread([cb = std::move(on_read)]() mutable { - cb(absl::UnknownError("test")); - }); - return false; - } - - bool Write(absl::AnyInvocable on_writable, - SliceBuffer* data, const WriteArgs* /* args */) override { - data->Clear(); - CleanupThread(state_->write); - state_->write = new std::thread([cb = std::move(on_writable)]() mutable { - cb(absl::UnknownError("test")); - }); - return false; - } - - const EventEngine::ResolvedAddress& GetPeerAddress() const override { - return peer_; - } - - const EventEngine::ResolvedAddress& GetLocalAddress() const override { - return local_; - } - - private: - struct EndpointState { - explicit EndpointState(grpc_core::Notification* deleter) - : delete_notifier_(deleter) {} - std::thread* read = nullptr; - std::thread* write = nullptr; - NotifyOnDelete delete_notifier_; - }; - - static void CleanupThread(std::thread* thd) { - if (thd != nullptr) { - thd->join(); - delete thd; - } - } - - std::shared_ptr state_; - EventEngine::ResolvedAddress peer_; - EventEngine::ResolvedAddress local_; -}; - } // namespace experimental } // namespace grpc_event_engine diff --git a/test/cpp/server/BUILD b/test/cpp/server/BUILD index 063e6cf2a4c..0927de6c7a0 100644 --- a/test/cpp/server/BUILD +++ b/test/cpp/server/BUILD @@ -28,7 +28,6 @@ grpc_cc_test( deps = [ "//:grpc++_unsecure", "//src/proto/grpc/testing:echo_proto", - "//test/core/event_engine:event_engine_test_utils", "//test/core/util:grpc_test_util_base", "//test/core/util:grpc_test_util_unsecure", ], diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc index 476eb41686c..14eaa5efb7d 100644 --- a/test/cpp/server/server_builder_test.cc +++ b/test/cpp/server/server_builder_test.cc @@ -16,19 +16,14 @@ // // -#include - #include -#include #include #include #include #include -#include "src/core/lib/gprpp/notification.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/event_engine/event_engine_test_utils.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -88,56 +83,6 @@ TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { nullptr); } -TEST_F(ServerBuilderTest, AddPassiveListener) { - std::unique_ptr passive_listener; - auto server = - ServerBuilder() - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - server->Shutdown(); -} - -TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedFd) { - std::unique_ptr passive_listener; - ServerBuilder builder; - auto cq = builder.AddCompletionQueue(); - // TODO(hork): why is the service necessary? Queue isn't drained otherwise. - auto server = - builder.RegisterService(&g_service) - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - ASSERT_NE(server.get(), nullptr); -#ifdef GPR_SUPPORT_CHANNELS_FROM_FD - int fd = socket(AF_INET, SOCK_STREAM, 0); - auto accept_status = passive_listener->AcceptConnectedFd(fd); - ASSERT_TRUE(accept_status.ok()) << accept_status; -#else - int fd = -1; - auto accept_status = passive_listener->AcceptConnectedFd(fd); - ASSERT_FALSE(accept_status.ok()) << accept_status; -#endif - server->Shutdown(); -} - -TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) { - std::unique_ptr passive_listener; - auto server = - ServerBuilder() - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - grpc_core::Notification endpoint_destroyed; - auto success = passive_listener->AcceptConnectedEndpoint( - std::make_unique( - &endpoint_destroyed)); - ASSERT_TRUE(success.ok()) - << "AcceptConnectedEndpoint failure: " << success.ToString(); - endpoint_destroyed.WaitForNotification(); - server->Shutdown(); -} - } // namespace } // namespace grpc diff --git a/tools/distrib/check_namespace_qualification.py b/tools/distrib/check_namespace_qualification.py index bf13f0cd729..6634d8b8830 100755 --- a/tools/distrib/check_namespace_qualification.py +++ b/tools/distrib/check_namespace_qualification.py @@ -77,10 +77,6 @@ IGNORED_FILES = [ "src/core/lib/gprpp/global_config_env.h", "src/core/lib/profiling/timers.h", "src/core/lib/gprpp/crash.h", - # The grpc_core::Server redundant namespace qualification is required for - # older gcc versions. - "src/core/ext/transport/chttp2/server/chttp2_server.h", - "src/core/lib/surface/server.h", ] # find our home diff --git a/tools/distrib/check_redundant_namespace_qualifiers.py b/tools/distrib/check_redundant_namespace_qualifiers.py index db89796db6f..0322332209b 100755 --- a/tools/distrib/check_redundant_namespace_qualifiers.py +++ b/tools/distrib/check_redundant_namespace_qualifiers.py @@ -21,13 +21,6 @@ import os import re import sys -IGNORED_FILES = [ - # note: the grpc_core::Server redundant namespace qualification is required - # for older gcc versions. - "src/core/ext/transport/chttp2/server/chttp2_server.h", - "src/core/lib/surface/server.h", -] - def find_closing_mustache(contents, initial_depth): """Find the closing mustache for a given number of open mustaches.""" @@ -173,8 +166,6 @@ for config in _CONFIGURATION: for file in files: if file.endswith(".cc") or file.endswith(".h"): path = os.path.join(root, file) - if path in IGNORED_FILES: - continue try: with open(path) as f: contents = f.read() diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c630913e944..6e0f4316174 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ -include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index b2b6d5cf0f8..45745a6b3c8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ -include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 42c1ae40ce8..224d9f2d10b 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e9a74dd745e..73cb5cdb1c6 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ From fa248b1fe807b21055d7df607a0cf67ef6f3d96f Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 18 Apr 2024 09:43:18 -0700 Subject: [PATCH 24/45] [handshaker] add new priority as a temporary hack PiperOrigin-RevId: 626063899 --- src/core/lib/transport/handshaker_factory.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/lib/transport/handshaker_factory.h b/src/core/lib/transport/handshaker_factory.h index aa2f3e45492..79c4b005f4e 100644 --- a/src/core/lib/transport/handshaker_factory.h +++ b/src/core/lib/transport/handshaker_factory.h @@ -58,6 +58,22 @@ class HandshakerFactory { // Handshakers that are responsible for post connect security handshakes. // Applicable for both Client and Server handshakers. kSecurityHandshakers, + // TEMPORARY HACK -- DO NOT USE + // Currently, handshakers that need to hijack the endpoint's fd and + // exit early (which generally run at priority kSecurityHandshakers) + // need to call grpc_tcp_destroy_and_release_fd(), which asserts + // that the endpoint is an iomgr endpoint. If another handshaker + // has wrapped the endpoint before then, this assertion fails. So + // for now, we introduce a new priority here for handshakers that + // need to wrap the endpoint, to make sure that they run after + // handshakers that hijack the fd and exit early. + // TODO(hork): As part of migrating to the EventEngine endpoint API, + // remove this priority. In the EE API, handshakers that want to + // hijack the fd will do so via the query interface, so we can just + // have any wrapper endpoints forward query interfaces to the wrapped + // endpoint, so that it's not a problem if the endpoint is wrapped + // before a handshaker needs to hijack the fd. + kTemporaryHackDoNotUseEndpointWrappingHandshakers, }; virtual void AddHandshakers(const ChannelArgs& args, From 108848ae203b5ff73a544e39e0193e8773ccf8b5 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:22:50 -0700 Subject: [PATCH 25/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36368) grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36368 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36368 from tanvi-jagtap:tjagtap_test_02 0072bd885476d5ae72a23b2e0421fb6d286f9cb9 PiperOrigin-RevId: 626114257 --- CMakeLists.txt | 5 + build_autogenerated.yaml | 5 + test/core/tsi/BUILD | 1 + test/core/tsi/transport_security_test_lib.cc | 222 ++++++++++--------- 4 files changed, 123 insertions(+), 110 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2bb8d2151e..bce2fd580fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6608,6 +6608,7 @@ target_include_directories(alts_frame_protector_test target_link_libraries(alts_frame_protector_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -11880,6 +11881,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) target_link_libraries(crl_ssl_transport_security_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -13743,6 +13745,7 @@ target_include_directories(fake_transport_security_test target_link_libraries(fake_transport_security_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -28423,6 +28426,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) target_link_libraries(ssl_transport_security_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -28468,6 +28472,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) target_link_libraries(ssl_transport_security_utils_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index aa277f8adf6..0418b6ae26a 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -5492,6 +5492,7 @@ targets: - test/core/tsi/transport_security_test_lib.cc deps: - gtest + - absl/log:check - grpc_test_util - name: alts_grpc_record_protocol_test gtest: true @@ -8476,6 +8477,7 @@ targets: - test/core/tsi/transport_security_test_lib.cc deps: - gtest + - absl/log:check - grpc_test_util platforms: - linux @@ -9476,6 +9478,7 @@ targets: - test/core/tsi/transport_security_test_lib.cc deps: - gtest + - absl/log:check - grpc_test_util - name: fd_posix_test gtest: true @@ -18302,6 +18305,7 @@ targets: - test/core/tsi/transport_security_test_lib.cc deps: - gtest + - absl/log:check - grpc_test_util platforms: - linux @@ -18318,6 +18322,7 @@ targets: - test/core/tsi/transport_security_test_lib.cc deps: - gtest + - absl/log:check - grpc_test_util platforms: - linux diff --git a/test/core/tsi/BUILD b/test/core/tsi/BUILD index fcf97c83eca..3035e3c7415 100644 --- a/test/core/tsi/BUILD +++ b/test/core/tsi/BUILD @@ -26,6 +26,7 @@ grpc_cc_library( srcs = ["transport_security_test_lib.cc"], hdrs = ["transport_security_test_lib.h"], external_deps = [ + "absl/log:check", "libssl", "libcrypto", ], diff --git a/test/core/tsi/transport_security_test_lib.cc b/test/core/tsi/transport_security_test_lib.cc index a0be6edf466..27064d65724 100644 --- a/test/core/tsi/transport_security_test_lib.cc +++ b/test/core/tsi/transport_security_test_lib.cc @@ -31,6 +31,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -67,8 +69,8 @@ typedef struct handshaker_args { static handshaker_args* handshaker_args_create(tsi_test_fixture* fixture, bool is_client) { - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->config != nullptr); + CHECK_NE(fixture, nullptr); + CHECK_NE(fixture->config, nullptr); handshaker_args* args = new handshaker_args(); args->fixture = fixture; args->handshake_buffer_size = fixture->handshake_buffer_size; @@ -87,9 +89,9 @@ static void handshaker_args_destroy(handshaker_args* args) { static void do_handshaker_next(handshaker_args* args); static void setup_handshakers(tsi_test_fixture* fixture) { - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->vtable != nullptr); - GPR_ASSERT(fixture->vtable->setup_handshakers != nullptr); + CHECK_NE(fixture, nullptr); + CHECK_NE(fixture->vtable, nullptr); + CHECK_NE(fixture->vtable->setup_handshakers, nullptr); fixture->vtable->setup_handshakers(fixture); } @@ -102,20 +104,20 @@ static void check_unused_bytes(tsi_test_fixture* fixture) { : fixture->server_result; const unsigned char* bytes = nullptr; size_t bytes_size = 0; - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes( - result_with_unused_bytes, &bytes, &bytes_size) == TSI_OK); - GPR_ASSERT(bytes_size == strlen(TSI_TEST_UNUSED_BYTES)); - GPR_ASSERT(memcmp(bytes, TSI_TEST_UNUSED_BYTES, bytes_size) == 0); - GPR_ASSERT(tsi_handshaker_result_get_unused_bytes( - result_without_unused_bytes, &bytes, &bytes_size) == TSI_OK); - GPR_ASSERT(bytes_size == 0); - GPR_ASSERT(bytes == nullptr); + CHECK(tsi_handshaker_result_get_unused_bytes(result_with_unused_bytes, &bytes, + &bytes_size) == TSI_OK); + CHECK_EQ(bytes_size, strlen(TSI_TEST_UNUSED_BYTES)); + CHECK_EQ(memcmp(bytes, TSI_TEST_UNUSED_BYTES, bytes_size), 0); + CHECK(tsi_handshaker_result_get_unused_bytes(result_without_unused_bytes, + &bytes, &bytes_size) == TSI_OK); + CHECK_EQ(bytes_size, 0u); + CHECK_EQ(bytes, nullptr); } static void check_handshake_results(tsi_test_fixture* fixture) { - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->vtable != nullptr); - GPR_ASSERT(fixture->vtable->check_handshaker_peers != nullptr); + CHECK_NE(fixture, nullptr); + CHECK_NE(fixture->vtable, nullptr); + CHECK_NE(fixture->vtable->check_handshaker_peers, nullptr); // Check handshaker peers. fixture->vtable->check_handshaker_peers(fixture); // Check unused bytes. @@ -135,24 +137,25 @@ static void check_handshake_results(tsi_test_fixture* fixture) { static void send_bytes_to_peer(tsi_test_channel* test_channel, const unsigned char* buf, size_t buf_size, bool is_client) { - GPR_ASSERT(test_channel != nullptr); - GPR_ASSERT(buf != nullptr); + CHECK_NE(test_channel, nullptr); + CHECK_NE(buf, nullptr); uint8_t* channel = is_client ? test_channel->server_channel : test_channel->client_channel; - GPR_ASSERT(channel != nullptr); + CHECK_NE(channel, nullptr); size_t* bytes_written = is_client ? &test_channel->bytes_written_to_server_channel : &test_channel->bytes_written_to_client_channel; - GPR_ASSERT(bytes_written != nullptr); - GPR_ASSERT(*bytes_written + buf_size <= TSI_TEST_DEFAULT_CHANNEL_SIZE); + CHECK_NE(bytes_written, nullptr); + CHECK_LE(*bytes_written + buf_size, + static_cast(TSI_TEST_DEFAULT_CHANNEL_SIZE)); // Write data to channel. memcpy(channel + *bytes_written, buf, buf_size); *bytes_written += buf_size; } static void maybe_append_unused_bytes(handshaker_args* args) { - GPR_ASSERT(args != nullptr); - GPR_ASSERT(args->fixture != nullptr); + CHECK_NE(args, nullptr); + CHECK_NE(args->fixture, nullptr); tsi_test_fixture* fixture = args->fixture; if (fixture->test_unused_bytes && !args->appended_unused_bytes) { args->appended_unused_bytes = true; @@ -170,20 +173,20 @@ static void maybe_append_unused_bytes(handshaker_args* args) { static void receive_bytes_from_peer(tsi_test_channel* test_channel, unsigned char** buf, size_t* buf_size, bool is_client) { - GPR_ASSERT(test_channel != nullptr); - GPR_ASSERT(*buf != nullptr); - GPR_ASSERT(buf_size != nullptr); + CHECK_NE(test_channel, nullptr); + CHECK_NE(*buf, nullptr); + CHECK_NE(buf_size, nullptr); uint8_t* channel = is_client ? test_channel->client_channel : test_channel->server_channel; - GPR_ASSERT(channel != nullptr); + CHECK_NE(channel, nullptr); size_t* bytes_read = is_client ? &test_channel->bytes_read_from_client_channel : &test_channel->bytes_read_from_server_channel; size_t* bytes_written = is_client ? &test_channel->bytes_written_to_client_channel : &test_channel->bytes_written_to_server_channel; - GPR_ASSERT(bytes_read != nullptr); - GPR_ASSERT(bytes_written != nullptr); + CHECK_NE(bytes_read, nullptr); + CHECK_NE(bytes_written, nullptr); size_t to_read = *buf_size < *bytes_written - *bytes_read ? *buf_size : *bytes_written - *bytes_read; @@ -197,16 +200,16 @@ void tsi_test_frame_protector_send_message_to_peer( tsi_test_frame_protector_config* config, tsi_test_channel* channel, tsi_frame_protector* protector, bool is_client) { // Initialization. - GPR_ASSERT(config != nullptr); - GPR_ASSERT(channel != nullptr); - GPR_ASSERT(protector != nullptr); + CHECK_NE(config, nullptr); + CHECK_NE(channel, nullptr); + CHECK_NE(protector, nullptr); unsigned char* protected_buffer = static_cast(gpr_zalloc(config->protected_buffer_size)); size_t message_size = is_client ? config->client_message_size : config->server_message_size; uint8_t* message = is_client ? config->client_message : config->server_message; - GPR_ASSERT(message != nullptr); + CHECK_NE(message, nullptr); const unsigned char* message_bytes = reinterpret_cast(message); tsi_result result = TSI_OK; @@ -218,7 +221,7 @@ void tsi_test_frame_protector_send_message_to_peer( result = tsi_frame_protector_protect( protector, message_bytes, &processed_message_size, protected_buffer, &protected_buffer_size_to_send); - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); // Send protected data to peer. send_bytes_to_peer(channel, protected_buffer, protected_buffer_size_to_send, is_client); @@ -232,14 +235,14 @@ void tsi_test_frame_protector_send_message_to_peer( result = tsi_frame_protector_protect_flush( protector, protected_buffer, &protected_buffer_size_to_send, &still_pending_size); - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); send_bytes_to_peer(channel, protected_buffer, protected_buffer_size_to_send, is_client); } while (still_pending_size > 0 && result == TSI_OK); - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); } } - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); gpr_free(protected_buffer); } @@ -248,11 +251,11 @@ void tsi_test_frame_protector_receive_message_from_peer( tsi_frame_protector* protector, unsigned char* message, size_t* bytes_received, bool is_client) { // Initialization. - GPR_ASSERT(config != nullptr); - GPR_ASSERT(channel != nullptr); - GPR_ASSERT(protector != nullptr); - GPR_ASSERT(message != nullptr); - GPR_ASSERT(bytes_received != nullptr); + CHECK_NE(config, nullptr); + CHECK_NE(channel, nullptr); + CHECK_NE(protector, nullptr); + CHECK_NE(message, nullptr); + CHECK_NE(bytes_received, nullptr); size_t read_offset = 0; size_t message_offset = 0; size_t read_from_peer_size = 0; @@ -282,7 +285,7 @@ void tsi_test_frame_protector_receive_message_from_peer( result = tsi_frame_protector_unprotect( protector, read_buffer + read_offset, &processed_size, message_buffer, &message_buffer_size); - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); if (message_buffer_size > 0) { memcpy(message + message_offset, message_buffer, message_buffer_size); message_offset += message_buffer_size; @@ -291,9 +294,9 @@ void tsi_test_frame_protector_receive_message_from_peer( read_from_peer_size -= processed_size; } while ((read_from_peer_size > 0 || message_buffer_size > 0) && result == TSI_OK); - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); } - GPR_ASSERT(result == TSI_OK); + CHECK(result == TSI_OK); *bytes_received = message_offset; gpr_free(read_buffer); gpr_free(message_buffer); @@ -303,13 +306,13 @@ grpc_error_handle on_handshake_next_done( tsi_result result, void* user_data, const unsigned char* bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) { handshaker_args* args = static_cast(user_data); - GPR_ASSERT(args != nullptr); - GPR_ASSERT(args->fixture != nullptr); + CHECK_NE(args, nullptr); + CHECK_NE(args->fixture, nullptr); tsi_test_fixture* fixture = args->fixture; grpc_error_handle error; // Read more data if we need to. if (result == TSI_INCOMPLETE_DATA) { - GPR_ASSERT(bytes_to_send_size == 0); + CHECK_EQ(bytes_to_send_size, 0u); notification_signal(fixture); return error; } @@ -322,7 +325,7 @@ grpc_error_handle on_handshake_next_done( if (handshaker_result != nullptr) { tsi_handshaker_result** result_to_write = args->is_client ? &fixture->client_result : &fixture->server_result; - GPR_ASSERT(*result_to_write == nullptr); + CHECK_EQ(*result_to_write, nullptr); *result_to_write = handshaker_result; } // Send data to peer, if needed. @@ -347,8 +350,8 @@ static void on_handshake_next_done_wrapper( } static bool is_handshake_finished_properly(handshaker_args* args) { - GPR_ASSERT(args != nullptr); - GPR_ASSERT(args->fixture != nullptr); + CHECK_NE(args, nullptr); + CHECK_NE(args->fixture, nullptr); tsi_test_fixture* fixture = args->fixture; return (args->is_client && fixture->client_result != nullptr) || (!args->is_client && fixture->server_result != nullptr); @@ -356,8 +359,8 @@ static bool is_handshake_finished_properly(handshaker_args* args) { static void do_handshaker_next(handshaker_args* args) { // Initialization. - GPR_ASSERT(args != nullptr); - GPR_ASSERT(args->fixture != nullptr); + CHECK_NE(args, nullptr); + CHECK_NE(args->fixture, nullptr); tsi_test_fixture* fixture = args->fixture; tsi_handshaker* handshaker = args->is_client ? fixture->client_handshaker : fixture->server_handshaker; @@ -416,7 +419,7 @@ void tsi_test_do_handshake(tsi_test_fixture* fixture) { // responsible for sending the next chunk of bytes to the other. This can // happen e.g. when a bug in the handshaker code results in some bytes being // dropped instead of passed to the BIO or SSL objects. - GPR_ASSERT(client_args->transferred_data || server_args->transferred_data); + CHECK(client_args->transferred_data || server_args->transferred_data); } while (fixture->client_result == nullptr || fixture->server_result == nullptr); // Verify handshake results. @@ -430,10 +433,10 @@ static void tsi_test_do_ping_pong(tsi_test_frame_protector_config* config, tsi_test_channel* channel, tsi_frame_protector* client_frame_protector, tsi_frame_protector* server_frame_protector) { - GPR_ASSERT(config != nullptr); - GPR_ASSERT(channel != nullptr); - GPR_ASSERT(client_frame_protector != nullptr); - GPR_ASSERT(server_frame_protector != nullptr); + CHECK_NE(config, nullptr); + CHECK_NE(channel, nullptr); + CHECK_NE(client_frame_protector, nullptr); + CHECK_NE(server_frame_protector, nullptr); // Client sends a message to server. tsi_test_frame_protector_send_message_to_peer( config, channel, client_frame_protector, true /* is_client */); @@ -443,9 +446,10 @@ static void tsi_test_do_ping_pong(tsi_test_frame_protector_config* config, tsi_test_frame_protector_receive_message_from_peer( config, channel, server_frame_protector, server_received_message, &server_received_message_size, false /* is_client */); - GPR_ASSERT(config->client_message_size == server_received_message_size); - GPR_ASSERT(memcmp(config->client_message, server_received_message, - server_received_message_size) == 0); + CHECK(config->client_message_size == server_received_message_size); + CHECK_EQ(memcmp(config->client_message, server_received_message, + server_received_message_size), + 0); // Server sends a message to client. tsi_test_frame_protector_send_message_to_peer( config, channel, server_frame_protector, false /* is_client */); @@ -455,16 +459,17 @@ static void tsi_test_do_ping_pong(tsi_test_frame_protector_config* config, tsi_test_frame_protector_receive_message_from_peer( config, channel, client_frame_protector, client_received_message, &client_received_message_size, true /* is_client */); - GPR_ASSERT(config->server_message_size == client_received_message_size); - GPR_ASSERT(memcmp(config->server_message, client_received_message, - client_received_message_size) == 0); + CHECK_EQ(config->server_message_size, client_received_message_size); + CHECK_EQ(memcmp(config->server_message, client_received_message, + client_received_message_size), + 0); gpr_free(server_received_message); gpr_free(client_received_message); } void tsi_test_frame_protector_do_round_trip_no_handshake( tsi_test_frame_protector_fixture* fixture) { - GPR_ASSERT(fixture != nullptr); + CHECK_NE(fixture, nullptr); tsi_test_do_ping_pong(fixture->config, fixture->channel, fixture->client_frame_protector, fixture->server_frame_protector); @@ -472,8 +477,8 @@ void tsi_test_frame_protector_do_round_trip_no_handshake( void tsi_test_do_round_trip(tsi_test_fixture* fixture) { // Initialization. - GPR_ASSERT(fixture != nullptr); - GPR_ASSERT(fixture->config != nullptr); + CHECK_NE(fixture, nullptr); + CHECK_NE(fixture->config, nullptr); tsi_test_frame_protector_config* config = fixture->config; tsi_frame_protector* client_frame_protector = nullptr; tsi_frame_protector* server_frame_protector = nullptr; @@ -482,20 +487,20 @@ void tsi_test_do_round_trip(tsi_test_fixture* fixture) { // Create frame protectors. size_t client_max_output_protected_frame_size = config->client_max_output_protected_frame_size; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - fixture->client_result, - client_max_output_protected_frame_size == 0 - ? nullptr - : &client_max_output_protected_frame_size, - &client_frame_protector) == TSI_OK); + CHECK(tsi_handshaker_result_create_frame_protector( + fixture->client_result, + client_max_output_protected_frame_size == 0 + ? nullptr + : &client_max_output_protected_frame_size, + &client_frame_protector) == TSI_OK); size_t server_max_output_protected_frame_size = config->server_max_output_protected_frame_size; - GPR_ASSERT(tsi_handshaker_result_create_frame_protector( - fixture->server_result, - server_max_output_protected_frame_size == 0 - ? nullptr - : &server_max_output_protected_frame_size, - &server_frame_protector) == TSI_OK); + CHECK(tsi_handshaker_result_create_frame_protector( + fixture->server_result, + server_max_output_protected_frame_size == 0 + ? nullptr + : &server_max_output_protected_frame_size, + &server_frame_protector) == TSI_OK); tsi_test_do_ping_pong(config, fixture->channel, client_frame_protector, server_frame_protector); // Destroy server and client frame protectors. @@ -576,7 +581,7 @@ void tsi_test_frame_protector_config_set_buffer_size( size_t message_buffer_allocated_size, size_t protected_buffer_size, size_t client_max_output_protected_frame_size, size_t server_max_output_protected_frame_size) { - GPR_ASSERT(config != nullptr); + CHECK_NE(config, nullptr); config->read_buffer_allocated_size = read_buffer_allocated_size; config->message_buffer_allocated_size = message_buffer_allocated_size; config->protected_buffer_size = protected_buffer_size; @@ -641,8 +646,8 @@ void tsi_test_fixture_destroy(tsi_test_fixture* fixture) { tsi_handshaker_result_destroy(fixture->client_result); tsi_handshaker_result_destroy(fixture->server_result); tsi_test_channel_destroy(fixture->channel); - GPR_ASSERT(fixture->vtable != nullptr); - GPR_ASSERT(fixture->vtable->destruct != nullptr); + CHECK_NE(fixture->vtable, nullptr); + CHECK_NE(fixture->vtable->destruct, nullptr); gpr_mu_destroy(&fixture->mu); gpr_cv_destroy(&fixture->cv); fixture->vtable->destruct(fixture); @@ -662,7 +667,7 @@ void tsi_test_frame_protector_fixture_init( tsi_test_frame_protector_fixture* fixture, tsi_frame_protector* client_frame_protector, tsi_frame_protector* server_frame_protector) { - GPR_ASSERT(fixture != nullptr); + CHECK_NE(fixture, nullptr); fixture->client_frame_protector = client_frame_protector; fixture->server_frame_protector = server_frame_protector; } @@ -683,73 +688,70 @@ std::string GenerateSelfSignedCertificate( const SelfSignedCertificateOptions& options) { // Generate an RSA keypair. BIGNUM* bignum = BN_new(); - GPR_ASSERT(BN_set_word(bignum, RSA_F4)); + CHECK(BN_set_word(bignum, RSA_F4)); BIGNUM* n = BN_new(); - GPR_ASSERT(BN_set_word(n, 2048)); + CHECK(BN_set_word(n, 2048)); EVP_PKEY* key = EVP_PKEY_new(); // Create the X509 object. X509* x509 = X509_new(); #if OPENSSL_VERSION_NUMBER < 0x30000000L RSA* rsa = RSA_new(); - GPR_ASSERT( - RSA_generate_key_ex(rsa, /*key_size=*/2048, bignum, /*cb=*/nullptr)); - GPR_ASSERT(EVP_PKEY_assign_RSA(key, rsa)); - GPR_ASSERT(X509_set_version(x509, 2)); // TODO(gtcooke94) make a const + CHECK(RSA_generate_key_ex(rsa, /*key_size=*/2048, bignum, /*cb=*/nullptr)); + CHECK(EVP_PKEY_assign_RSA(key, rsa)); + CHECK(X509_set_version(x509, 2)); // TODO(gtcooke94) make a const #else key = EVP_RSA_gen(2048); - GPR_ASSERT(X509_set_version(x509, X509_VERSION_3)); + CHECK(X509_set_version(x509, X509_VERSION_3)); #endif // Set the not_before/after fields to infinite past/future. The value for // infinite future is from RFC 5280 Section 4.1.2.5.1. ASN1_UTCTIME* infinite_past = ASN1_UTCTIME_new(); - GPR_ASSERT(ASN1_UTCTIME_set(infinite_past, /*posix_time=*/0)); + CHECK(ASN1_UTCTIME_set(infinite_past, /*posix_time=*/0)); #if OPENSSL_VERSION_NUMBER < 0x10100000 - GPR_ASSERT(X509_set_notBefore(x509, infinite_past)); + CHECK(X509_set_notBefore(x509, infinite_past)); #else - GPR_ASSERT(X509_set1_notBefore(x509, infinite_past)); + CHECK(X509_set1_notBefore(x509, infinite_past)); #endif ASN1_UTCTIME_free(infinite_past); ASN1_GENERALIZEDTIME* infinite_future = ASN1_GENERALIZEDTIME_new(); - GPR_ASSERT( - ASN1_GENERALIZEDTIME_set_string(infinite_future, "99991231235959Z")); + CHECK(ASN1_GENERALIZEDTIME_set_string(infinite_future, "99991231235959Z")); #if OPENSSL_VERSION_NUMBER < 0x10100000 - GPR_ASSERT(X509_set_notAfter(x509, infinite_future)); + CHECK(X509_set_notAfter(x509, infinite_future)); #else - GPR_ASSERT(X509_set1_notAfter(x509, infinite_future)); + CHECK(X509_set1_notAfter(x509, infinite_future)); #endif ASN1_GENERALIZEDTIME_free(infinite_future); // Set the subject DN. X509_NAME* subject_name = X509_NAME_new(); - GPR_ASSERT(X509_NAME_add_entry_by_txt( + CHECK(X509_NAME_add_entry_by_txt( subject_name, /*field=*/"CN", MBSTRING_ASC, reinterpret_cast(options.common_name.c_str()), /*len=*/-1, /*loc=*/-1, /*set=*/0)); - GPR_ASSERT(X509_NAME_add_entry_by_txt( + CHECK(X509_NAME_add_entry_by_txt( subject_name, /*field=*/"O", MBSTRING_ASC, reinterpret_cast(options.organization.c_str()), /*len=*/-1, /*loc=*/-1, /*set=*/0)); - GPR_ASSERT( - X509_NAME_add_entry_by_txt(subject_name, /*field=*/"OU", MBSTRING_ASC, - reinterpret_cast( - options.organizational_unit.c_str()), - /*len=*/-1, /*loc=*/-1, - /*set=*/0)); - GPR_ASSERT(X509_set_subject_name(x509, subject_name)); + CHECK(X509_NAME_add_entry_by_txt(subject_name, /*field=*/"OU", MBSTRING_ASC, + reinterpret_cast( + options.organizational_unit.c_str()), + /*len=*/-1, /*loc=*/-1, + /*set=*/0)); + CHECK(X509_set_subject_name(x509, subject_name)); X509_NAME_free(subject_name); // Set the public key and sign the certificate. - GPR_ASSERT(X509_set_pubkey(x509, key)); - GPR_ASSERT(X509_sign(x509, key, EVP_sha256())); + CHECK(X509_set_pubkey(x509, key)); + CHECK(X509_sign(x509, key, EVP_sha256())); // Convert to PEM. BIO* bio = BIO_new(BIO_s_mem()); - GPR_ASSERT(PEM_write_bio_X509(bio, x509)); + CHECK(PEM_write_bio_X509(bio, x509)); const uint8_t* data = nullptr; size_t len = 0; #ifdef OPENSSL_IS_BORINGSSL - GPR_ASSERT(BIO_mem_contents(bio, &data, &len)); + CHECK(BIO_mem_contents(bio, &data, &len)); #else len = BIO_get_mem_data(bio, &data); #endif From 17984c10e15ddc94497b96bfd221a53d8ced1497 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 18 Apr 2024 13:44:16 -0700 Subject: [PATCH 26/45] [clang-format] run for everything under src/core (#36381) Looks like this has been broken for things we've moved out of lib and ext. Closes #36381 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36381 from markdroth:clang_format_fix 41f0283c424ea3ff0509f72ab2bd61fcb9d836fb PiperOrigin-RevId: 626137779 --- .../client_channel/client_channel_filter.h | 2 +- .../client_channel/client_channel_internal.h | 2 +- .../client_channel_service_config.h | 2 +- src/core/client_channel/config_selector.h | 2 +- src/core/client_channel/retry_filter.cc | 2 +- src/core/load_balancing/address_filtering.cc | 4 +- src/core/load_balancing/address_filtering.h | 4 +- src/core/load_balancing/backend_metric_data.h | 4 +- .../load_balancing/backend_metric_parser.cc | 4 +- .../load_balancing/backend_metric_parser.h | 4 +- .../load_balancing/child_policy_handler.cc | 5 +-- .../load_balancing/child_policy_handler.h | 4 +- src/core/load_balancing/delegating_helper.h | 5 +-- src/core/load_balancing/endpoint_list.cc | 5 +-- src/core/load_balancing/endpoint_list.h | 3 +- src/core/load_balancing/grpclb/grpclb.cc | 3 +- .../grpclb/grpclb_balancer_addresses.cc | 4 +- .../grpclb/grpclb_balancer_addresses.h | 3 +- .../grpclb/grpclb_client_stats.cc | 3 +- .../grpclb/grpclb_client_stats.h | 3 +- .../grpclb/load_balancer_api.cc | 3 +- .../load_balancing/grpclb/load_balancer_api.h | 5 +-- .../load_balancing/health_check_client.cc | 3 +- src/core/load_balancing/health_check_client.h | 4 +- .../health_check_client_internal.h | 3 +- src/core/load_balancing/lb_policy.cc | 4 +- src/core/load_balancing/lb_policy.h | 3 +- src/core/load_balancing/lb_policy_factory.h | 4 +- src/core/load_balancing/lb_policy_registry.cc | 3 +- src/core/load_balancing/lb_policy_registry.h | 4 +- src/core/load_balancing/oob_backend_metric.cc | 3 +- src/core/load_balancing/oob_backend_metric.h | 4 +- .../oob_backend_metric_internal.h | 3 +- .../outlier_detection/outlier_detection.cc | 3 +- .../outlier_detection/outlier_detection.h | 4 +- .../load_balancing/pick_first/pick_first.cc | 45 +++++++++---------- src/core/load_balancing/priority/priority.cc | 7 ++- .../load_balancing/ring_hash/ring_hash.cc | 5 +-- src/core/load_balancing/ring_hash/ring_hash.h | 4 +- src/core/load_balancing/rls/rls.cc | 3 +- .../load_balancing/round_robin/round_robin.cc | 3 +- .../load_balancing/subchannel_interface.h | 3 +- .../static_stride_scheduler.cc | 3 +- .../static_stride_scheduler.h | 4 +- .../weighted_round_robin.cc | 3 +- .../weighted_target/weighted_target.cc | 7 ++- .../weighted_target/weighted_target.h | 2 +- src/core/load_balancing/xds/cds.cc | 3 +- .../load_balancing/xds/xds_cluster_manager.cc | 5 +-- .../load_balancing/xds/xds_override_host.cc | 3 +- .../load_balancing/xds/xds_override_host.h | 4 +- .../load_balancing/xds/xds_wrr_locality.cc | 3 +- .../plugin_registry/grpc_plugin_registry.cc | 3 +- .../grpc_plugin_registry_extra.cc | 3 +- .../grpc_plugin_registry_noextra.cc | 3 +- src/core/resolver/binder/binder_resolver.cc | 8 ++-- .../resolver/dns/c_ares/dns_resolver_ares.cc | 11 +++-- .../resolver/dns/c_ares/dns_resolver_ares.h | 4 +- .../resolver/dns/c_ares/grpc_ares_ev_driver.h | 6 +-- .../dns/c_ares/grpc_ares_ev_driver_posix.cc | 4 +- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 4 +- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 7 ++- .../resolver/dns/c_ares/grpc_ares_wrapper.h | 3 +- .../dns/c_ares/grpc_ares_wrapper_posix.cc | 2 +- .../dns/c_ares/grpc_ares_wrapper_windows.cc | 2 +- src/core/resolver/dns/dns_resolver_plugin.cc | 9 ++-- .../event_engine_client_channel_resolver.cc | 7 ++- .../event_engine_client_channel_resolver.h | 6 +-- .../dns/event_engine/service_config_helper.cc | 4 +- .../dns/event_engine/service_config_helper.h | 4 +- src/core/resolver/dns/native/dns_resolver.cc | 7 ++- src/core/resolver/endpoint_addresses.cc | 3 +- src/core/resolver/endpoint_addresses.h | 4 +- src/core/resolver/fake/fake_resolver.cc | 5 +-- src/core/resolver/fake/fake_resolver.h | 3 +- .../google_c2p/google_c2p_resolver.cc | 9 ++-- src/core/resolver/polling_resolver.cc | 5 +-- src/core/resolver/polling_resolver.h | 3 +- src/core/resolver/resolver.cc | 4 +- src/core/resolver/resolver.h | 4 +- src/core/resolver/resolver_factory.h | 6 +-- src/core/resolver/resolver_registry.cc | 3 +- src/core/resolver/resolver_registry.h | 6 +-- .../resolver/sockaddr/sockaddr_resolver.cc | 5 +-- .../resolver/xds/xds_dependency_manager.cc | 4 +- .../resolver/xds/xds_dependency_manager.h | 4 +- src/core/resolver/xds/xds_resolver.cc | 3 +- .../resolver/xds/xds_resolver_attributes.h | 4 +- src/core/resolver/xds/xds_resolver_trace.cc | 4 +- src/core/service_config/service_config.h | 3 +- .../service_config/service_config_call_data.h | 4 +- .../service_config/service_config_impl.cc | 4 +- src/core/service_config/service_config_impl.h | 3 +- .../service_config/service_config_parser.cc | 3 +- .../service_config/service_config_parser.h | 4 +- .../clang_format_all_the_things.sh | 2 +- 96 files changed, 188 insertions(+), 239 deletions(-) diff --git a/src/core/client_channel/client_channel_filter.h b/src/core/client_channel/client_channel_filter.h index b3fc9839945..23819b33073 100644 --- a/src/core/client_channel/client_channel_filter.h +++ b/src/core/client_channel/client_channel_filter.h @@ -63,7 +63,6 @@ #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/resource_quota/arena.h" -#include "src/core/service_config/service_config.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/metadata_batch.h" @@ -71,6 +70,7 @@ #include "src/core/load_balancing/backend_metric_data.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/resolver/resolver.h" +#include "src/core/service_config/service_config.h" // // Client channel filter diff --git a/src/core/client_channel/client_channel_internal.h b/src/core/client_channel/client_channel_internal.h index 3fdb7184b79..8d849277f79 100644 --- a/src/core/client_channel/client_channel_internal.h +++ b/src/core/client_channel/client_channel_internal.h @@ -29,8 +29,8 @@ #include "src/core/lib/channel/context.h" #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/resource_quota/arena.h" -#include "src/core/service_config/service_config_call_data.h" #include "src/core/load_balancing/lb_policy.h" +#include "src/core/service_config/service_config_call_data.h" // // This file contains internal interfaces used to allow various plugins diff --git a/src/core/client_channel/client_channel_service_config.h b/src/core/client_channel/client_channel_service_config.h index c79e3e6ed8c..21778d9be18 100644 --- a/src/core/client_channel/client_channel_service_config.h +++ b/src/core/client_channel/client_channel_service_config.h @@ -35,8 +35,8 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/json/json_args.h" #include "src/core/lib/json/json_object_loader.h" -#include "src/core/service_config/service_config_parser.h" #include "src/core/load_balancing/lb_policy.h" +#include "src/core/service_config/service_config_parser.h" namespace grpc_core { namespace internal { diff --git a/src/core/client_channel/config_selector.h b/src/core/client_channel/config_selector.h index e6560318f9a..4f657e974ef 100644 --- a/src/core/client_channel/config_selector.h +++ b/src/core/client_channel/config_selector.h @@ -36,9 +36,9 @@ #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/resource_quota/arena.h" -#include "src/core/service_config/service_config.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/metadata_batch.h" +#include "src/core/service_config/service_config.h" // Channel arg key for ConfigSelector. #define GRPC_ARG_CONFIG_SELECTOR "grpc.internal.config_selector" diff --git a/src/core/client_channel/retry_filter.cc b/src/core/client_channel/retry_filter.cc index b00899392f6..fae1ae427fb 100644 --- a/src/core/client_channel/retry_filter.cc +++ b/src/core/client_channel/retry_filter.cc @@ -35,9 +35,9 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_call_data.h" -#include "src/core/lib/uri/uri_parser.h" // // Retry filter diff --git a/src/core/load_balancing/address_filtering.cc b/src/core/load_balancing/address_filtering.cc index a6eb3966f04..4077eda12ab 100644 --- a/src/core/load_balancing/address_filtering.cc +++ b/src/core/load_balancing/address_filtering.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/address_filtering.h" #include @@ -24,6 +22,8 @@ #include "absl/functional/function_ref.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/resolved_address.h" diff --git a/src/core/load_balancing/address_filtering.h b/src/core/load_balancing/address_filtering.h index bad19b16039..0c03092694e 100644 --- a/src/core/load_balancing/address_filtering.h +++ b/src/core/load_balancing/address_filtering.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_ADDRESS_FILTERING_H #define GRPC_SRC_CORE_LOAD_BALANCING_ADDRESS_FILTERING_H -#include - #include #include #include @@ -27,6 +25,8 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_string.h" #include "src/core/resolver/endpoint_addresses.h" diff --git a/src/core/load_balancing/backend_metric_data.h b/src/core/load_balancing/backend_metric_data.h index 036298681de..1f11e61e947 100644 --- a/src/core/load_balancing/backend_metric_data.h +++ b/src/core/load_balancing/backend_metric_data.h @@ -17,12 +17,12 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_DATA_H #define GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_DATA_H -#include - #include #include "absl/strings/string_view.h" +#include + namespace grpc_core { // Represents backend metrics reported by the backend to the client. diff --git a/src/core/load_balancing/backend_metric_parser.cc b/src/core/load_balancing/backend_metric_parser.cc index 968fc287b36..6dc1275a65e 100644 --- a/src/core/load_balancing/backend_metric_parser.cc +++ b/src/core/load_balancing/backend_metric_parser.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/backend_metric_parser.h" #include @@ -28,6 +26,8 @@ #include "upb/message/map.h" #include "xds/data/orca/v3/orca_load_report.upb.h" +#include + namespace grpc_core { namespace { diff --git a/src/core/load_balancing/backend_metric_parser.h b/src/core/load_balancing/backend_metric_parser.h index 3ee75c9c556..cd499157d0a 100644 --- a/src/core/load_balancing/backend_metric_parser.h +++ b/src/core/load_balancing/backend_metric_parser.h @@ -17,12 +17,12 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_PARSER_H #define GRPC_SRC_CORE_LOAD_BALANCING_BACKEND_METRIC_PARSER_H -#include - #include #include "absl/strings/string_view.h" +#include + #include "src/core/load_balancing/backend_metric_data.h" namespace grpc_core { diff --git a/src/core/load_balancing/child_policy_handler.cc b/src/core/load_balancing/child_policy_handler.cc index e70d017eb04..7fca56266df 100644 --- a/src/core/load_balancing/child_policy_handler.cc +++ b/src/core/load_balancing/child_policy_handler.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/child_policy_handler.h" #include @@ -27,16 +25,17 @@ #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/transport/connectivity_state.h" #include "src/core/load_balancing/delegating_helper.h" #include "src/core/load_balancing/lb_policy_registry.h" #include "src/core/load_balancing/subchannel_interface.h" -#include "src/core/lib/transport/connectivity_state.h" namespace grpc_core { diff --git a/src/core/load_balancing/child_policy_handler.h b/src/core/load_balancing/child_policy_handler.h index 19d37a1a012..9a964f020cd 100644 --- a/src/core/load_balancing/child_policy_handler.h +++ b/src/core/load_balancing/child_policy_handler.h @@ -16,13 +16,13 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_CHILD_POLICY_HANDLER_H #define GRPC_SRC_CORE_LOAD_BALANCING_CHILD_POLICY_HANDLER_H -#include - #include #include "absl/status/status.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/load_balancing/delegating_helper.h b/src/core/load_balancing/delegating_helper.h index e0f3885a326..fea9d48e0d7 100644 --- a/src/core/load_balancing/delegating_helper.h +++ b/src/core/load_balancing/delegating_helper.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_DELEGATING_HELPER_H #define GRPC_SRC_CORE_LOAD_BALANCING_DELEGATING_HELPER_H -#include - #include #include "absl/status/status.h" @@ -27,14 +25,15 @@ #include #include #include +#include #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/resolved_address.h" +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/subchannel_interface.h" -#include "src/core/lib/security/credentials/credentials.h" namespace grpc_core { diff --git a/src/core/load_balancing/endpoint_list.cc b/src/core/load_balancing/endpoint_list.cc index 00b152b9908..f86d5af16ff 100644 --- a/src/core/load_balancing/endpoint_list.cc +++ b/src/core/load_balancing/endpoint_list.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/endpoint_list.h" #include @@ -31,8 +29,8 @@ #include #include #include +#include -#include "src/core/load_balancing/pick_first/pick_first.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/debug_location.h" @@ -43,6 +41,7 @@ #include "src/core/load_balancing/delegating_helper.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_registry.h" +#include "src/core/load_balancing/pick_first/pick_first.h" #include "src/core/resolver/endpoint_addresses.h" namespace grpc_core { diff --git a/src/core/load_balancing/endpoint_list.h b/src/core/load_balancing/endpoint_list.h index 2c842fe32fb..daf4f1fe366 100644 --- a/src/core/load_balancing/endpoint_list.h +++ b/src/core/load_balancing/endpoint_list.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_ENDPOINT_LIST_H #define GRPC_SRC_CORE_LOAD_BALANCING_ENDPOINT_LIST_H -#include - #include #include @@ -30,6 +28,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/debug_location.h" diff --git a/src/core/load_balancing/grpclb/grpclb.cc b/src/core/load_balancing/grpclb/grpclb.cc index b6b3eac4b81..0b62235f51e 100644 --- a/src/core/load_balancing/grpclb/grpclb.cc +++ b/src/core/load_balancing/grpclb/grpclb.cc @@ -49,13 +49,12 @@ /// \see https://github.com/grpc/grpc/blob/master/doc/load-balancing.md for the /// high level design and details. -#include - #include "src/core/load_balancing/grpclb/grpclb.h" #include #include #include +#include // IWYU pragma: no_include diff --git a/src/core/load_balancing/grpclb/grpclb_balancer_addresses.cc b/src/core/load_balancing/grpclb/grpclb_balancer_addresses.cc index 06684a88ae0..17f817eb7a1 100644 --- a/src/core/load_balancing/grpclb/grpclb_balancer_addresses.cc +++ b/src/core/load_balancing/grpclb/grpclb_balancer_addresses.cc @@ -14,14 +14,14 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/grpclb/grpclb_balancer_addresses.h" #include #include +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/useful.h" diff --git a/src/core/load_balancing/grpclb/grpclb_balancer_addresses.h b/src/core/load_balancing/grpclb/grpclb_balancer_addresses.h index bb9d67885d3..bd46ec0ea32 100644 --- a/src/core/load_balancing/grpclb/grpclb_balancer_addresses.h +++ b/src/core/load_balancing/grpclb/grpclb_balancer_addresses.h @@ -17,9 +17,8 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_GRPCLB_BALANCER_ADDRESSES_H #define GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_GRPCLB_BALANCER_ADDRESSES_H -#include - #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/resolver/endpoint_addresses.h" diff --git a/src/core/load_balancing/grpclb/grpclb_client_stats.cc b/src/core/load_balancing/grpclb/grpclb_client_stats.cc index 0d3cad26494..b21e56c908c 100644 --- a/src/core/load_balancing/grpclb/grpclb_client_stats.cc +++ b/src/core/load_balancing/grpclb/grpclb_client_stats.cc @@ -16,13 +16,12 @@ // // -#include - #include "src/core/load_balancing/grpclb/grpclb_client_stats.h" #include #include +#include #include #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/load_balancing/grpclb/grpclb_client_stats.h b/src/core/load_balancing/grpclb/grpclb_client_stats.h index 0a7229a85d3..557d00429a9 100644 --- a/src/core/load_balancing/grpclb/grpclb_client_stats.h +++ b/src/core/load_balancing/grpclb/grpclb_client_stats.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_GRPCLB_CLIENT_STATS_H #define GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_GRPCLB_CLIENT_STATS_H -#include - #include #include @@ -30,6 +28,7 @@ #include "absl/container/inlined_vector.h" #include +#include #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" diff --git a/src/core/load_balancing/grpclb/load_balancer_api.cc b/src/core/load_balancing/grpclb/load_balancer_api.cc index 074e7f97f25..a702e900843 100644 --- a/src/core/load_balancing/grpclb/load_balancer_api.cc +++ b/src/core/load_balancing/grpclb/load_balancer_api.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/load_balancing/grpclb/load_balancer_api.h" #include @@ -29,6 +27,7 @@ #include "upb/base/string_view.h" #include +#include #include #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/load_balancing/grpclb/load_balancer_api.h b/src/core/load_balancing/grpclb/load_balancer_api.h index e52a62d5454..e948810e492 100644 --- a/src/core/load_balancing/grpclb/load_balancer_api.h +++ b/src/core/load_balancing/grpclb/load_balancer_api.h @@ -18,8 +18,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_LOAD_BALANCER_API_H #define GRPC_SRC_CORE_LOAD_BALANCING_GRPCLB_LOAD_BALANCER_API_H -#include - #include #include @@ -28,9 +26,10 @@ #include "upb/mem/arena.h" #include +#include -#include "src/core/load_balancing/grpclb/grpclb_client_stats.h" #include "src/core/lib/gprpp/time.h" +#include "src/core/load_balancing/grpclb/grpclb_client_stats.h" #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128 #define GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE 16 diff --git a/src/core/load_balancing/health_check_client.cc b/src/core/load_balancing/health_check_client.cc index a97edecec43..455dc789adb 100644 --- a/src/core/load_balancing/health_check_client.cc +++ b/src/core/load_balancing/health_check_client.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -39,6 +37,7 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_channelz.h" #include "src/core/client_channel/client_channel_internal.h" diff --git a/src/core/load_balancing/health_check_client.h b/src/core/load_balancing/health_check_client.h index 74205a3596b..03f42cd1e91 100644 --- a/src/core/load_balancing/health_check_client.h +++ b/src/core/load_balancing/health_check_client.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_H #define GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_H -#include - #include +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/work_serializer.h" #include "src/core/load_balancing/subchannel_interface.h" diff --git a/src/core/load_balancing/health_check_client_internal.h b/src/core/load_balancing/health_check_client_internal.h index a083fa035ec..0fc86ac2858 100644 --- a/src/core/load_balancing/health_check_client_internal.h +++ b/src/core/load_balancing/health_check_client_internal.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_INTERNAL_H #define GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_INTERNAL_H -#include - #include #include #include @@ -31,6 +29,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_interface_internal.h" diff --git a/src/core/load_balancing/lb_policy.cc b/src/core/load_balancing/lb_policy.cc index 79cd63868e8..66ce4f4e3ce 100644 --- a/src/core/load_balancing/lb_policy.cc +++ b/src/core/load_balancing/lb_policy.cc @@ -16,10 +16,10 @@ // // -#include - #include "src/core/load_balancing/lb_policy.h" +#include + #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/load_balancing/lb_policy.h b/src/core/load_balancing/lb_policy.h index aa6036182d9..68f75e5271a 100644 --- a/src/core/load_balancing/lb_policy.h +++ b/src/core/load_balancing/lb_policy.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_H #define GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_H -#include - #include #include @@ -37,6 +35,7 @@ #include #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/metrics.h" diff --git a/src/core/load_balancing/lb_policy_factory.h b/src/core/load_balancing/lb_policy_factory.h index ca46e912d4a..b4116f5ff30 100644 --- a/src/core/load_balancing/lb_policy_factory.h +++ b/src/core/load_balancing/lb_policy_factory.h @@ -17,11 +17,11 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_FACTORY_H #define GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_FACTORY_H -#include - #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/json/json.h" diff --git a/src/core/load_balancing/lb_policy_registry.cc b/src/core/load_balancing/lb_policy_registry.cc index a03219bb1e1..6a639377a42 100644 --- a/src/core/load_balancing/lb_policy_registry.cc +++ b/src/core/load_balancing/lb_policy_registry.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/lb_policy_registry.h" #include @@ -32,6 +30,7 @@ #include #include +#include #include "src/core/load_balancing/lb_policy.h" diff --git a/src/core/load_balancing/lb_policy_registry.h b/src/core/load_balancing/lb_policy_registry.h index 018595eff4a..dea9b5ad277 100644 --- a/src/core/load_balancing/lb_policy_registry.h +++ b/src/core/load_balancing/lb_policy_registry.h @@ -17,14 +17,14 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_REGISTRY_H #define GRPC_SRC_CORE_LOAD_BALANCING_LB_POLICY_REGISTRY_H -#include - #include #include #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/json/json.h" diff --git a/src/core/load_balancing/oob_backend_metric.cc b/src/core/load_balancing/oob_backend_metric.cc index 854a4dba3bf..6d4bdd03164 100644 --- a/src/core/load_balancing/oob_backend_metric.cc +++ b/src/core/load_balancing/oob_backend_metric.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/oob_backend_metric.h" #include @@ -36,6 +34,7 @@ #include #include #include +#include #include #include "src/core/client_channel/client_channel_channelz.h" diff --git a/src/core/load_balancing/oob_backend_metric.h b/src/core/load_balancing/oob_backend_metric.h index b90e12889c9..26ac8b1b12d 100644 --- a/src/core/load_balancing/oob_backend_metric.h +++ b/src/core/load_balancing/oob_backend_metric.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_OOB_BACKEND_METRIC_H #define GRPC_SRC_CORE_LOAD_BALANCING_OOB_BACKEND_METRIC_H -#include - #include +#include + #include "src/core/lib/gprpp/time.h" #include "src/core/load_balancing/backend_metric_data.h" #include "src/core/load_balancing/subchannel_interface.h" diff --git a/src/core/load_balancing/oob_backend_metric_internal.h b/src/core/load_balancing/oob_backend_metric_internal.h index ee088f97064..30f9ac158da 100644 --- a/src/core/load_balancing/oob_backend_metric_internal.h +++ b/src/core/load_balancing/oob_backend_metric_internal.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_OOB_BACKEND_METRIC_INTERNAL_H #define GRPC_SRC_CORE_LOAD_BALANCING_OOB_BACKEND_METRIC_INTERNAL_H -#include - #include #include #include @@ -27,6 +25,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_interface_internal.h" diff --git a/src/core/load_balancing/outlier_detection/outlier_detection.cc b/src/core/load_balancing/outlier_detection/outlier_detection.cc index e6e85a8bffa..b955e0cc1ce 100644 --- a/src/core/load_balancing/outlier_detection/outlier_detection.cc +++ b/src/core/load_balancing/outlier_detection/outlier_detection.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/outlier_detection/outlier_detection.h" #include @@ -43,6 +41,7 @@ #include #include #include +#include #include "src/core/client_channel/subchannel_interface_internal.h" #include "src/core/lib/address_utils/sockaddr_utils.h" diff --git a/src/core/load_balancing/outlier_detection/outlier_detection.h b/src/core/load_balancing/outlier_detection/outlier_detection.h index fd247997f21..468591ddfc7 100644 --- a/src/core/load_balancing/outlier_detection/outlier_detection.h +++ b/src/core/load_balancing/outlier_detection/outlier_detection.h @@ -17,12 +17,12 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_OUTLIER_DETECTION_OUTLIER_DETECTION_H #define GRPC_SRC_CORE_LOAD_BALANCING_OUTLIER_DETECTION_OUTLIER_DETECTION_H -#include - #include // for uint32_t #include "absl/types/optional.h" +#include + #include "src/core/lib/gprpp/time.h" #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/json/json.h" diff --git a/src/core/load_balancing/pick_first/pick_first.cc b/src/core/load_balancing/pick_first/pick_first.cc index 53ce9559f62..7204b16f8be 100644 --- a/src/core/load_balancing/pick_first/pick_first.cc +++ b/src/core/load_balancing/pick_first/pick_first.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/pick_first/pick_first.h" #include @@ -40,8 +38,8 @@ #include #include #include +#include -#include "src/core/load_balancing/health_check_client.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/metrics.h" @@ -62,6 +60,7 @@ #include "src/core/lib/json/json_args.h" #include "src/core/lib/json/json_object_loader.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/load_balancing/health_check_client.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" #include "src/core/load_balancing/subchannel_interface.h" @@ -89,14 +88,14 @@ const auto kMetricDisconnections = const auto kMetricConnectionAttemptsSucceeded = GlobalInstrumentsRegistry::RegisterUInt64Counter( "grpc.lb.pick_first.connection_attempts_succeeded", - "EXPERIMENTAL. Number of successful connection attempts.", - "{attempt}", {kMetricLabelTarget}, {}, false); + "EXPERIMENTAL. Number of successful connection attempts.", "{attempt}", + {kMetricLabelTarget}, {}, false); const auto kMetricConnectionAttemptsFailed = GlobalInstrumentsRegistry::RegisterUInt64Counter( "grpc.lb.pick_first.connection_attempts_failed", - "EXPERIMENTAL. Number of failed connection attempts.", - "{attempt}", {kMetricLabelTarget}, {}, false); + "EXPERIMENTAL. Number of failed connection attempts.", "{attempt}", + {kMetricLabelTarget}, {}, false); class PickFirstConfig final : public LoadBalancingPolicy::Config { public: @@ -777,9 +776,9 @@ void PickFirst::SubchannelList::SubchannelData::SubchannelState:: // connection. Report the failure. auto& stats_plugins = pick_first_->channel_control_helper()->GetStatsPluginGroup(); - stats_plugins.AddCounter( - kMetricDisconnections, 1, - {pick_first_->channel_control_helper()->GetTarget()}, {}); + stats_plugins.AddCounter(kMetricDisconnections, 1, + {pick_first_->channel_control_helper()->GetTarget()}, + {}); // Report IDLE. pick_first_->GoIdle(); } @@ -874,9 +873,8 @@ void PickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange( // We've already started trying to connect. Any subchannel that // reports TF is a connection attempt failure. if (new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { - auto& stats_plugins = - subchannel_list_->policy_->channel_control_helper() - ->GetStatsPluginGroup(); + auto& stats_plugins = subchannel_list_->policy_->channel_control_helper() + ->GetStatsPluginGroup(); stats_plugins.AddCounter( kMetricConnectionAttemptsFailed, 1, {subchannel_list_->policy_->channel_control_helper()->GetTarget()}, {}); @@ -1551,8 +1549,8 @@ absl::Status OldPickFirst::UpdateLocked(UpdateArgs args) { } void OldPickFirst::UpdateState(grpc_connectivity_state state, - const absl::Status& status, - RefCountedPtr picker) { + const absl::Status& status, + RefCountedPtr picker) { state_ = state; channel_control_helper()->UpdateState(state, status, std::move(picker)); } @@ -1665,9 +1663,8 @@ void OldPickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange( p->latest_pending_subchannel_list_.get()); } if (subchannel_list_->shutting_down_ || pending_watcher_ == nullptr) return; - auto& stats_plugins = - subchannel_list_->policy_->channel_control_helper() - ->GetStatsPluginGroup(); + auto& stats_plugins = subchannel_list_->policy_->channel_control_helper() + ->GetStatsPluginGroup(); // The notification must be for a subchannel in either the current or // latest pending subchannel lists. GPR_ASSERT(subchannel_list_ == p->subchannel_list_.get() || @@ -1851,7 +1848,8 @@ void OldPickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange( } } -void OldPickFirst::SubchannelList::SubchannelData::RequestConnectionWithTimer() { +void OldPickFirst::SubchannelList::SubchannelData:: + RequestConnectionWithTimer() { GPR_ASSERT(connectivity_state_.has_value()); if (connectivity_state_ == GRPC_CHANNEL_IDLE) { subchannel_->RequestConnection(); @@ -1898,7 +1896,8 @@ void OldPickFirst::SubchannelList::SubchannelData::RequestConnectionWithTimer() } } -void OldPickFirst::SubchannelList::SubchannelData::ProcessUnselectedReadyLocked() { +void OldPickFirst::SubchannelList::SubchannelData:: + ProcessUnselectedReadyLocked() { OldPickFirst* p = subchannel_list_->policy_.get(); // Cancel Happy Eyeballs timer, if any. if (subchannel_list_->timer_handle_.has_value()) { @@ -1965,9 +1964,9 @@ void OldPickFirst::SubchannelList::SubchannelData::ProcessUnselectedReadyLocked( // OldPickFirst::SubchannelList // -OldPickFirst::SubchannelList::SubchannelList(RefCountedPtr policy, - EndpointAddressesIterator* addresses, - const ChannelArgs& args) +OldPickFirst::SubchannelList::SubchannelList( + RefCountedPtr policy, EndpointAddressesIterator* addresses, + const ChannelArgs& args) : InternallyRefCounted( GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace) ? "SubchannelList" : nullptr), diff --git a/src/core/load_balancing/priority/priority.cc b/src/core/load_balancing/priority/priority.cc index 5b1b0e743ca..ac3eea9c371 100644 --- a/src/core/load_balancing/priority/priority.cc +++ b/src/core/load_balancing/priority/priority.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -38,9 +36,8 @@ #include #include #include +#include -#include "src/core/load_balancing/address_filtering.h" -#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" @@ -57,6 +54,8 @@ #include "src/core/lib/json/json_args.h" #include "src/core/lib/json/json_object_loader.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/load_balancing/address_filtering.h" +#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/load_balancing/delegating_helper.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" diff --git a/src/core/load_balancing/ring_hash/ring_hash.cc b/src/core/load_balancing/ring_hash/ring_hash.cc index a4c0e40a0cd..41782c70655 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.cc +++ b/src/core/load_balancing/ring_hash/ring_hash.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/ring_hash/ring_hash.h" #include @@ -41,9 +39,9 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_internal.h" -#include "src/core/load_balancing/pick_first/pick_first.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" @@ -67,6 +65,7 @@ #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" #include "src/core/load_balancing/lb_policy_registry.h" +#include "src/core/load_balancing/pick_first/pick_first.h" #include "src/core/resolver/endpoint_addresses.h" namespace grpc_core { diff --git a/src/core/load_balancing/ring_hash/ring_hash.h b/src/core/load_balancing/ring_hash/ring_hash.h index 78833f3361f..001de901543 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.h +++ b/src/core/load_balancing/ring_hash/ring_hash.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_RING_HASH_RING_HASH_H #define GRPC_SRC_CORE_LOAD_BALANCING_RING_HASH_RING_HASH_H -#include - #include +#include + #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/json/json.h" diff --git a/src/core/load_balancing/rls/rls.cc b/src/core/load_balancing/rls/rls.cc index aa5a281c5f1..ea7c1c909bd 100644 --- a/src/core/load_balancing/rls/rls.cc +++ b/src/core/load_balancing/rls/rls.cc @@ -20,8 +20,6 @@ // to use. A child policy that recognizes the name as a field of its // configuration will take further load balancing action on the request. -#include - #include "src/core/load_balancing/rls/rls.h" #include @@ -65,6 +63,7 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_filter.h" #include "src/core/lib/backoff/backoff.h" diff --git a/src/core/load_balancing/round_robin/round_robin.cc b/src/core/load_balancing/round_robin/round_robin.cc index 95160d543b4..85d524e10f3 100644 --- a/src/core/load_balancing/round_robin/round_robin.cc +++ b/src/core/load_balancing/round_robin/round_robin.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -36,6 +34,7 @@ #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" diff --git a/src/core/load_balancing/subchannel_interface.h b/src/core/load_balancing/subchannel_interface.h index 7efa522971a..d135924f2b3 100644 --- a/src/core/load_balancing/subchannel_interface.h +++ b/src/core/load_balancing/subchannel_interface.h @@ -17,14 +17,13 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_SUBCHANNEL_INTERFACE_H #define GRPC_SRC_CORE_LOAD_BALANCING_SUBCHANNEL_INTERFACE_H -#include - #include #include #include "absl/status/status.h" #include +#include #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc index 6f126fa5d71..ba3f3d5a36a 100644 --- a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc +++ b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h" #include @@ -27,6 +25,7 @@ #include "absl/functional/any_invocable.h" #include +#include namespace grpc_core { diff --git a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h index 3bd8ec147fd..7245ca9607a 100644 --- a/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h +++ b/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_WEIGHTED_ROUND_ROBIN_STATIC_STRIDE_SCHEDULER_H #define GRPC_SRC_CORE_LOAD_BALANCING_WEIGHTED_ROUND_ROBIN_STATIC_STRIDE_SCHEDULER_H -#include - #include #include @@ -28,6 +26,8 @@ #include "absl/types/optional.h" #include "absl/types/span.h" +#include + namespace grpc_core { // StaticStrideScheduler implements a stride scheduler without the ability to diff --git a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc index 8e28f6b2c3b..b93f51f410a 100644 --- a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +++ b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -43,6 +41,7 @@ #include #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/metrics.h" diff --git a/src/core/load_balancing/weighted_target/weighted_target.cc b/src/core/load_balancing/weighted_target/weighted_target.cc index 3f32142a76a..7da39858acd 100644 --- a/src/core/load_balancing/weighted_target/weighted_target.cc +++ b/src/core/load_balancing/weighted_target/weighted_target.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/weighted_target/weighted_target.h" #include @@ -41,9 +39,8 @@ #include #include #include +#include -#include "src/core/load_balancing/address_filtering.h" -#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" @@ -60,6 +57,8 @@ #include "src/core/lib/json/json_args.h" #include "src/core/lib/json/json_object_loader.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/load_balancing/address_filtering.h" +#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/load_balancing/delegating_helper.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" diff --git a/src/core/load_balancing/weighted_target/weighted_target.h b/src/core/load_balancing/weighted_target/weighted_target.h index 2a1c4f17086..cf88c704cae 100644 --- a/src/core/load_balancing/weighted_target/weighted_target.h +++ b/src/core/load_balancing/weighted_target/weighted_target.h @@ -23,6 +23,6 @@ // Channel arg key indicating the weighted_target child name. #define GRPC_ARG_LB_WEIGHTED_TARGET_CHILD \ - GRPC_ARG_NO_SUBCHANNEL_PREFIX "lb_weighted_target_child" + GRPC_ARG_NO_SUBCHANNEL_PREFIX "lb_weighted_target_child" #endif // GRPC_SRC_CORE_LOAD_BALANCING_WEIGHTED_TARGET_WEIGHTED_TARGET_H diff --git a/src/core/load_balancing/xds/cds.cc b/src/core/load_balancing/xds/cds.cc index 4a7c07b41ed..2a53ed21115 100644 --- a/src/core/load_balancing/xds/cds.cc +++ b/src/core/load_balancing/xds/cds.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include #include @@ -36,6 +34,7 @@ #include #include #include +#include #include "src/core/ext/xds/xds_cluster.h" #include "src/core/ext/xds/xds_common_types.h" diff --git a/src/core/load_balancing/xds/xds_cluster_manager.cc b/src/core/load_balancing/xds/xds_cluster_manager.cc index 4cad8116953..f2aea70f293 100644 --- a/src/core/load_balancing/xds/xds_cluster_manager.cc +++ b/src/core/load_balancing/xds/xds_cluster_manager.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -37,9 +35,9 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_internal.h" -#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" @@ -55,6 +53,7 @@ #include "src/core/lib/json/json_args.h" #include "src/core/lib/json/json_object_loader.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/load_balancing/child_policy_handler.h" #include "src/core/load_balancing/delegating_helper.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/lb_policy_factory.h" diff --git a/src/core/load_balancing/xds/xds_override_host.cc b/src/core/load_balancing/xds/xds_override_host.cc index 4fcc5a77b6d..d0316742f37 100644 --- a/src/core/load_balancing/xds/xds_override_host.cc +++ b/src/core/load_balancing/xds/xds_override_host.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/load_balancing/xds/xds_override_host.h" #include @@ -46,6 +44,7 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_internal.h" #include "src/core/ext/filters/stateful_session/stateful_session_filter.h" diff --git a/src/core/load_balancing/xds/xds_override_host.h b/src/core/load_balancing/xds/xds_override_host.h index a9adae2eaa8..392f325ec35 100644 --- a/src/core/load_balancing/xds/xds_override_host.h +++ b/src/core/load_balancing/xds/xds_override_host.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_LOAD_BALANCING_XDS_XDS_OVERRIDE_HOST_H #define GRPC_SRC_CORE_LOAD_BALANCING_XDS_XDS_OVERRIDE_HOST_H -#include - #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/json/json.h" diff --git a/src/core/load_balancing/xds/xds_wrr_locality.cc b/src/core/load_balancing/xds/xds_wrr_locality.cc index 2a773941983..6aa2194d7b7 100644 --- a/src/core/load_balancing/xds/xds_wrr_locality.cc +++ b/src/core/load_balancing/xds/xds_wrr_locality.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include #include @@ -31,6 +29,7 @@ #include #include #include +#include #include "src/core/ext/xds/xds_client_stats.h" #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index eb8f14c5f1c..44c2336a8f7 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -16,9 +16,8 @@ // // -#include - #include +#include #include "src/core/lib/channel/server_call_tracer_filter.h" #include "src/core/lib/config/core_configuration.h" diff --git a/src/core/plugin_registry/grpc_plugin_registry_extra.cc b/src/core/plugin_registry/grpc_plugin_registry_extra.cc index 25e26342c2a..a6013c24965 100644 --- a/src/core/plugin_registry/grpc_plugin_registry_extra.cc +++ b/src/core/plugin_registry/grpc_plugin_registry_extra.cc @@ -14,9 +14,8 @@ // limitations under the License. // -#include - #include +#include #include "src/core/lib/config/core_configuration.h" diff --git a/src/core/plugin_registry/grpc_plugin_registry_noextra.cc b/src/core/plugin_registry/grpc_plugin_registry_noextra.cc index 00692f98efd..c6666166742 100644 --- a/src/core/plugin_registry/grpc_plugin_registry_noextra.cc +++ b/src/core/plugin_registry/grpc_plugin_registry_noextra.cc @@ -14,9 +14,8 @@ // limitations under the License. // -#include - #include +#include #include "src/core/lib/config/core_configuration.h" diff --git a/src/core/resolver/binder/binder_resolver.cc b/src/core/resolver/binder/binder_resolver.cc index b0187ca3c40..903a5528470 100644 --- a/src/core/resolver/binder/binder_resolver.cc +++ b/src/core/resolver/binder/binder_resolver.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include #include "absl/status/status.h" +#include + #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/port.h" // IWYU pragma: keep @@ -32,7 +32,7 @@ #else #include #include -#endif // GPR_WINDOWS +#endif // GPR_WINDOWS #include #include @@ -49,10 +49,10 @@ #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" -#include "src/core/lib/uri/uri_parser.h" namespace grpc_core { namespace { diff --git a/src/core/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/resolver/dns/c_ares/dns_resolver_ares.cc index b394fd635d2..4fa22539ba1 100644 --- a/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/resolver/dns/c_ares/dns_resolver_ares.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -36,8 +34,8 @@ #include #include #include +#include -#include "src/core/resolver/dns/event_engine/service_config_helper.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" @@ -51,10 +49,11 @@ #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/uri/uri_parser.h" +#include "src/core/resolver/dns/event_engine/service_config_helper.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" #include "src/core/service_config/service_config.h" -#include "src/core/lib/uri/uri_parser.h" #if GRPC_ARES == 1 @@ -66,12 +65,12 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/config_vars.h" #include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/resolver/endpoint_addresses.h" -#include "src/core/service_config/service_config_impl.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/load_balancing/grpclb/grpclb_balancer_addresses.h" #include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/polling_resolver.h" +#include "src/core/service_config/service_config_impl.h" #define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/src/core/resolver/dns/c_ares/dns_resolver_ares.h b/src/core/resolver/dns/c_ares/dns_resolver_ares.h index 5660361545e..d8ce1c25c6b 100644 --- a/src/core/resolver/dns/c_ares/dns_resolver_ares.h +++ b/src/core/resolver/dns/c_ares/dns_resolver_ares.h @@ -14,10 +14,10 @@ #ifndef GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_DNS_RESOLVER_ARES_H #define GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_DNS_RESOLVER_ARES_H -#include - #include "absl/strings/string_view.h" +#include + #include "src/core/lib/config/core_configuration.h" namespace grpc_core { diff --git a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h index 9627cef9ccd..652921cb668 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -19,19 +19,19 @@ #ifndef GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H #define GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H -#include - #include #include #include "absl/base/thread_annotations.h" -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include + #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/iomgr_fwd.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" namespace grpc_core { diff --git a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index bf56486ed93..501e1105ef7 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -40,14 +40,14 @@ #include -#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/socket_utils_posix.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" namespace grpc_core { diff --git a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index a016cae956b..ab03f8132bf 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -37,8 +37,6 @@ #include #include -#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/crash.h" @@ -49,6 +47,8 @@ #include "src/core/lib/iomgr/tcp_windows.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" // TODO(apolcyn): remove this hack after fixing upstream. // Our grpc/c-ares code on Windows uses the ares_set_socket_functions API, diff --git a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc index 23b9c2adae7..c27561dd06b 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -16,14 +16,13 @@ // // -#include - #include #include #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -57,8 +56,6 @@ #include #include -#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" @@ -71,6 +68,8 @@ #include "src/core/lib/iomgr/nameser.h" // IWYU pragma: keep #include "src/core/lib/iomgr/resolved_address.h" #include "src/core/lib/iomgr/timer.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" using grpc_core::EndpointAddresses; using grpc_core::EndpointAddressesList; diff --git a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h index 122e727b65f..9183fd59151 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H #define GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H -#include - #include #include @@ -30,6 +28,7 @@ #include "absl/base/thread_annotations.h" #include +#include #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc b/src/core/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc index 9f6290eba57..cdad090dcd9 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc @@ -21,8 +21,8 @@ #include "src/core/lib/iomgr/port.h" #if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/iomgr/socket_utils_posix.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } diff --git a/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc b/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc index 849c6b11ec3..9b87b56c1f1 100644 --- a/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +++ b/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc @@ -24,10 +24,10 @@ #include -#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_windows.h" +#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/resolver/endpoint_addresses.h" bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); } diff --git a/src/core/resolver/dns/dns_resolver_plugin.cc b/src/core/resolver/dns/dns_resolver_plugin.cc index 81b411024d7..a0f92a6c600 100644 --- a/src/core/resolver/dns/dns_resolver_plugin.cc +++ b/src/core/resolver/dns/dns_resolver_plugin.cc @@ -11,8 +11,6 @@ // WITHOUT 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 - #include "src/core/resolver/dns/dns_resolver_plugin.h" #include @@ -20,13 +18,14 @@ #include "absl/strings/match.h" #include +#include -#include "src/core/resolver/dns/c_ares/dns_resolver_ares.h" -#include "src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h" -#include "src/core/resolver/dns/native/dns_resolver.h" #include "src/core/lib/config/config_vars.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/gprpp/crash.h" +#include "src/core/resolver/dns/c_ares/dns_resolver_ares.h" +#include "src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h" +#include "src/core/resolver/dns/native/dns_resolver.h" #include "src/core/resolver/resolver_factory.h" namespace grpc_core { diff --git a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc index 432e948968c..da806a809e1 100644 --- a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +++ b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc @@ -11,8 +11,6 @@ // WITHOUT 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 - #include "src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h" #include @@ -37,6 +35,7 @@ #include #include #include +#include #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" @@ -49,14 +48,14 @@ #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/service_config/service_config.h" -#include "src/core/service_config/service_config_impl.h" #include "src/core/load_balancing/grpclb/grpclb_balancer_addresses.h" #include "src/core/resolver/dns/event_engine/service_config_helper.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/polling_resolver.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" +#include "src/core/service_config/service_config.h" +#include "src/core/service_config/service_config_impl.h" // IWYU pragma: no_include diff --git a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h index 10d8f10a4d3..65a21e4a02f 100644 --- a/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h +++ b/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h @@ -13,14 +13,14 @@ // limitations under the License. #ifndef GRPC_SRC_CORE_RESOLVER_DNS_EVENT_ENGINE_EVENT_ENGINE_CLIENT_CHANNEL_RESOLVER_H #define GRPC_SRC_CORE_RESOLVER_DNS_EVENT_ENGINE_EVENT_ENGINE_CLIENT_CHANNEL_RESOLVER_H -#include - #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/orphanable.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" -#include "src/core/lib/uri/uri_parser.h" namespace grpc_core { diff --git a/src/core/resolver/dns/event_engine/service_config_helper.cc b/src/core/resolver/dns/event_engine/service_config_helper.cc index 7d3dcb4d389..40b932b8deb 100644 --- a/src/core/resolver/dns/event_engine/service_config_helper.cc +++ b/src/core/resolver/dns/event_engine/service_config_helper.cc @@ -11,8 +11,6 @@ // WITHOUT 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 - #include "src/core/resolver/dns/event_engine/service_config_helper.h" #include @@ -23,6 +21,8 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/gethostname.h" #include "src/core/lib/json/json.h" diff --git a/src/core/resolver/dns/event_engine/service_config_helper.h b/src/core/resolver/dns/event_engine/service_config_helper.h index 5c89aa5e1e4..90bc82a96b6 100644 --- a/src/core/resolver/dns/event_engine/service_config_helper.h +++ b/src/core/resolver/dns/event_engine/service_config_helper.h @@ -15,13 +15,13 @@ #ifndef GRPC_SRC_CORE_RESOLVER_DNS_EVENT_ENGINE_SERVICE_CONFIG_HELPER_H #define GRPC_SRC_CORE_RESOLVER_DNS_EVENT_ENGINE_SERVICE_CONFIG_HELPER_H -#include - #include #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + namespace grpc_core { absl::StatusOr ChooseServiceConfig( diff --git a/src/core/resolver/dns/native/dns_resolver.cc b/src/core/resolver/dns/native/dns_resolver.cc index 3634e00e85c..43dddc719a4 100644 --- a/src/core/resolver/dns/native/dns_resolver.cc +++ b/src/core/resolver/dns/native/dns_resolver.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include #include @@ -31,8 +29,8 @@ #include #include +#include -#include "src/core/resolver/polling_resolver.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" @@ -43,10 +41,11 @@ #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/endpoint_addresses.h" +#include "src/core/resolver/polling_resolver.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" -#include "src/core/lib/uri/uri_parser.h" #define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6 diff --git a/src/core/resolver/endpoint_addresses.cc b/src/core/resolver/endpoint_addresses.cc index b474876020e..a5b29010b2c 100644 --- a/src/core/resolver/endpoint_addresses.cc +++ b/src/core/resolver/endpoint_addresses.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/resolver/endpoint_addresses.h" #include @@ -32,6 +30,7 @@ #include "absl/strings/str_join.h" #include +#include #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/resolver/endpoint_addresses.h b/src/core/resolver/endpoint_addresses.h index 789f7ede86b..cec6df1af68 100644 --- a/src/core/resolver/endpoint_addresses.h +++ b/src/core/resolver/endpoint_addresses.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_ENDPOINT_ADDRESSES_H #define GRPC_SRC_CORE_RESOLVER_ENDPOINT_ADDRESSES_H -#include - #include #include #include @@ -28,6 +26,8 @@ #include "absl/functional/function_ref.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolved_address.h" diff --git a/src/core/resolver/fake/fake_resolver.cc b/src/core/resolver/fake/fake_resolver.cc index b8385440ab8..08f7404b964 100644 --- a/src/core/resolver/fake/fake_resolver.cc +++ b/src/core/resolver/fake/fake_resolver.cc @@ -17,8 +17,6 @@ // This is similar to the sockaddr resolver, except that it supports a // bunch of query args that are useful for dependency injection in tests. -#include - #include "src/core/resolver/fake/fake_resolver.h" #include @@ -28,6 +26,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" @@ -35,8 +34,8 @@ #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/work_serializer.h" -#include "src/core/resolver/resolver_factory.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/resolver/resolver_factory.h" namespace grpc_core { diff --git a/src/core/resolver/fake/fake_resolver.h b/src/core/resolver/fake/fake_resolver.h index a9d51962485..c164c04ab38 100644 --- a/src/core/resolver/fake/fake_resolver.h +++ b/src/core/resolver/fake/fake_resolver.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_FAKE_FAKE_RESOLVER_H #define GRPC_SRC_CORE_RESOLVER_FAKE_FAKE_RESOLVER_H -#include - #include #include "absl/base/thread_annotations.h" @@ -27,6 +25,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/notification.h" diff --git a/src/core/resolver/google_c2p/google_c2p_resolver.cc b/src/core/resolver/google_c2p/google_c2p_resolver.cc index 254c34a2537..18705a896d0 100644 --- a/src/core/resolver/google_c2p/google_c2p_resolver.cc +++ b/src/core/resolver/google_c2p/google_c2p_resolver.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include #include @@ -31,6 +29,7 @@ #include #include +#include #include "src/core/ext/gcp/metadata_query.h" #include "src/core/ext/xds/xds_bootstrap.h" @@ -46,12 +45,12 @@ #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/json/json.h" #include "src/core/lib/json/json_writer.h" -#include "src/core/resolver/resolver.h" -#include "src/core/resolver/resolver_factory.h" -#include "src/core/resolver/resolver_registry.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/security/credentials/alts/check_gcp_environment.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/resolver/resolver.h" +#include "src/core/resolver/resolver_factory.h" +#include "src/core/resolver/resolver_registry.h" namespace grpc_core { diff --git a/src/core/resolver/polling_resolver.cc b/src/core/resolver/polling_resolver.cc index 74bd5c05ece..0a1f79a52e2 100644 --- a/src/core/resolver/polling_resolver.cc +++ b/src/core/resolver/polling_resolver.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/resolver/polling_resolver.h" #include @@ -31,6 +29,7 @@ #include "absl/strings/strip.h" #include +#include #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" @@ -38,9 +37,9 @@ #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/work_serializer.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/service_config/service_config.h" -#include "src/core/lib/uri/uri_parser.h" namespace grpc_core { diff --git a/src/core/resolver/polling_resolver.h b/src/core/resolver/polling_resolver.h index 961ec493225..e37c04722c3 100644 --- a/src/core/resolver/polling_resolver.h +++ b/src/core/resolver/polling_resolver.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_POLLING_RESOLVER_H #define GRPC_SRC_CORE_RESOLVER_POLLING_RESOLVER_H -#include - #include #include @@ -26,6 +24,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/resolver/resolver.cc b/src/core/resolver/resolver.cc index c1135731ea8..f4910a70d5c 100644 --- a/src/core/resolver/resolver.cc +++ b/src/core/resolver/resolver.cc @@ -16,10 +16,10 @@ // // -#include - #include "src/core/resolver/resolver.h" +#include + grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount(false, "resolver_refcount"); diff --git a/src/core/resolver/resolver.h b/src/core/resolver/resolver.h index 107f92ff4b4..99108a63b38 100644 --- a/src/core/resolver/resolver.h +++ b/src/core/resolver/resolver.h @@ -17,14 +17,14 @@ #ifndef GRPC_SRC_CORE_RESOLVER_RESOLVER_H #define GRPC_SRC_CORE_RESOLVER_RESOLVER_H -#include - #include #include #include "absl/status/status.h" #include "absl/status/statusor.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/resolver/resolver_factory.h b/src/core/resolver/resolver_factory.h index 889c50190a5..e4cc5347386 100644 --- a/src/core/resolver/resolver_factory.h +++ b/src/core/resolver/resolver_factory.h @@ -17,19 +17,19 @@ #ifndef GRPC_SRC_CORE_RESOLVER_RESOLVER_FACTORY_H #define GRPC_SRC_CORE_RESOLVER_RESOLVER_FACTORY_H -#include - #include #include #include "absl/strings/string_view.h" #include "absl/strings/strip.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/iomgr_fwd.h" -#include "src/core/resolver/resolver.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/resolver/resolver.h" namespace grpc_core { diff --git a/src/core/resolver/resolver_registry.cc b/src/core/resolver/resolver_registry.cc index 1edc210ccb9..47930c25cb4 100644 --- a/src/core/resolver/resolver_registry.cc +++ b/src/core/resolver/resolver_registry.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/resolver/resolver_registry.h" #include "absl/status/status.h" @@ -25,6 +23,7 @@ #include "absl/strings/str_format.h" #include +#include namespace grpc_core { diff --git a/src/core/resolver/resolver_registry.h b/src/core/resolver/resolver_registry.h index 4de325da7a5..cb8512d7e53 100644 --- a/src/core/resolver/resolver_registry.h +++ b/src/core/resolver/resolver_registry.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_RESOLVER_RESOLVER_REGISTRY_H #define GRPC_SRC_CORE_RESOLVER_RESOLVER_REGISTRY_H -#include - #include #include #include @@ -26,12 +24,14 @@ #include "absl/strings/string_view.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/iomgr_fwd.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" -#include "src/core/lib/uri/uri_parser.h" namespace grpc_core { diff --git a/src/core/resolver/sockaddr/sockaddr_resolver.cc b/src/core/resolver/sockaddr/sockaddr_resolver.cc index a980d1f1ccc..f3996b3c69b 100644 --- a/src/core/resolver/sockaddr/sockaddr_resolver.cc +++ b/src/core/resolver/sockaddr/sockaddr_resolver.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include #include @@ -26,6 +24,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/channel/channel_args.h" @@ -33,10 +32,10 @@ #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/uri/uri_parser.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/resolver.h" #include "src/core/resolver/resolver_factory.h" -#include "src/core/lib/uri/uri_parser.h" namespace grpc_core { diff --git a/src/core/resolver/xds/xds_dependency_manager.cc b/src/core/resolver/xds/xds_dependency_manager.cc index b9e37bca0bf..182fe249e7e 100644 --- a/src/core/resolver/xds/xds_dependency_manager.cc +++ b/src/core/resolver/xds/xds_dependency_manager.cc @@ -14,14 +14,14 @@ // limitations under the License. // -#include - #include "src/core/resolver/xds/xds_dependency_manager.h" #include #include "absl/strings/str_join.h" +#include + #include "src/core/ext/xds/xds_routing.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/match.h" diff --git a/src/core/resolver/xds/xds_dependency_manager.h b/src/core/resolver/xds/xds_dependency_manager.h index 263471174cb..903c8b95e89 100644 --- a/src/core/resolver/xds/xds_dependency_manager.h +++ b/src/core/resolver/xds/xds_dependency_manager.h @@ -17,12 +17,12 @@ #ifndef GRPC_SRC_CORE_RESOLVER_XDS_XDS_DEPENDENCY_MANAGER_H #define GRPC_SRC_CORE_RESOLVER_XDS_XDS_DEPENDENCY_MANAGER_H -#include - #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/string_view.h" +#include + #include "src/core/ext/xds/xds_client_grpc.h" #include "src/core/ext/xds/xds_cluster.h" #include "src/core/ext/xds/xds_endpoint.h" diff --git a/src/core/resolver/xds/xds_resolver.cc b/src/core/resolver/xds/xds_resolver.cc index 13efe8a5099..537401f4361 100644 --- a/src/core/resolver/xds/xds_resolver.cc +++ b/src/core/resolver/xds/xds_resolver.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include #include @@ -47,6 +45,7 @@ #include #include #include +#include #include "src/core/client_channel/client_channel_internal.h" #include "src/core/client_channel/config_selector.h" diff --git a/src/core/resolver/xds/xds_resolver_attributes.h b/src/core/resolver/xds/xds_resolver_attributes.h index 27720d31113..0d70624dcdd 100644 --- a/src/core/resolver/xds/xds_resolver_attributes.h +++ b/src/core/resolver/xds/xds_resolver_attributes.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_RESOLVER_XDS_XDS_RESOLVER_ATTRIBUTES_H #define GRPC_SRC_CORE_RESOLVER_XDS_XDS_RESOLVER_ATTRIBUTES_H -#include - #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/service_config/service_config_call_data.h" diff --git a/src/core/resolver/xds/xds_resolver_trace.cc b/src/core/resolver/xds/xds_resolver_trace.cc index a97ac81b010..e9986e2cef7 100644 --- a/src/core/resolver/xds/xds_resolver_trace.cc +++ b/src/core/resolver/xds/xds_resolver_trace.cc @@ -14,10 +14,10 @@ // limitations under the License. // -#include - #include "src/core/resolver/xds/xds_resolver_trace.h" +#include + namespace grpc_core { TraceFlag grpc_xds_resolver_trace(false, "xds_resolver"); diff --git a/src/core/service_config/service_config.h b/src/core/service_config/service_config.h index 6453e2401cc..7935150fb2c 100644 --- a/src/core/service_config/service_config.h +++ b/src/core/service_config/service_config.h @@ -17,13 +17,12 @@ #ifndef GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_H #define GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_H -#include - #include #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/ref_counted.h" diff --git a/src/core/service_config/service_config_call_data.h b/src/core/service_config/service_config_call_data.h index b549f4dcaaf..a422893c6e2 100644 --- a/src/core/service_config/service_config_call_data.h +++ b/src/core/service_config/service_config_call_data.h @@ -17,13 +17,13 @@ #ifndef GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H #define GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_CALL_DATA_H -#include - #include #include #include +#include + #include "src/core/lib/channel/context.h" #include "src/core/lib/gprpp/chunked_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/service_config/service_config_impl.cc b/src/core/service_config/service_config_impl.cc index ccd0559b579..78b66bd7f43 100644 --- a/src/core/service_config/service_config_impl.cc +++ b/src/core/service_config/service_config_impl.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/service_config/service_config_impl.h" #include @@ -28,6 +26,8 @@ #include "absl/strings/str_cat.h" #include "absl/types/optional.h" +#include + #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/validation_errors.h" diff --git a/src/core/service_config/service_config_impl.h b/src/core/service_config/service_config_impl.h index 499110d11c3..2de5f7377be 100644 --- a/src/core/service_config/service_config_impl.h +++ b/src/core/service_config/service_config_impl.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_IMPL_H #define GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_IMPL_H -#include - #include #include @@ -31,6 +29,7 @@ #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/service_config/service_config_parser.cc b/src/core/service_config/service_config_parser.cc index e67c8a509fd..de39251b0d4 100644 --- a/src/core/service_config/service_config_parser.cc +++ b/src/core/service_config/service_config_parser.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/service_config/service_config_parser.h" #include @@ -25,6 +23,7 @@ #include "absl/strings/str_cat.h" #include +#include namespace grpc_core { diff --git a/src/core/service_config/service_config_parser.h b/src/core/service_config/service_config_parser.h index f0f91f896bc..d911f869ad0 100644 --- a/src/core/service_config/service_config_parser.h +++ b/src/core/service_config/service_config_parser.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H #define GRPC_SRC_CORE_SERVICE_CONFIG_SERVICE_CONFIG_PARSER_H -#include - #include #include @@ -28,6 +26,8 @@ #include "absl/strings/string_view.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/validation_errors.h" #include "src/core/lib/json/json.h" diff --git a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh index ef654434917..ffd486b5f6a 100755 --- a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh +++ b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh @@ -16,7 +16,7 @@ set -e # directories to run against -DIRS="examples/cpp examples/android/binder src/core/lib src/core/tsi src/core/ext src/cpp test/core test/cpp include src/compiler src/ruby src/objective-c tools/distrib/python src/python/grpcio_observability" +DIRS="examples/cpp examples/android/binder src/core src/cpp test/core test/cpp include src/compiler src/ruby src/objective-c tools/distrib/python src/python/grpcio_observability" # file matching patterns to check GLOB="*.h *.c *.cc *.m *.mm" From 9c704b69621ac485661e373ed30ba40d0b76a8b3 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 18 Apr 2024 15:43:32 -0700 Subject: [PATCH 27/45] [xds] ToString: Output telemetry labels from cluster resource (#36401) Closes #36401 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36401 from yashykt:LogServiceNameLabels 5a22a5c6cc72e116d77ca634cdfd5d60d62532e5 PiperOrigin-RevId: 626171767 --- src/core/ext/xds/xds_cluster.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/ext/xds/xds_cluster.cc b/src/core/ext/xds/xds_cluster.cc index 194a88d5e49..313d513bf74 100644 --- a/src/core/ext/xds/xds_cluster.cc +++ b/src/core/ext/xds/xds_cluster.cc @@ -116,6 +116,15 @@ std::string XdsClusterResource::ToString() const { absl::StrCat("max_concurrent_requests=", max_concurrent_requests)); contents.push_back(absl::StrCat("override_host_statuses=", override_host_statuses.ToString())); + if (!service_telemetry_label.as_string_view().empty()) { + contents.push_back(absl::StrCat("service_name_telemetry_label=", + service_telemetry_label.as_string_view())); + } + if (!namespace_telemetry_label.as_string_view().empty()) { + contents.push_back( + absl::StrCat("service_namespace_telemetry_label=", + namespace_telemetry_label.as_string_view())); + } return absl::StrCat("{", absl::StrJoin(contents, ", "), "}"); } From f6ee70289dd79622ec4dca93728f1193b696eae8 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Thu, 18 Apr 2024 18:03:06 -0700 Subject: [PATCH 28/45] [ObjC] Update abseil and boring ssl versions (#36356) Update abseil and boring ssl versions Closes #36356 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36356 from HannahShiSFB:update-pod-swift-dependencies dcf33c8824b128708fad064c7be32c1aba17f7ee PiperOrigin-RevId: 626206584 --- Package.swift | 4 ++-- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 2 +- templates/Package.swift.template | 4 ++-- templates/gRPC-C++.podspec.template | 2 +- templates/gRPC-Core.podspec.template | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index ce9e5e1bed5..b9ce42b95e9 100644 --- a/Package.swift +++ b/Package.swift @@ -23,8 +23,8 @@ let package = Package( ], dependencies: [ - .package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20230802.0"..<"0.20230803.0"), - .package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.9.0"..<"0.10.0"), + .package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20240116.1"..<"0.20240117.0"), + .package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.32.0"..<"0.33.0"), ], targets: [ diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 9114af3c0d9..046f9667500 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -225,7 +225,7 @@ Pod::Spec.new do |s| ss.dependency "#{s.name}/Privacy", version ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version - abseil_version = '1.20240116.1' + abseil_version = '~> 1.20240116.2' ss.dependency 'abseil/algorithm/container', abseil_version ss.dependency 'abseil/base/base', abseil_version ss.dependency 'abseil/base/config', abseil_version diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1624bceaeb2..1f25780fb3a 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -46,7 +46,7 @@ Pod::Spec.new do |s| s.requires_arc = false name = 'grpc' - abseil_version = '1.20240116.1' + abseil_version = '~> 1.20240116.2' # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework. # This lets users write their includes like `#include ` as opposed to `#include diff --git a/templates/Package.swift.template b/templates/Package.swift.template index 23334c0bc8b..496cd2686c2 100644 --- a/templates/Package.swift.template +++ b/templates/Package.swift.template @@ -25,8 +25,8 @@ ], dependencies: [ - .package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20230802.0"..<"0.20230803.0"), - .package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.9.0"..<"0.10.0"), + .package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20240116.1"..<"0.20240117.0"), + .package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.32.0"..<"0.33.0"), ], targets: [ diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template index b4c24348bf1..3231a52e24a 100644 --- a/templates/gRPC-C++.podspec.template +++ b/templates/gRPC-C++.podspec.template @@ -183,7 +183,7 @@ ss.dependency "#{s.name}/Privacy", version ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version - abseil_version = '1.20240116.1' + abseil_version = '~> 1.20240116.2' % for abseil_spec in grpcpp_abseil_specs: ss.dependency '${abseil_spec}', abseil_version % endfor diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index c3a0b10b0f3..6fe258801c9 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -122,7 +122,7 @@ s.requires_arc = false name = 'grpc' - abseil_version = '1.20240116.1' + abseil_version = '~> 1.20240116.2' # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework. # This lets users write their includes like `#include ` as opposed to `#include From ba78e4ff475550e1fa3fd09fbcee326c3c6dfd5a Mon Sep 17 00:00:00 2001 From: Yijie Ma Date: Thu, 18 Apr 2024 18:04:10 -0700 Subject: [PATCH 29/45] [test] Wait for `RecordEnd` in `FakeClientCallAttemptTracer` destruction (#36396) Closes #36396 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36396 from yijiem:xds-cluster-end2end-test-twin 26062ea1b4584d4408cc274d96b90a37fab5c70b PiperOrigin-RevId: 626207011 --- src/cpp/ext/otel/otel_plugin.cc | 2 +- test/core/channel/call_tracer_test.cc | 1 + test/core/util/fake_stats_plugin.h | 17 +++++++++-------- .../cpp/end2end/xds/xds_cluster_end2end_test.cc | 7 ------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/cpp/ext/otel/otel_plugin.cc b/src/cpp/ext/otel/otel_plugin.cc index de527591a0d..5546b21c8a3 100644 --- a/src/cpp/ext/otel/otel_plugin.cc +++ b/src/cpp/ext/otel/otel_plugin.cc @@ -104,7 +104,7 @@ class OpenTelemetryPlugin::NPCMetricsKeyValueIterable bool(opentelemetry::nostd::string_view, opentelemetry::common::AttributeValue)> callback) const noexcept override { - for (size_t i = 0; i < label_keys_.size(); i++) { + for (size_t i = 0; i < label_keys_.size(); ++i) { if (!callback(AbslStrViewToOpenTelemetryStrView(label_keys_[i]), AbslStrViewToOpenTelemetryStrView(label_values_[i]))) { return false; diff --git a/test/core/channel/call_tracer_test.cc b/test/core/channel/call_tracer_test.cc index d83093cb128..4950e8d0276 100644 --- a/test/core/channel/call_tracer_test.cc +++ b/test/core/channel/call_tracer_test.cc @@ -94,6 +94,7 @@ TEST_F(CallTracerTest, MultipleClientCallAttemptTracers) { attempt_tracer->RecordAnnotation("Test"); EXPECT_EQ(annotation_logger_, std::vector({"Test", "Test", "Test"})); + attempt_tracer->RecordEnd(gpr_timespec()); } TEST_F(CallTracerTest, BasicServerCallTracerTest) { diff --git a/test/core/util/fake_stats_plugin.h b/test/core/util/fake_stats_plugin.h index 4b3a4018fa3..8a32e4992c0 100644 --- a/test/core/util/fake_stats_plugin.h +++ b/test/core/util/fake_stats_plugin.h @@ -31,6 +31,7 @@ #include "src/core/lib/channel/metrics.h" #include "src/core/lib/channel/promise_based_filter.h" #include "src/core/lib/channel/tcp_tracer.h" +#include "src/core/lib/gprpp/ref_counted.h" namespace grpc_core { @@ -59,12 +60,12 @@ void RegisterFakeStatsPlugin(); class FakeClientCallTracer : public ClientCallTracer { public: class FakeClientCallAttemptTracer - : public ClientCallTracer::CallAttemptTracer { + : public ClientCallTracer::CallAttemptTracer, + public RefCounted { public: explicit FakeClientCallAttemptTracer( std::vector* annotation_logger) : annotation_logger_(annotation_logger) {} - ~FakeClientCallAttemptTracer() override {} void RecordSendInitialMetadata( grpc_metadata_batch* /*send_initial_metadata*/) override {} void RecordSendTrailingMetadata( @@ -83,7 +84,7 @@ class FakeClientCallTracer : public ClientCallTracer { grpc_metadata_batch* /*recv_trailing_metadata*/, const grpc_transport_stream_stats* /*transport_stream_stats*/) override {} - void RecordEnd(const gpr_timespec& /*latency*/) override {} + void RecordEnd(const gpr_timespec& /*latency*/) override { Unref(); } void RecordAnnotation(absl::string_view annotation) override { annotation_logger_->push_back(std::string(annotation)); } @@ -113,9 +114,10 @@ class FakeClientCallTracer : public ClientCallTracer { : annotation_logger_(annotation_logger) {} ~FakeClientCallTracer() override {} CallAttemptTracer* StartNewAttempt(bool /*is_transparent_retry*/) override { - call_attempt_tracers_.emplace_back( - new FakeClientCallAttemptTracer(annotation_logger_)); - return call_attempt_tracers_.back().get(); + auto call_attempt_tracer = + MakeRefCounted(annotation_logger_); + call_attempt_tracers_.emplace_back(call_attempt_tracer); + return call_attempt_tracer.release(); // Released in RecordEnd(). } void RecordAnnotation(absl::string_view annotation) override { @@ -132,8 +134,7 @@ class FakeClientCallTracer : public ClientCallTracer { private: std::vector* annotation_logger_; - std::vector> - call_attempt_tracers_; + std::vector> call_attempt_tracers_; }; #define GRPC_ARG_INJECT_FAKE_CLIENT_CALL_TRACER_FACTORY \ diff --git a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc index 41780a96313..d52e767053b 100644 --- a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc @@ -355,13 +355,6 @@ TEST_P(CdsTest, MetricLabels) { "mynamespace"), ::testing::Pair(OptionalLabelKey::kLocality, LocalityNameString("locality1")))); - // TODO(yashkt, yijiem): This shutdown shouldn't actually be necessary. The - // only reason it's here is to add a delay before - // fake_client_call_tracer_factory goes out of scope, since there may be - // lingering callbacks in the call stack that are using the CallAttemptTracer - // even after we get here, which would then cause a crash. Find a cleaner way - // to fix this. - balancer_->Shutdown(); } // From 08f56b3a74c6851a62d8fe775077c4ea97b0815e Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 19 Apr 2024 13:02:52 -0700 Subject: [PATCH 30/45] [reorg] move channelz code to src/core/channelz (#36380) Closes #36380 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36380 from markdroth:reorg_channelz f186e53f70819e3b780e566ab3089b2b9ed5fca1 PiperOrigin-RevId: 626447939 --- BUILD | 14 ++- CMakeLists.txt | 20 ++-- Makefile | 7 +- Package.swift | 14 ++- build_autogenerated.yaml | 40 ++++---- config.m4 | 8 +- config.w32 | 8 +- gRPC-C++.podspec | 18 ++-- gRPC-Core.podspec | 25 +++-- grpc.gemspec | 14 ++- package.xml | 14 ++- src/core/BUILD | 24 ----- .../channel => channelz}/channel_trace.cc | 4 +- .../{lib/channel => channelz}/channel_trace.h | 6 +- .../{lib/channel => channelz}/channelz.cc | 66 ++++++++++++- src/core/{lib/channel => channelz}/channelz.h | 48 +++++++++- .../channel => channelz}/channelz_registry.cc | 4 +- .../channel => channelz}/channelz_registry.h | 8 +- .../client_channel/client_channel_channelz.cc | 93 ------------------- .../client_channel/client_channel_channelz.h | 85 ----------------- .../client_channel/client_channel_filter.cc | 3 +- .../client_channel/client_channel_filter.h | 2 +- src/core/client_channel/connector.h | 2 +- src/core/client_channel/subchannel.cc | 4 +- src/core/client_channel/subchannel.h | 1 - .../chaotic_good/server/chaotic_good_server.h | 2 +- .../chttp2/client/chttp2_connector.cc | 2 +- .../transport/chttp2/server/chttp2_server.cc | 2 +- .../chttp2/transport/chttp2_transport.h | 2 +- .../ext/transport/chttp2/transport/internal.h | 2 +- .../ext/transport/chttp2/transport/parsing.cc | 2 +- .../ext/transport/chttp2/transport/writing.cc | 2 +- .../inproc/legacy_inproc_transport.cc | 2 +- .../security/transport/security_handshaker.cc | 2 +- src/core/lib/surface/call.cc | 2 +- src/core/lib/surface/channel.cc | 4 +- src/core/lib/surface/channel.h | 2 +- src/core/lib/surface/channel_create.cc | 2 +- src/core/lib/surface/legacy_channel.cc | 2 +- src/core/lib/surface/server.cc | 4 +- src/core/lib/surface/server.h | 2 +- src/core/lib/surface/server_interface.h | 2 +- src/core/load_balancing/grpclb/grpclb.cc | 2 +- .../load_balancing/health_check_client.cc | 3 +- src/core/load_balancing/oob_backend_metric.cc | 3 +- src/core/load_balancing/rls/rls.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 7 +- test/core/bad_client/bad_client.cc | 2 +- test/core/bad_connection/close_fd_test.cc | 2 +- test/core/channel/channel_trace_test.cc | 4 +- test/core/channel/channelz_registry_test.cc | 4 +- test/core/channel/channelz_test.cc | 4 +- test/core/end2end/fixtures/sockpair_fixture.h | 2 +- test/core/end2end/tests/channelz.cc | 2 +- test/core/end2end/tests/retry_streaming.cc | 2 +- .../chttp2/graceful_shutdown_test.cc | 2 +- tools/doxygen/Doxyfile.c++.internal | 14 ++- tools/doxygen/Doxyfile.core.internal | 14 ++- 58 files changed, 255 insertions(+), 384 deletions(-) rename src/core/{lib/channel => channelz}/channel_trace.cc (98%) rename src/core/{lib/channel => channelz}/channel_trace.h (96%) rename src/core/{lib/channel => channelz}/channelz.cc (90%) rename src/core/{lib/channel => channelz}/channelz.h (87%) rename src/core/{lib/channel => channelz}/channelz_registry.cc (99%) rename src/core/{lib/channel => channelz}/channelz_registry.h (93%) delete mode 100644 src/core/client_channel/client_channel_channelz.cc delete mode 100644 src/core/client_channel/client_channel_channelz.h diff --git a/BUILD b/BUILD index 894186b35f2..ae8e518fffd 100644 --- a/BUILD +++ b/BUILD @@ -1348,14 +1348,14 @@ grpc_cc_library( grpc_cc_library( name = "channelz", srcs = [ - "//src/core:lib/channel/channel_trace.cc", - "//src/core:lib/channel/channelz.cc", - "//src/core:lib/channel/channelz_registry.cc", + "//src/core:channelz/channel_trace.cc", + "//src/core:channelz/channelz.cc", + "//src/core:channelz/channelz_registry.cc", ], hdrs = [ - "//src/core:lib/channel/channel_trace.h", - "//src/core:lib/channel/channelz.h", - "//src/core:lib/channel/channelz_registry.h", + "//src/core:channelz/channel_trace.h", + "//src/core:channelz/channelz.h", + "//src/core:channelz/channelz_registry.h", ], external_deps = [ "absl/base:core_headers", @@ -3532,7 +3532,6 @@ grpc_cc_library( "xds_orca_service_upb", "xds_orca_upb", "//src/core:backend_metric_parser", - "//src/core:client_channel_channelz", "//src/core:closure", "//src/core:error", "//src/core:grpc_backend_metric_data", @@ -3666,7 +3665,6 @@ grpc_cc_library( "//src/core:channel_init", "//src/core:channel_stack_type", "//src/core:client_channel_backup_poller", - "//src/core:client_channel_channelz", "//src/core:client_channel_internal_header", "//src/core:client_channel_service_config", "//src/core:closure", diff --git a/CMakeLists.txt b/CMakeLists.txt index bce2fd580fe..c7db2d856ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1819,8 +1819,10 @@ endif() add_library(grpc + src/core/channelz/channel_trace.cc + src/core/channelz/channelz.cc + src/core/channelz/channelz_registry.cc src/core/client_channel/backup_poller.cc - src/core/client_channel/client_channel_channelz.cc src/core/client_channel/client_channel_factory.cc src/core/client_channel/client_channel_filter.cc src/core/client_channel/client_channel_plugin.cc @@ -2245,9 +2247,6 @@ add_library(grpc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_stack_builder_impl.cc src/core/lib/channel/channel_stack_trace.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/metrics.cc src/core/lib/channel/promise_based_filter.cc @@ -2916,8 +2915,10 @@ endif() endif() add_library(grpc_unsecure + src/core/channelz/channel_trace.cc + src/core/channelz/channelz.cc + src/core/channelz/channelz_registry.cc src/core/client_channel/backup_poller.cc - src/core/client_channel/client_channel_channelz.cc src/core/client_channel/client_channel_factory.cc src/core/client_channel/client_channel_filter.cc src/core/client_channel/client_channel_plugin.cc @@ -3011,9 +3012,6 @@ add_library(grpc_unsecure src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_stack_builder_impl.cc src/core/lib/channel/channel_stack_trace.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/metrics.cc src/core/lib/channel/promise_based_filter.cc @@ -5113,6 +5111,9 @@ endif() add_library(grpc_authorization_provider + src/core/channelz/channel_trace.cc + src/core/channelz/channelz.cc + src/core/channelz/channelz_registry.cc src/core/ext/upb-gen/google/protobuf/any.upb_minitable.c src/core/ext/upb-gen/google/rpc/status.upb_minitable.c src/core/ext/upb-gen/src/proto/grpc/gcp/altscontext.upb_minitable.c @@ -5128,9 +5129,6 @@ add_library(grpc_authorization_provider src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_stack_builder_impl.cc src/core/lib/channel/channel_stack_trace.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/metrics.cc src/core/lib/channel/promise_based_filter.cc diff --git a/Makefile b/Makefile index 30be778e03d..33f21133e1f 100644 --- a/Makefile +++ b/Makefile @@ -666,8 +666,10 @@ clean: # deps: ['cares', 'libssl', 'z'] # transitive_deps: ['cares', 'libssl', 'z'] LIBGRPC_SRC = \ + src/core/channelz/channel_trace.cc \ + src/core/channelz/channelz.cc \ + src/core/channelz/channelz_registry.cc \ src/core/client_channel/backup_poller.cc \ - src/core/client_channel/client_channel_channelz.cc \ src/core/client_channel/client_channel_factory.cc \ src/core/client_channel/client_channel_filter.cc \ src/core/client_channel/client_channel_plugin.cc \ @@ -1092,9 +1094,6 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder_impl.cc \ src/core/lib/channel/channel_stack_trace.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/metrics.cc \ src/core/lib/channel/promise_based_filter.cc \ diff --git a/Package.swift b/Package.swift index b9ce42b95e9..0eb0d795a66 100644 --- a/Package.swift +++ b/Package.swift @@ -117,10 +117,14 @@ let package = Package( "include/grpc/support/thd_id.h", "include/grpc/support/time.h", "include/grpc/support/workaround_list.h", + "src/core/channelz/channel_trace.cc", + "src/core/channelz/channel_trace.h", + "src/core/channelz/channelz.cc", + "src/core/channelz/channelz.h", + "src/core/channelz/channelz_registry.cc", + "src/core/channelz/channelz_registry.h", "src/core/client_channel/backup_poller.cc", "src/core/client_channel/backup_poller.h", - "src/core/client_channel/client_channel_channelz.cc", - "src/core/client_channel/client_channel_channelz.h", "src/core/client_channel/client_channel_factory.cc", "src/core/client_channel/client_channel_factory.h", "src/core/client_channel/client_channel_filter.cc", @@ -1144,12 +1148,6 @@ let package = Package( "src/core/lib/channel/channel_stack_builder_impl.h", "src/core/lib/channel/channel_stack_trace.cc", "src/core/lib/channel/channel_stack_trace.h", - "src/core/lib/channel/channel_trace.cc", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channelz.cc", - "src/core/lib/channel/channelz.h", - "src/core/lib/channel/channelz_registry.cc", - "src/core/lib/channel/channelz_registry.h", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 0418b6ae26a..e8e69293969 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -221,8 +221,10 @@ libs: - include/grpc/support/time.h - include/grpc/support/workaround_list.h headers: + - src/core/channelz/channel_trace.h + - src/core/channelz/channelz.h + - src/core/channelz/channelz_registry.h - src/core/client_channel/backup_poller.h - - src/core/client_channel/client_channel_channelz.h - src/core/client_channel/client_channel_factory.h - src/core/client_channel/client_channel_filter.h - src/core/client_channel/client_channel_internal.h @@ -822,9 +824,6 @@ libs: - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_stack_builder_impl.h - src/core/lib/channel/channel_stack_trace.h - - src/core/lib/channel/channel_trace.h - - src/core/lib/channel/channelz.h - - src/core/lib/channel/channelz_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/metrics.h @@ -1245,8 +1244,10 @@ libs: - third_party/upb/upb/generated_code_support.h - third_party/xxhash/xxhash.h src: + - src/core/channelz/channel_trace.cc + - src/core/channelz/channelz.cc + - src/core/channelz/channelz_registry.cc - src/core/client_channel/backup_poller.cc - - src/core/client_channel/client_channel_channelz.cc - src/core/client_channel/client_channel_factory.cc - src/core/client_channel/client_channel_filter.cc - src/core/client_channel/client_channel_plugin.cc @@ -1671,9 +1672,6 @@ libs: - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_stack_builder_impl.cc - src/core/lib/channel/channel_stack_trace.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/metrics.cc - src/core/lib/channel/promise_based_filter.cc @@ -2209,8 +2207,10 @@ libs: - include/grpc/support/time.h - include/grpc/support/workaround_list.h headers: + - src/core/channelz/channel_trace.h + - src/core/channelz/channelz.h + - src/core/channelz/channelz_registry.h - src/core/client_channel/backup_poller.h - - src/core/client_channel/client_channel_channelz.h - src/core/client_channel/client_channel_factory.h - src/core/client_channel/client_channel_filter.h - src/core/client_channel/client_channel_internal.h @@ -2327,9 +2327,6 @@ libs: - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_stack_builder_impl.h - src/core/lib/channel/channel_stack_trace.h - - src/core/lib/channel/channel_trace.h - - src/core/lib/channel/channelz.h - - src/core/lib/channel/channelz_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/metrics.h @@ -2702,8 +2699,10 @@ libs: - third_party/upb/upb/wire/reader.h - third_party/upb/upb/wire/types.h src: + - src/core/channelz/channel_trace.cc + - src/core/channelz/channelz.cc + - src/core/channelz/channelz_registry.cc - src/core/client_channel/backup_poller.cc - - src/core/client_channel/client_channel_channelz.cc - src/core/client_channel/client_channel_factory.cc - src/core/client_channel/client_channel_filter.cc - src/core/client_channel/client_channel_plugin.cc @@ -2797,9 +2796,6 @@ libs: - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_stack_builder_impl.cc - src/core/lib/channel/channel_stack_trace.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/metrics.cc - src/core/lib/channel/promise_based_filter.cc @@ -4395,6 +4391,9 @@ libs: - include/grpc/support/time.h - include/grpc/support/workaround_list.h headers: + - src/core/channelz/channel_trace.h + - src/core/channelz/channelz.h + - src/core/channelz/channelz_registry.h - src/core/ext/upb-gen/google/protobuf/any.upb.h - src/core/ext/upb-gen/google/protobuf/any.upb_minitable.h - src/core/ext/upb-gen/google/rpc/status.upb.h @@ -4418,9 +4417,6 @@ libs: - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_stack_builder_impl.h - src/core/lib/channel/channel_stack_trace.h - - src/core/lib/channel/channel_trace.h - - src/core/lib/channel/channelz.h - - src/core/lib/channel/channelz_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/metrics.h @@ -4747,6 +4743,9 @@ libs: - third_party/upb/upb/wire/reader.h - third_party/upb/upb/wire/types.h src: + - src/core/channelz/channel_trace.cc + - src/core/channelz/channelz.cc + - src/core/channelz/channelz_registry.cc - src/core/ext/upb-gen/google/protobuf/any.upb_minitable.c - src/core/ext/upb-gen/google/rpc/status.upb_minitable.c - src/core/ext/upb-gen/src/proto/grpc/gcp/altscontext.upb_minitable.c @@ -4762,9 +4761,6 @@ libs: - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_stack_builder_impl.cc - src/core/lib/channel/channel_stack_trace.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/metrics.cc - src/core/lib/channel/promise_based_filter.cc diff --git a/config.m4 b/config.m4 index d103e945a6b..be7973006b8 100644 --- a/config.m4 +++ b/config.m4 @@ -41,8 +41,10 @@ if test "$PHP_GRPC" != "no"; then PHP_SUBST(GRPC_SHARED_LIBADD) PHP_NEW_EXTENSION(grpc, + src/core/channelz/channel_trace.cc \ + src/core/channelz/channelz.cc \ + src/core/channelz/channelz_registry.cc \ src/core/client_channel/backup_poller.cc \ - src/core/client_channel/client_channel_channelz.cc \ src/core/client_channel/client_channel_factory.cc \ src/core/client_channel/client_channel_filter.cc \ src/core/client_channel/client_channel_plugin.cc \ @@ -467,9 +469,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder_impl.cc \ src/core/lib/channel/channel_stack_trace.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/metrics.cc \ src/core/lib/channel/promise_based_filter.cc \ @@ -1383,6 +1382,7 @@ if test "$PHP_GRPC" != "no"; then -DGRPC_XDS_USER_AGENT_NAME_SUFFIX='"\"PHP\""' \ -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX='"\"1.64.0dev\""') + PHP_ADD_BUILD_DIR($ext_builddir/src/core/channelz) PHP_ADD_BUILD_DIR($ext_builddir/src/core/client_channel) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/backend_metrics) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/census) diff --git a/config.w32 b/config.w32 index f5fc445b434..3ab3dbfdf22 100644 --- a/config.w32 +++ b/config.w32 @@ -6,8 +6,10 @@ ARG_WITH("grpc", "grpc support", "no"); if (PHP_GRPC != "no") { EXTENSION("grpc", + "src\\core\\channelz\\channel_trace.cc " + + "src\\core\\channelz\\channelz.cc " + + "src\\core\\channelz\\channelz_registry.cc " + "src\\core\\client_channel\\backup_poller.cc " + - "src\\core\\client_channel\\client_channel_channelz.cc " + "src\\core\\client_channel\\client_channel_factory.cc " + "src\\core\\client_channel\\client_channel_filter.cc " + "src\\core\\client_channel\\client_channel_plugin.cc " + @@ -432,9 +434,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_stack_builder.cc " + "src\\core\\lib\\channel\\channel_stack_builder_impl.cc " + "src\\core\\lib\\channel\\channel_stack_trace.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\\metrics.cc " + "src\\core\\lib\\channel\\promise_based_filter.cc " + @@ -1375,6 +1374,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\channelz"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\client_channel"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 046f9667500..85099db02ee 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -260,8 +260,10 @@ Pod::Spec.new do |s| ss.dependency 'abseil/types/variant', abseil_version ss.dependency 'abseil/utility/utility', abseil_version - ss.source_files = 'src/core/client_channel/backup_poller.h', - 'src/core/client_channel/client_channel_channelz.h', + ss.source_files = 'src/core/channelz/channel_trace.h', + 'src/core/channelz/channelz.h', + 'src/core/channelz/channelz_registry.h', + 'src/core/client_channel/backup_poller.h', 'src/core/client_channel/client_channel_factory.h', 'src/core/client_channel/client_channel_filter.h', 'src/core/client_channel/client_channel_internal.h', @@ -900,9 +902,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_stack_builder_impl.h', 'src/core/lib/channel/channel_stack_trace.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channelz.h', - 'src/core/lib/channel/channelz_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', @@ -1550,8 +1549,10 @@ Pod::Spec.new do |s| 'third_party/zlib/zlib.h', 'third_party/zlib/zutil.h' - ss.private_header_files = 'src/core/client_channel/backup_poller.h', - 'src/core/client_channel/client_channel_channelz.h', + ss.private_header_files = 'src/core/channelz/channel_trace.h', + 'src/core/channelz/channelz.h', + 'src/core/channelz/channelz_registry.h', + 'src/core/client_channel/backup_poller.h', 'src/core/client_channel/client_channel_factory.h', 'src/core/client_channel/client_channel_filter.h', 'src/core/client_channel/client_channel_internal.h', @@ -2172,9 +2173,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_stack_builder_impl.h', 'src/core/lib/channel/channel_stack_trace.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channelz.h', - 'src/core/lib/channel/channelz_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 1f25780fb3a..0d69b0c30d4 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -233,10 +233,14 @@ Pod::Spec.new do |s| ss.dependency 'abseil/utility/utility', abseil_version ss.compiler_flags = '-DBORINGSSL_PREFIX=GRPC -Wno-unreachable-code -Wno-shorten-64-to-32' - ss.source_files = 'src/core/client_channel/backup_poller.cc', + ss.source_files = 'src/core/channelz/channel_trace.cc', + 'src/core/channelz/channel_trace.h', + 'src/core/channelz/channelz.cc', + 'src/core/channelz/channelz.h', + 'src/core/channelz/channelz_registry.cc', + 'src/core/channelz/channelz_registry.h', + 'src/core/client_channel/backup_poller.cc', 'src/core/client_channel/backup_poller.h', - 'src/core/client_channel/client_channel_channelz.cc', - 'src/core/client_channel/client_channel_channelz.h', 'src/core/client_channel/client_channel_factory.cc', 'src/core/client_channel/client_channel_factory.h', 'src/core/client_channel/client_channel_filter.cc', @@ -1260,12 +1264,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack_builder_impl.h', 'src/core/lib/channel/channel_stack_trace.cc', 'src/core/lib/channel/channel_stack_trace.h', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channelz.cc', - 'src/core/lib/channel/channelz.h', - 'src/core/lib/channel/channelz_registry.cc', - 'src/core/lib/channel/channelz_registry.h', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', @@ -2351,8 +2349,10 @@ Pod::Spec.new do |s| 'third_party/zlib/zlib.h', 'third_party/zlib/zutil.c', 'third_party/zlib/zutil.h' - ss.private_header_files = 'src/core/client_channel/backup_poller.h', - 'src/core/client_channel/client_channel_channelz.h', + ss.private_header_files = 'src/core/channelz/channel_trace.h', + 'src/core/channelz/channelz.h', + 'src/core/channelz/channelz_registry.h', + 'src/core/client_channel/backup_poller.h', 'src/core/client_channel/client_channel_factory.h', 'src/core/client_channel/client_channel_filter.h', 'src/core/client_channel/client_channel_internal.h', @@ -2952,9 +2952,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_stack_builder_impl.h', 'src/core/lib/channel/channel_stack_trace.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channelz.h', - 'src/core/lib/channel/channelz_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', diff --git a/grpc.gemspec b/grpc.gemspec index 3a986b6d65e..3c714dd2565 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -123,10 +123,14 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/thd_id.h ) s.files += %w( include/grpc/support/time.h ) s.files += %w( include/grpc/support/workaround_list.h ) + s.files += %w( src/core/channelz/channel_trace.cc ) + s.files += %w( src/core/channelz/channel_trace.h ) + s.files += %w( src/core/channelz/channelz.cc ) + s.files += %w( src/core/channelz/channelz.h ) + s.files += %w( src/core/channelz/channelz_registry.cc ) + s.files += %w( src/core/channelz/channelz_registry.h ) s.files += %w( src/core/client_channel/backup_poller.cc ) s.files += %w( src/core/client_channel/backup_poller.h ) - s.files += %w( src/core/client_channel/client_channel_channelz.cc ) - s.files += %w( src/core/client_channel/client_channel_channelz.h ) s.files += %w( src/core/client_channel/client_channel_factory.cc ) s.files += %w( src/core/client_channel/client_channel_factory.h ) s.files += %w( src/core/client_channel/client_channel_filter.cc ) @@ -1150,12 +1154,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_stack_builder_impl.h ) s.files += %w( src/core/lib/channel/channel_stack_trace.cc ) s.files += %w( src/core/lib/channel/channel_stack_trace.h ) - s.files += %w( src/core/lib/channel/channel_trace.cc ) - s.files += %w( src/core/lib/channel/channel_trace.h ) - s.files += %w( src/core/lib/channel/channelz.cc ) - s.files += %w( src/core/lib/channel/channelz.h ) - s.files += %w( src/core/lib/channel/channelz_registry.cc ) - s.files += %w( src/core/lib/channel/channelz_registry.h ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) diff --git a/package.xml b/package.xml index 6a184f74d73..cd1737e1450 100644 --- a/package.xml +++ b/package.xml @@ -105,10 +105,14 @@ + + + + + + - - @@ -1132,12 +1136,6 @@ - - - - - - diff --git a/src/core/BUILD b/src/core/BUILD index 23040cc5fe8..8f0c0a013d5 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -3309,29 +3309,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "client_channel_channelz", - srcs = [ - "client_channel/client_channel_channelz.cc", - ], - hdrs = [ - "client_channel/client_channel_channelz.h", - ], - external_deps = [ - "absl/base:core_headers", - "absl/strings", - ], - language = "c++", - deps = [ - "connectivity_state", - "json", - "//:channelz", - "//:gpr", - "//:grpc_public_hdrs", - "//:ref_counted_ptr", - ], -) - grpc_cc_library( name = "service_config_channel_arg_filter", srcs = [ @@ -5511,7 +5488,6 @@ grpc_cc_library( language = "c++", deps = [ "channel_args", - "client_channel_channelz", "client_channel_internal_header", "closure", "connectivity_state", diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/channelz/channel_trace.cc similarity index 98% rename from src/core/lib/channel/channel_trace.cc rename to src/core/channelz/channel_trace.cc index 783a2f3b4b1..ac8be425c61 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/channelz/channel_trace.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channel_trace.h" +#include "src/core/channelz/channel_trace.h" #include #include @@ -27,7 +27,7 @@ #include #include -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/slice/slice.h" diff --git a/src/core/lib/channel/channel_trace.h b/src/core/channelz/channel_trace.h similarity index 96% rename from src/core/lib/channel/channel_trace.h rename to src/core/channelz/channel_trace.h index b4f40a68d38..0b8e1bc7216 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/channelz/channel_trace.h @@ -16,8 +16,8 @@ // // -#ifndef GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H -#define GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H +#ifndef GRPC_SRC_CORE_CHANNELZ_CHANNEL_TRACE_H +#define GRPC_SRC_CORE_CHANNELZ_CHANNEL_TRACE_H #include #include @@ -134,4 +134,4 @@ class ChannelTrace { } // namespace channelz } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H +#endif // GRPC_SRC_CORE_CHANNELZ_CHANNEL_TRACE_H diff --git a/src/core/lib/channel/channelz.cc b/src/core/channelz/channelz.cc similarity index 90% rename from src/core/lib/channel/channelz.cc rename to src/core/channelz/channelz.cc index d7ae044578e..bcfe0c6b3ea 100644 --- a/src/core/lib/channel/channelz.cc +++ b/src/core/channelz/channelz.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include #include @@ -32,10 +32,10 @@ #include #include +#include "src/core/channelz/channelz_registry.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/resolved_address.h" @@ -262,6 +262,68 @@ void ChannelNode::RemoveChildSubchannel(intptr_t child_uuid) { child_subchannels_.erase(child_uuid); } +// +// SubchannelNode +// + +SubchannelNode::SubchannelNode(std::string target_address, + size_t channel_tracer_max_nodes) + : BaseNode(EntityType::kSubchannel, target_address), + target_(std::move(target_address)), + trace_(channel_tracer_max_nodes) {} + +SubchannelNode::~SubchannelNode() {} + +void SubchannelNode::UpdateConnectivityState(grpc_connectivity_state state) { + connectivity_state_.store(state, std::memory_order_relaxed); +} + +void SubchannelNode::SetChildSocket(RefCountedPtr socket) { + MutexLock lock(&socket_mu_); + child_socket_ = std::move(socket); +} + +Json SubchannelNode::RenderJson() { + // Create and fill the data child. + grpc_connectivity_state state = + connectivity_state_.load(std::memory_order_relaxed); + Json::Object data = { + {"state", Json::FromObject({ + {"state", Json::FromString(ConnectivityStateName(state))}, + })}, + {"target", Json::FromString(target_)}, + }; + // Fill in the channel trace if applicable + Json trace_json = trace_.RenderJson(); + if (trace_json.type() != Json::Type::kNull) { + data["trace"] = std::move(trace_json); + } + // Ask CallCountingHelper to populate call count data. + call_counter_.PopulateCallCounts(&data); + // Construct top-level object. + Json::Object object{ + {"ref", Json::FromObject({ + {"subchannelId", Json::FromString(absl::StrCat(uuid()))}, + })}, + {"data", Json::FromObject(std::move(data))}, + }; + // Populate the child socket. + RefCountedPtr child_socket; + { + MutexLock lock(&socket_mu_); + child_socket = child_socket_; + } + if (child_socket != nullptr && child_socket->uuid() != 0) { + object["socketRef"] = Json::FromArray({ + Json::FromObject({ + {"socketId", Json::FromString(absl::StrCat(child_socket->uuid()))}, + {"name", Json::FromString(child_socket->name())}, + }), + }); + } + return Json::FromObject(object); +} + // // ServerNode // diff --git a/src/core/lib/channel/channelz.h b/src/core/channelz/channelz.h similarity index 87% rename from src/core/lib/channel/channelz.h rename to src/core/channelz/channelz.h index cc83387c194..c7dd8561f57 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/channelz/channelz.h @@ -16,8 +16,8 @@ // // -#ifndef GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_H -#define GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_H +#ifndef GRPC_SRC_CORE_CHANNELZ_CHANNELZ_H +#define GRPC_SRC_CORE_CHANNELZ_CHANNELZ_H #include @@ -28,6 +28,7 @@ #include #include +#include "absl/base/thread_annotations.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -36,7 +37,7 @@ #include #include -#include "src/core/lib/channel/channel_trace.h" +#include "src/core/channelz/channel_trace.h" #include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/per_cpu.h" @@ -245,6 +246,45 @@ class ChannelNode final : public BaseNode { std::set child_subchannels_; }; +// Handles channelz bookkeeping for subchannels +class SubchannelNode final : public BaseNode { + public: + SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes); + ~SubchannelNode() override; + + // Sets the subchannel's connectivity state without health checking. + void UpdateConnectivityState(grpc_connectivity_state state); + + // Used when the subchannel's child socket changes. This should be set when + // the subchannel's transport is created and set to nullptr when the + // subchannel unrefs the transport. + void SetChildSocket(RefCountedPtr socket); + + Json RenderJson() override; + + // proxy methods to composed classes. + void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) { + trace_.AddTraceEvent(severity, data); + } + void AddTraceEventWithReference(ChannelTrace::Severity severity, + const grpc_slice& data, + RefCountedPtr referenced_channel) { + trace_.AddTraceEventWithReference(severity, data, + std::move(referenced_channel)); + } + void RecordCallStarted() { call_counter_.RecordCallStarted(); } + void RecordCallFailed() { call_counter_.RecordCallFailed(); } + void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); } + + private: + std::atomic connectivity_state_{GRPC_CHANNEL_IDLE}; + Mutex socket_mu_; + RefCountedPtr child_socket_ ABSL_GUARDED_BY(socket_mu_); + std::string target_; + CallCountingHelper call_counter_; + ChannelTrace trace_; +}; + // Handles channelz bookkeeping for servers class ServerNode final : public BaseNode { public: @@ -380,4 +420,4 @@ class ListenSocketNode final : public BaseNode { } // namespace channelz } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_H +#endif // GRPC_SRC_CORE_CHANNELZ_CHANNELZ_H diff --git a/src/core/lib/channel/channelz_registry.cc b/src/core/channelz/channelz_registry.cc similarity index 99% rename from src/core/lib/channel/channelz_registry.cc rename to src/core/channelz/channelz_registry.cc index e451b187d6b..04bf4a80903 100644 --- a/src/core/lib/channel/channelz_registry.cc +++ b/src/core/channelz/channelz_registry.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channelz_registry.h" +#include "src/core/channelz/channelz_registry.h" #include #include @@ -30,7 +30,7 @@ #include #include -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/json/json.h" diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/channelz/channelz_registry.h similarity index 93% rename from src/core/lib/channel/channelz_registry.h rename to src/core/channelz/channelz_registry.h index b183d1690bf..39525597b4f 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/channelz/channelz_registry.h @@ -16,8 +16,8 @@ // // -#ifndef GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H -#define GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H +#ifndef GRPC_SRC_CORE_CHANNELZ_CHANNELZ_REGISTRY_H +#define GRPC_SRC_CORE_CHANNELZ_CHANNELZ_REGISTRY_H #include #include @@ -27,7 +27,7 @@ #include -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" @@ -99,4 +99,4 @@ class ChannelzRegistry final { } // namespace channelz } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_CHANNEL_CHANNELZ_REGISTRY_H +#endif // GRPC_SRC_CORE_CHANNELZ_CHANNELZ_REGISTRY_H diff --git a/src/core/client_channel/client_channel_channelz.cc b/src/core/client_channel/client_channel_channelz.cc deleted file mode 100644 index 29be8b0a29b..00000000000 --- a/src/core/client_channel/client_channel_channelz.cc +++ /dev/null @@ -1,93 +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 - -#include "src/core/client_channel/client_channel_channelz.h" - -#include "absl/strings/str_cat.h" - -#include - -#include "src/core/lib/transport/connectivity_state.h" - -// IWYU pragma: no_include - -namespace grpc_core { -namespace channelz { - -SubchannelNode::SubchannelNode(std::string target_address, - size_t channel_tracer_max_nodes) - : BaseNode(EntityType::kSubchannel, target_address), - target_(std::move(target_address)), - trace_(channel_tracer_max_nodes) {} - -SubchannelNode::~SubchannelNode() {} - -void SubchannelNode::UpdateConnectivityState(grpc_connectivity_state state) { - connectivity_state_.store(state, std::memory_order_relaxed); -} - -void SubchannelNode::SetChildSocket(RefCountedPtr socket) { - MutexLock lock(&socket_mu_); - child_socket_ = std::move(socket); -} - -Json SubchannelNode::RenderJson() { - // Create and fill the data child. - grpc_connectivity_state state = - connectivity_state_.load(std::memory_order_relaxed); - Json::Object data = { - {"state", Json::FromObject({ - {"state", Json::FromString(ConnectivityStateName(state))}, - })}, - {"target", Json::FromString(target_)}, - }; - // Fill in the channel trace if applicable - Json trace_json = trace_.RenderJson(); - if (trace_json.type() != Json::Type::kNull) { - data["trace"] = std::move(trace_json); - } - // Ask CallCountingHelper to populate call count data. - call_counter_.PopulateCallCounts(&data); - // Construct top-level object. - Json::Object object{ - {"ref", Json::FromObject({ - {"subchannelId", Json::FromString(absl::StrCat(uuid()))}, - })}, - {"data", Json::FromObject(std::move(data))}, - }; - // Populate the child socket. - RefCountedPtr child_socket; - { - MutexLock lock(&socket_mu_); - child_socket = child_socket_; - } - if (child_socket != nullptr && child_socket->uuid() != 0) { - object["socketRef"] = Json::FromArray({ - Json::FromObject({ - {"socketId", Json::FromString(absl::StrCat(child_socket->uuid()))}, - {"name", Json::FromString(child_socket->name())}, - }), - }); - } - return Json::FromObject(object); -} - -} // namespace channelz -} // namespace grpc_core diff --git a/src/core/client_channel/client_channel_channelz.h b/src/core/client_channel/client_channel_channelz.h deleted file mode 100644 index 8311b61356d..00000000000 --- a/src/core/client_channel/client_channel_channelz.h +++ /dev/null @@ -1,85 +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_SRC_CORE_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H -#define GRPC_SRC_CORE_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H - -#include - -#include - -#include -#include -#include - -#include "absl/base/thread_annotations.h" - -#include -#include - -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channelz.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/json/json.h" - -namespace grpc_core { -namespace channelz { - -class SubchannelNode final : public BaseNode { - public: - SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes); - ~SubchannelNode() override; - - // Sets the subchannel's connectivity state without health checking. - void UpdateConnectivityState(grpc_connectivity_state state); - - // Used when the subchannel's child socket changes. This should be set when - // the subchannel's transport is created and set to nullptr when the - // subchannel unrefs the transport. - void SetChildSocket(RefCountedPtr socket); - - Json RenderJson() override; - - // proxy methods to composed classes. - void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) { - trace_.AddTraceEvent(severity, data); - } - void AddTraceEventWithReference(ChannelTrace::Severity severity, - const grpc_slice& data, - RefCountedPtr referenced_channel) { - trace_.AddTraceEventWithReference(severity, data, - std::move(referenced_channel)); - } - void RecordCallStarted() { call_counter_.RecordCallStarted(); } - void RecordCallFailed() { call_counter_.RecordCallFailed(); } - void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); } - - private: - std::atomic connectivity_state_{GRPC_CHANNEL_IDLE}; - Mutex socket_mu_; - RefCountedPtr child_socket_ ABSL_GUARDED_BY(socket_mu_); - std::string target_; - CallCountingHelper call_counter_; - ChannelTrace trace_; -}; - -} // namespace channelz -} // namespace grpc_core - -#endif // GRPC_SRC_CORE_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H diff --git a/src/core/client_channel/client_channel_filter.cc b/src/core/client_channel/client_channel_filter.cc index b7d4d6d4952..cfa5b3fd283 100644 --- a/src/core/client_channel/client_channel_filter.cc +++ b/src/core/client_channel/client_channel_filter.cc @@ -49,8 +49,8 @@ #include #include +#include "src/core/channelz/channel_trace.h" #include "src/core/client_channel/backup_poller.h" -#include "src/core/client_channel/client_channel_channelz.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/client_channel/client_channel_service_config.h" #include "src/core/client_channel/config_selector.h" @@ -63,7 +63,6 @@ #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/status_util.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" diff --git a/src/core/client_channel/client_channel_filter.h b/src/core/client_channel/client_channel_filter.h index 23819b33073..f9ae44b0d26 100644 --- a/src/core/client_channel/client_channel_filter.h +++ b/src/core/client_channel/client_channel_filter.h @@ -37,6 +37,7 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/config_selector.h" #include "src/core/client_channel/dynamic_filters.h" @@ -46,7 +47,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/context.h" #include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/client_channel/connector.h b/src/core/client_channel/connector.h index 7b1e73f63fb..5c218dd7d41 100644 --- a/src/core/client_channel/connector.h +++ b/src/core/client_channel/connector.h @@ -19,8 +19,8 @@ #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/client_channel/subchannel.cc b/src/core/client_channel/subchannel.cc index 6e8d1c41507..29bf5e2b86e 100644 --- a/src/core/client_channel/subchannel.cc +++ b/src/core/client_channel/subchannel.cc @@ -37,14 +37,14 @@ #include #include +#include "src/core/channelz/channel_trace.h" +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/subchannel_pool_interface.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder_impl.h" -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" diff --git a/src/core/client_channel/subchannel.h b/src/core/client_channel/subchannel.h index 174e48df403..6fbe389da5c 100644 --- a/src/core/client_channel/subchannel.h +++ b/src/core/client_channel/subchannel.h @@ -31,7 +31,6 @@ #include #include -#include "src/core/client_channel/client_channel_channelz.h" #include "src/core/client_channel/connector.h" #include "src/core/client_channel/subchannel_pool_interface.h" #include "src/core/lib/backoff/backoff.h" diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index ed90dd45d1d..64083d2cd76 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -29,10 +29,10 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/closure.h" diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc index 4914ea75a78..c3796209c84 100644 --- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -38,6 +38,7 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_factory.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/client_channel/connector.h" @@ -46,7 +47,6 @@ #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args_preconditioning.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 2e97b207ed2..180dc9836d7 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -46,12 +46,12 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index 5388c4a4737..72c1d160e28 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -28,10 +28,10 @@ #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 250de698f4c..8e8be510b10 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -41,6 +41,7 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/context_list_entry.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" @@ -59,7 +60,6 @@ #include "src/core/ext/transport/chttp2/transport/write_size_policy.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/tcp_tracer.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/bitset.h" diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 8f0757c053e..6ea01b3c1df 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -42,6 +42,7 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame_data.h" #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" @@ -59,7 +60,6 @@ #include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/backoff/random_early_detection.h" #include "src/core/lib/channel/call_tracer.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/context.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 5357b2ccf22..693e43ea9a6 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -36,6 +36,7 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/context_list_entry.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" @@ -54,7 +55,6 @@ #include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/ext/transport/chttp2/transport/write_size_policy.h" #include "src/core/lib/channel/call_tracer.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" #include "src/core/lib/debug/trace.h" diff --git a/src/core/ext/transport/inproc/legacy_inproc_transport.cc b/src/core/ext/transport/inproc/legacy_inproc_transport.cc index 4106c7ade7c..2197c6b1edd 100644 --- a/src/core/ext/transport/inproc/legacy_inproc_transport.cc +++ b/src/core/ext/transport/inproc/legacy_inproc_transport.cc @@ -42,9 +42,9 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args_preconditioning.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 0dbbf77d191..4c3fcd53f81 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -42,8 +42,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 08a3aeb02a5..f7152abb340 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -54,10 +54,10 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/call_finalization.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/context.h" #include "src/core/lib/channel/status_util.h" #include "src/core/lib/compression/compression_internal.h" diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 64d5fd3e322..e70e1d001b9 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -23,9 +23,9 @@ #include #include +#include "src/core/channelz/channel_trace.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 58046cdde55..533a944c18c 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -31,8 +31,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/cpp_impl_of.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/surface/channel_create.cc b/src/core/lib/surface/channel_create.cc index 4b64f14c029..0fccd09a45b 100644 --- a/src/core/lib/surface/channel_create.cc +++ b/src/core/lib/surface/channel_create.cc @@ -19,8 +19,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index 80568674f9c..0ee4cd61312 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -29,12 +29,12 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder_impl.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/metrics.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 5e974ec25a6..9d19736ae9c 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -45,10 +45,10 @@ #include #include +#include "src/core/channelz/channel_trace.h" +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args_preconditioning.h" -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/experiments/experiments.h" diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 356bcc40269..9eca869af44 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -43,12 +43,12 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/backoff/random_early_detection.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/cpp_impl_of.h" #include "src/core/lib/gprpp/dual_ref_counted.h" diff --git a/src/core/lib/surface/server_interface.h b/src/core/lib/surface/server_interface.h index ea1081287d2..988cc201910 100644 --- a/src/core/lib/surface/server_interface.h +++ b/src/core/lib/surface/server_interface.h @@ -19,8 +19,8 @@ #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" namespace grpc_core { diff --git a/src/core/load_balancing/grpclb/grpclb.cc b/src/core/load_balancing/grpclb/grpclb.cc index 0b62235f51e..34f6afba790 100644 --- a/src/core/load_balancing/grpclb/grpclb.cc +++ b/src/core/load_balancing/grpclb/grpclb.cc @@ -92,11 +92,11 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/experiments.h" diff --git a/src/core/load_balancing/health_check_client.cc b/src/core/load_balancing/health_check_client.cc index 455dc789adb..6dfebe2e8d9 100644 --- a/src/core/load_balancing/health_check_client.cc +++ b/src/core/load_balancing/health_check_client.cc @@ -39,13 +39,12 @@ #include #include -#include "src/core/client_channel/client_channel_channelz.h" +#include "src/core/channelz/channel_trace.h" #include "src/core/client_channel/client_channel_internal.h" #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_stream_client.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/load_balancing/oob_backend_metric.cc b/src/core/load_balancing/oob_backend_metric.cc index 6d4bdd03164..4f43594b44e 100644 --- a/src/core/load_balancing/oob_backend_metric.cc +++ b/src/core/load_balancing/oob_backend_metric.cc @@ -37,10 +37,9 @@ #include #include -#include "src/core/client_channel/client_channel_channelz.h" +#include "src/core/channelz/channel_trace.h" #include "src/core/client_channel/subchannel.h" #include "src/core/client_channel/subchannel_stream_client.h" -#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/load_balancing/rls/rls.cc b/src/core/load_balancing/rls/rls.cc index ea7c1c909bd..93de1b7ae9f 100644 --- a/src/core/load_balancing/rls/rls.cc +++ b/src/core/load_balancing/rls/rls.cc @@ -65,10 +65,10 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/client_channel/client_channel_filter.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/channel/metrics.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 9f20c1f18f1..fc65b906b34 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -15,8 +15,10 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! CORE_SOURCE_FILES = [ + 'src/core/channelz/channel_trace.cc', + 'src/core/channelz/channelz.cc', + 'src/core/channelz/channelz_registry.cc', 'src/core/client_channel/backup_poller.cc', - 'src/core/client_channel/client_channel_channelz.cc', 'src/core/client_channel/client_channel_factory.cc', 'src/core/client_channel/client_channel_filter.cc', 'src/core/client_channel/client_channel_plugin.cc', @@ -441,9 +443,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_stack_builder_impl.cc', 'src/core/lib/channel/channel_stack_trace.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/metrics.cc', 'src/core/lib/channel/promise_based_filter.cc', diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index 7394e109b5e..55dba74272c 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -30,10 +30,10 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args_preconditioning.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/thd.h" diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index 7313304a05e..0e6f9086e3f 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -32,8 +32,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/error.h" diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 2396c4a3945..04eb892927a 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channel_trace.h" +#include "src/core/channelz/channel_trace.h" #include @@ -29,8 +29,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/json/json.h" #include "src/core/lib/json/json_writer.h" diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 4f9f23bd1d6..02fb0360c72 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channelz_registry.h" +#include "src/core/channelz/channelz_registry.h" #include @@ -25,7 +25,7 @@ #include "gtest/gtest.h" -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include "test/core/util/test_config.h" namespace grpc_core { diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 973af3690eb..3cf8239eb39 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include @@ -39,8 +39,8 @@ #include #include +#include "src/core/channelz/channelz_registry.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/notification.h" diff --git a/test/core/end2end/fixtures/sockpair_fixture.h b/test/core/end2end/fixtures/sockpair_fixture.h index e8d7c30c4d8..5649d121e5b 100644 --- a/test/core/end2end/fixtures/sockpair_fixture.h +++ b/test/core/end2end/fixtures/sockpair_fixture.h @@ -27,10 +27,10 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args_preconditioning.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/endpoint.h" diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc index a70b2c244d8..7836b291243 100644 --- a/test/core/end2end/tests/channelz.cc +++ b/test/core/end2end/tests/channelz.cc @@ -16,7 +16,7 @@ // // -#include "src/core/lib/channel/channelz.h" +#include "src/core/channelz/channelz.h" #include diff --git a/test/core/end2end/tests/retry_streaming.cc b/test/core/end2end/tests/retry_streaming.cc index d21dd512444..ab06d00a862 100644 --- a/test/core/end2end/tests/retry_streaming.cc +++ b/test/core/end2end/tests/retry_streaming.cc @@ -25,8 +25,8 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/surface/channel.h" #include "test/core/end2end/end2end_tests.h" diff --git a/test/core/transport/chttp2/graceful_shutdown_test.cc b/test/core/transport/chttp2/graceful_shutdown_test.cc index e0294aebee8..44b60b7cf6b 100644 --- a/test/core/transport/chttp2/graceful_shutdown_test.cc +++ b/test/core/transport/chttp2/graceful_shutdown_test.cc @@ -44,11 +44,11 @@ #include #include +#include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channelz.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/notification.h" diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 45745a6b3c8..58ff43e6228 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1083,10 +1083,14 @@ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ include/grpcpp/version_info.h \ include/grpcpp/xds_server_builder.h \ +src/core/channelz/channel_trace.cc \ +src/core/channelz/channel_trace.h \ +src/core/channelz/channelz.cc \ +src/core/channelz/channelz.h \ +src/core/channelz/channelz_registry.cc \ +src/core/channelz/channelz_registry.h \ src/core/client_channel/backup_poller.cc \ src/core/client_channel/backup_poller.h \ -src/core/client_channel/client_channel_channelz.cc \ -src/core/client_channel/client_channel_channelz.h \ src/core/client_channel/client_channel_factory.cc \ src/core/client_channel/client_channel_factory.h \ src/core/client_channel/client_channel_filter.cc \ @@ -2149,12 +2153,6 @@ src/core/lib/channel/channel_stack_builder_impl.cc \ src/core/lib/channel/channel_stack_builder_impl.h \ src/core/lib/channel/channel_stack_trace.cc \ src/core/lib/channel/channel_stack_trace.h \ -src/core/lib/channel/channel_trace.cc \ -src/core/lib/channel/channel_trace.h \ -src/core/lib/channel/channelz.cc \ -src/core/lib/channel/channelz.h \ -src/core/lib/channel/channelz_registry.cc \ -src/core/lib/channel/channelz_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 73cb5cdb1c6..d17727a5592 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -886,11 +886,15 @@ include/grpc/support/thd_id.h \ include/grpc/support/time.h \ include/grpc/support/workaround_list.h \ src/core/README.md \ +src/core/channelz/channel_trace.cc \ +src/core/channelz/channel_trace.h \ +src/core/channelz/channelz.cc \ +src/core/channelz/channelz.h \ +src/core/channelz/channelz_registry.cc \ +src/core/channelz/channelz_registry.h \ src/core/client_channel/README.md \ src/core/client_channel/backup_poller.cc \ src/core/client_channel/backup_poller.h \ -src/core/client_channel/client_channel_channelz.cc \ -src/core/client_channel/client_channel_channelz.h \ src/core/client_channel/client_channel_factory.cc \ src/core/client_channel/client_channel_factory.h \ src/core/client_channel/client_channel_filter.cc \ @@ -1921,12 +1925,6 @@ src/core/lib/channel/channel_stack_builder_impl.cc \ src/core/lib/channel/channel_stack_builder_impl.h \ src/core/lib/channel/channel_stack_trace.cc \ src/core/lib/channel/channel_stack_trace.h \ -src/core/lib/channel/channel_trace.cc \ -src/core/lib/channel/channel_trace.h \ -src/core/lib/channel/channelz.cc \ -src/core/lib/channel/channelz.h \ -src/core/lib/channel/channelz_registry.cc \ -src/core/lib/channel/channelz_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ From 91f0eadd22fafe2114d12348d01e3c82f9f58e2d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 19 Apr 2024 16:46:36 -0700 Subject: [PATCH 31/45] [CSM] Remove requirement that servers have to be xDS enabled (#36410) Closes #36410 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36410 from yashykt:CsmEnableForAllServers cfe8d7db0bd2aeabef7b448e2853db6bab90dbf8 PiperOrigin-RevId: 626501498 --- src/cpp/ext/csm/csm_observability.cc | 5 ++--- test/cpp/ext/csm/csm_observability_test.cc | 10 ++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/cpp/ext/csm/csm_observability.cc b/src/cpp/ext/csm/csm_observability.cc index e89950178ef..1f9d04bd7df 100644 --- a/src/cpp/ext/csm/csm_observability.cc +++ b/src/cpp/ext/csm/csm_observability.cc @@ -48,9 +48,8 @@ namespace { std::atomic g_csm_plugin_enabled(false); } -bool CsmServerSelector(const grpc_core::ChannelArgs& args) { - return g_csm_plugin_enabled && - args.GetBool(GRPC_ARG_XDS_ENABLED_SERVER).value_or(false); +bool CsmServerSelector(const grpc_core::ChannelArgs& /*args*/) { + return g_csm_plugin_enabled; } bool CsmChannelTargetSelector(absl::string_view target) { diff --git a/test/cpp/ext/csm/csm_observability_test.cc b/test/cpp/ext/csm/csm_observability_test.cc index 63c2af641c8..da2b5a8dad7 100644 --- a/test/cpp/ext/csm/csm_observability_test.cc +++ b/test/cpp/ext/csm/csm_observability_test.cc @@ -77,15 +77,9 @@ TEST(CsmChannelTargetSelectorTest, CsmObservabilityOutOfScope) { "xds://traffic-director-global.xds.googleapis.com/foo")); } -TEST(CsmServerSelectorTest, ChannelArgsWithoutXdsServerArg) { +TEST(CsmServerSelectorTest, ChannelArgs) { auto obs = CsmObservabilityBuilder().BuildAndRegister(); - EXPECT_FALSE(internal::CsmServerSelector(grpc_core::ChannelArgs())); -} - -TEST(CsmServerSelectorTest, ChannelArgsWithXdsServerArg) { - auto obs = CsmObservabilityBuilder().BuildAndRegister(); - EXPECT_TRUE(internal::CsmServerSelector( - grpc_core::ChannelArgs().Set(GRPC_ARG_XDS_ENABLED_SERVER, true))); + EXPECT_TRUE(internal::CsmServerSelector(grpc_core::ChannelArgs())); } TEST(CsmServerSelectorTest, CsmObservabilityOutOfScope) { From e9d1397fe15fe86e42122571fe1056a443aa6638 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:32:35 -0700 Subject: [PATCH 32/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36407) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement and regex. Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36407 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36407 from tanvi-jagtap:tjagtap_end2end_fixtures e98c97245b309a6e31f2e3f2e0373a3a15a2cb41 PiperOrigin-RevId: 626522240 --- test/core/end2end/BUILD | 3 ++ test/core/end2end/fixtures/h2_oauth2_common.h | 10 +++--- .../fixtures/h2_ssl_cred_reload_fixture.h | 4 ++- .../core/end2end/fixtures/h2_ssl_tls_common.h | 4 ++- test/core/end2end/fixtures/h2_tls_common.h | 3 +- .../end2end/fixtures/http_proxy_fixture.cc | 9 ++--- test/core/end2end/fixtures/local_util.cc | 9 ++--- test/core/end2end/fixtures/proxy.cc | 36 ++++++++++--------- test/core/end2end/fixtures/secure_fixture.h | 5 +-- test/core/end2end/fixtures/sockpair_fixture.h | 3 +- 10 files changed, 51 insertions(+), 35 deletions(-) diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index c3062c1d3a8..149001b1f39 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -62,6 +62,7 @@ grpc_cc_library( srcs = ["fixtures/http_proxy_fixture.cc"], hdrs = ["fixtures/http_proxy_fixture.h"], external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -94,6 +95,7 @@ grpc_cc_library( name = "proxy", srcs = ["fixtures/proxy.cc"], hdrs = ["fixtures/proxy.h"], + external_deps = ["absl/log:check"], language = "C++", deps = [ "//:channel_arg_names", @@ -159,6 +161,7 @@ grpc_cc_library( ], external_deps = [ "absl/functional:any_invocable", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", diff --git a/test/core/end2end/fixtures/h2_oauth2_common.h b/test/core/end2end/fixtures/h2_oauth2_common.h index e66f341059a..49ccec15bfb 100644 --- a/test/core/end2end/fixtures/h2_oauth2_common.h +++ b/test/core/end2end/fixtures/h2_oauth2_common.h @@ -17,6 +17,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -73,7 +75,7 @@ class Oauth2Fixture : public SecureFixture { void* user_data) { const grpc_metadata* oauth2 = find_metadata(md, md_count, "authorization", oauth2_md()); - GPR_ASSERT(oauth2 != nullptr); + CHECK_NE(oauth2, nullptr); cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_OK, nullptr); } @@ -83,8 +85,8 @@ class Oauth2Fixture : public SecureFixture { void* user_data) { const grpc_metadata* oauth2 = find_metadata(md, md_count, "authorization", oauth2_md()); - GPR_ASSERT(state != nullptr); - GPR_ASSERT(oauth2 != nullptr); + CHECK_NE(state, nullptr); + CHECK_NE(oauth2, nullptr); cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } @@ -159,7 +161,7 @@ class Oauth2Fixture : public SecureFixture { size_t /*md_count*/, grpc_process_auth_metadata_done_cb cb, void* user_data) { - GPR_ASSERT(state == nullptr); + CHECK_EQ(state, nullptr); cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h index 5b49fcb39e5..0c7dc536a7a 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h @@ -17,6 +17,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -91,7 +93,7 @@ class SslCredReloadFixture : public SecureFixture { size_t /*md_count*/, grpc_process_auth_metadata_done_cb cb, void* user_data) { - GPR_ASSERT(state == nullptr); + CHECK_EQ(state, nullptr); cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } diff --git a/test/core/end2end/fixtures/h2_ssl_tls_common.h b/test/core/end2end/fixtures/h2_ssl_tls_common.h index e026ccbd381..dbd8bb11539 100644 --- a/test/core/end2end/fixtures/h2_ssl_tls_common.h +++ b/test/core/end2end/fixtures/h2_ssl_tls_common.h @@ -17,6 +17,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -96,7 +98,7 @@ class SslTlsFixture : public SecureFixture { size_t /*md_count*/, grpc_process_auth_metadata_done_cb cb, void* user_data) { - GPR_ASSERT(state == nullptr); + CHECK_EQ(state, nullptr); cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } diff --git a/test/core/end2end/fixtures/h2_tls_common.h b/test/core/end2end/fixtures/h2_tls_common.h index 0abc56e6d06..908c1fc432e 100644 --- a/test/core/end2end/fixtures/h2_tls_common.h +++ b/test/core/end2end/fixtures/h2_tls_common.h @@ -24,6 +24,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -63,7 +64,7 @@ inline void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, size_t /*md_count*/, grpc_process_auth_metadata_done_cb cb, void* user_data) { - GPR_ASSERT(state == nullptr); + CHECK_EQ(state, nullptr); cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 85b97b90cbc..43c4dc87f8c 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -26,6 +26,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/escaping.h" @@ -575,7 +576,7 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error) { proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy DNS lookup", error); return; } - GPR_ASSERT(!addresses_or->empty()); + CHECK(!addresses_or->empty()); // Connect to requested address. // The connection callback inherits our reference to conn. const grpc_core::Timestamp deadline = @@ -679,7 +680,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( nullptr, grpc_event_engine::experimental::ChannelArgsEndpointConfig(channel_args), on_accept, proxy, &proxy->server); - GPR_ASSERT(error.ok()); + CHECK_OK(error); // Bind to port. grpc_resolved_address resolved_addr; grpc_sockaddr_in* addr = @@ -690,8 +691,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( grpc_sockaddr_set_port(&resolved_addr, proxy_port); int port; error = grpc_tcp_server_add_port(proxy->server, &resolved_addr, &port); - GPR_ASSERT(error.ok()); - GPR_ASSERT(port == proxy_port); + CHECK_OK(error); + CHECK(port == proxy_port); // Start server. auto* pollset = static_cast(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset, &proxy->mu); diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 2c4059b1973..12e05139a85 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -32,7 +34,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, size_t /*md_count*/, grpc_process_auth_metadata_done_cb cb, void* user_data) { - GPR_ASSERT(state == nullptr); + CHECK_EQ(state, nullptr); cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); } @@ -53,8 +55,7 @@ grpc_server* LocalTestFixture::MakeServer( grpc_server_credentials_set_auth_metadata_processor(server_creds, processor); } - GPR_ASSERT( - grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds)); + CHECK(grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds)); grpc_server_credentials_release(server_creds); pre_server_start(server); grpc_server_start(server); @@ -66,7 +67,7 @@ grpc_channel* LocalTestFixture::MakeClient(const grpc_core::ChannelArgs& args, grpc_channel_credentials* creds = grpc_local_credentials_create(type_); auto* client = grpc_channel_create(localaddr_.c_str(), creds, args.ToC().get()); - GPR_ASSERT(client != nullptr); + CHECK_NE(client, nullptr); grpc_channel_credentials_release(creds); return client; } diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index ddd96a2138f..94e56ef8e82 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -23,6 +23,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -193,7 +195,7 @@ static void on_p2s_recv_initial_metadata(void* arg, int /*success*/) { err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_sent_initial_metadata, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } unrefpc(pc, "on_p2s_recv_initial_metadata"); @@ -220,7 +222,7 @@ static void on_p2s_sent_message(void* arg, int success) { refpc(pc, "on_c2p_recv_msg"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_recv_msg, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } unrefpc(pc, "on_p2s_sent_message"); @@ -245,7 +247,7 @@ static void on_c2p_recv_msg(void* arg, int success) { refpc(pc, "on_p2s_sent_message"); err = grpc_call_start_batch( pc->p2s, &op, 1, new_closure(on_p2s_sent_message, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } else { op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op.flags = 0; @@ -253,7 +255,7 @@ static void on_c2p_recv_msg(void* arg, int success) { refpc(pc, "on_p2s_sent_close"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_sent_close, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } } else { if (pc->c2p_msg != nullptr) { @@ -280,7 +282,7 @@ static void on_c2p_sent_message(void* arg, int success) { refpc(pc, "on_p2s_recv_msg"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_recv_msg, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } unrefpc(pc, "on_c2p_sent_message"); @@ -299,7 +301,7 @@ static void on_p2s_recv_msg(void* arg, int success) { refpc(pc, "on_c2p_sent_message"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_sent_message, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } else { grpc_byte_buffer_destroy(pc->p2s_msg); } @@ -319,7 +321,7 @@ static void on_p2s_status(void* arg, int success) { memset(op, 0, sizeof(op)); if (!pc->proxy->shutdown) { - GPR_ASSERT(success); + CHECK(success); int op_count = 0; if (grpc_call_is_trailers_only(pc->p2s)) { @@ -341,7 +343,7 @@ static void on_p2s_status(void* arg, int success) { refpc(pc, "on_c2p_sent_status"); err = grpc_call_start_batch(pc->c2p, op, op_count, new_closure(on_c2p_sent_status, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); } unrefpc(pc, "on_p2s_status"); @@ -380,7 +382,7 @@ static void on_new_call(void* arg, int success) { err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_recv_initial_metadata, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); op.op = GRPC_OP_SEND_INITIAL_METADATA; op.flags = 0; @@ -390,7 +392,7 @@ static void on_new_call(void* arg, int success) { err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_sent_initial_metadata, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; @@ -398,7 +400,7 @@ static void on_new_call(void* arg, int success) { refpc(pc, "on_c2p_recv_msg"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_recv_msg, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); op.op = GRPC_OP_RECV_MESSAGE; op.flags = 0; @@ -406,7 +408,7 @@ static void on_new_call(void* arg, int success) { refpc(pc, "on_p2s_recv_msg"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_recv_msg, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); op.op = GRPC_OP_RECV_STATUS_ON_CLIENT; op.flags = 0; @@ -417,7 +419,7 @@ static void on_new_call(void* arg, int success) { refpc(pc, "on_p2s_status"); err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); op.op = GRPC_OP_RECV_CLOSE_ON_SERVER; op.flags = 0; @@ -425,7 +427,7 @@ static void on_new_call(void* arg, int success) { refpc(pc, "on_c2p_closed"); err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc), nullptr); - GPR_ASSERT(err == GRPC_CALL_OK); + CHECK_EQ(err, GRPC_CALL_OK); request_call(proxy); @@ -434,14 +436,14 @@ static void on_new_call(void* arg, int success) { unrefpc(pc, "init"); } else { - GPR_ASSERT(proxy->new_call == nullptr); + CHECK_EQ(proxy->new_call, nullptr); } } static void request_call(grpc_end2end_proxy* proxy) { proxy->new_call = nullptr; - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( - proxy->server, &proxy->new_call, + CHECK(GRPC_CALL_OK == + grpc_server_request_call(proxy->server, &proxy->new_call, &proxy->new_call_details, &proxy->new_call_metadata, proxy->cq, proxy->cq, new_closure(on_new_call, proxy))); diff --git a/test/core/end2end/fixtures/secure_fixture.h b/test/core/end2end/fixtures/secure_fixture.h index 8a64b49fc75..480abfd8698 100644 --- a/test/core/end2end/fixtures/secure_fixture.h +++ b/test/core/end2end/fixtures/secure_fixture.h @@ -19,6 +19,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include #include @@ -59,7 +60,7 @@ class SecureFixture : public grpc_core::CoreTestFixture { auto* creds = MakeServerCreds(args); auto* server = grpc_server_create(args.ToC().get(), nullptr); grpc_server_register_completion_queue(server, cq, nullptr); - GPR_ASSERT(grpc_server_add_http2_port(server, localaddr_.c_str(), creds)); + CHECK(grpc_server_add_http2_port(server, localaddr_.c_str(), creds)); grpc_server_credentials_release(creds); pre_server_start(server); grpc_server_start(server); @@ -71,7 +72,7 @@ class SecureFixture : public grpc_core::CoreTestFixture { auto* creds = MakeClientCreds(args); auto* client = grpc_channel_create(localaddr_.c_str(), creds, args.ToC().get()); - GPR_ASSERT(client != nullptr); + CHECK_NE(client, nullptr); grpc_channel_credentials_release(creds); return client; } diff --git a/test/core/end2end/fixtures/sockpair_fixture.h b/test/core/end2end/fixtures/sockpair_fixture.h index 5649d121e5b..0832f0def52 100644 --- a/test/core/end2end/fixtures/sockpair_fixture.h +++ b/test/core/end2end/fixtures/sockpair_fixture.h @@ -18,6 +18,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "gtest/gtest.h" @@ -121,7 +122,7 @@ class SockpairFixture : public CoreTestFixture { "lame channel"); transport->Orphan(); } - GPR_ASSERT(client); + CHECK(client); return client; } From dc848c3e054ef9366af749a364189355139aba9b Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:32:37 -0700 Subject: [PATCH 33/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36405) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement and regex. Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36405 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36405 from tanvi-jagtap:tjagtap_microbenchmarks_01 0dcec5d852af05d7b24625a44b77318856114541 PiperOrigin-RevId: 626522246 --- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 4 ++-- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 2 +- test/cpp/microbenchmarks/bm_event_engine_run.cc | 4 ++-- test/cpp/microbenchmarks/bm_thread_pool.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 29dd386db58..05045fc5a12 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -365,7 +365,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { auto error = p.Parse(slices[i], i == slices.size() - 1, absl::BitGenRef(bitgen), /*call_tracer=*/nullptr); - CHECK(error.ok()); + CHECK_OK(error); } }; parse_vec(init_slices); @@ -445,7 +445,7 @@ class FromEncoderFixture { } // Remove the HTTP header. CHECK(!out.empty()); - CHECK(GRPC_SLICE_LENGTH(out[0]) > 9); + CHECK_GT(GRPC_SLICE_LENGTH(out[0]), 9); out[0] = grpc_slice_sub_no_ref(out[0], 9, GRPC_SLICE_LENGTH(out[0])); return out; } diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 9321c2347cf..909cee97cf3 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -395,7 +395,7 @@ static void BM_TransportEmptyOp(benchmark::State& state) { gpr_event_init(stream_cancel_done); std::unique_ptr stream_cancel_closure = MakeTestClosure([&](grpc_error_handle error) { - CHECK(error.ok()); + CHECK_OK(error); gpr_event_set(stream_cancel_done, reinterpret_cast(1)); }); op.on_complete = stream_cancel_closure.get(); diff --git a/test/cpp/microbenchmarks/bm_event_engine_run.cc b/test/cpp/microbenchmarks/bm_event_engine_run.cc index 1dcbbe81465..6c7fc5a5708 100644 --- a/test/cpp/microbenchmarks/bm_event_engine_run.cc +++ b/test/cpp/microbenchmarks/bm_event_engine_run.cc @@ -181,7 +181,7 @@ void FanOutCallback(std::shared_ptr engine, signal.Notify(); return; } - GPR_DEBUG_ASSERT(local_cnt < params.limit); + DCHECK_LT(local_cnt, params.limit); if (params.depth == processing_layer) return; for (int i = 0; i < params.fanout; i++) { engine->Run([engine, params, processing_layer, &count, &signal]() { @@ -244,7 +244,7 @@ void BM_EventEngine_Closure_FanOut(benchmark::State& state) { })); } for (auto _ : state) { - GPR_DEBUG_ASSERT(count.load(std::memory_order_relaxed) == 0); + DCHECK_EQ(count.load(std::memory_order_relaxed), 0); engine->Run(closures[params.depth + 1]); do { signal->WaitForNotification(); diff --git a/test/cpp/microbenchmarks/bm_thread_pool.cc b/test/cpp/microbenchmarks/bm_thread_pool.cc index b0e101109eb..351b6921bfc 100644 --- a/test/cpp/microbenchmarks/bm_thread_pool.cc +++ b/test/cpp/microbenchmarks/bm_thread_pool.cc @@ -156,7 +156,7 @@ void FanOutCallback(std::shared_ptr pool, signal.Notify(); return; } - GPR_DEBUG_ASSERT(local_cnt < params.limit); + DCHECK_LT(local_cnt, params.limit); if (params.depth == processing_layer) return; for (int i = 0; i < params.fanout; i++) { pool->Run([pool, params, processing_layer, &count, &signal]() { @@ -222,7 +222,7 @@ void BM_ThreadPool_Closure_FanOut(benchmark::State& state) { })); } for (auto _ : state) { - GPR_DEBUG_ASSERT(count.load(std::memory_order_relaxed) == 0); + DCHECK_EQ(count.load(std::memory_order_relaxed), 0); pool->Run(closures[params.depth + 1]); do { signal->WaitForNotification(); From a1ec7bea08f39c5d77956c4ffa052941bd42986b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 22 Apr 2024 10:32:30 -0700 Subject: [PATCH 34/45] =?UTF-8?q?Revert=20"ssl:=20More=20comprehensive=20t?= =?UTF-8?q?esting=20of=20SSL=20credentials,=20part=201.=20(=E2=80=A6=20(#3?= =?UTF-8?q?6419)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …#35433)" This reverts commit 40d1776e0761e85c2d5b0215460ddd79122e142b. Closes #36419 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36419 from yashykt:Revert35433 90cfbe422973457b3d2021323ce6c941c4520ce8 PiperOrigin-RevId: 627083350 --- src/core/tsi/ssl_transport_security.cc | 4 - src/core/tsi/ssl_transport_security.h | 3 - test/cpp/end2end/BUILD | 1 - test/cpp/end2end/ssl_credentials_test.cc | 497 +++-------------------- 4 files changed, 64 insertions(+), 441 deletions(-) diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index d705abc1c2c..9235782bb29 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -1282,10 +1282,6 @@ void tsi_ssl_session_cache_unref(tsi_ssl_session_cache* cache) { tsi::SslSessionLRUCache::FromC(cache)->Unref(); } -size_t tsi_ssl_session_cache_size(tsi_ssl_session_cache* cache) { - return tsi::SslSessionLRUCache::FromC(cache)->Size(); -} - // --- tsi_frame_protector methods implementation. --- static tsi_result ssl_protector_protect(tsi_frame_protector* self, diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index d925f08840b..da3b260adbd 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -81,9 +81,6 @@ void tsi_ssl_session_cache_ref(tsi_ssl_session_cache* cache); // Decrement reference counter of \a cache. void tsi_ssl_session_cache_unref(tsi_ssl_session_cache* cache); -// Returns the size of the cache. -size_t tsi_ssl_session_cache_size(tsi_ssl_session_cache* cache); - // --- tsi_ssl_key_logger object --- // Experimental SSL Key logging functionality to enable decryption of diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 36125889baa..d8a09d6d3c0 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -1068,7 +1068,6 @@ grpc_cc_test( grpc_cc_test( name = "ssl_credentials_test", - timeout = "long", srcs = ["ssl_credentials_test.cc"], data = [ "//src/core/tsi/test_creds:ca.pem", diff --git a/test/cpp/end2end/ssl_credentials_test.cc b/test/cpp/end2end/ssl_credentials_test.cc index 092fe427aed..82cba482ca0 100644 --- a/test/cpp/end2end/ssl_credentials_test.cc +++ b/test/cpp/end2end/ssl_credentials_test.cc @@ -15,11 +15,7 @@ // limitations under the License. // // -#include "src/core/lib/security/credentials/ssl/ssl_credentials.h" - #include -#include -#include #include #include @@ -34,67 +30,34 @@ #include #include -#include "src/core/lib/gprpp/cpp_impl_of.h" -#include "src/core/tsi/ssl_transport_security.h" -#include "src/cpp/client/secure_credentials.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" -// TODO(matthewstevenson88): More test cases to add: -// - Use P256, P384, P512 credentials. -// - Use a long certificate chain. -// - Use a large certificate. -// - Large trust bundle. -// - Bad ALPN. -// - More failure modes. -// - Certs containing more SANs. -// - Copy all of this over to tls_credentials_test.cc. -// - Client doesn't have cert but server requests one. -// - Bad session ticket in cache. -// - Use same channel creds object on sequential/concurrent handshakes. -// - Do successful handshake with a localhost server cert. -// - Missing or malformed roots on both sides. - namespace grpc { namespace testing { namespace { -using ::grpc_core::testing::GetFileContents; -using ::testing::HasSubstr; -using ::testing::IsEmpty; -using ::testing::UnorderedElementsAre; - 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"; constexpr char kMessage[] = "Hello"; -constexpr char kTargetNameOverride[] = "foo.test.google.fr"; - -std::size_t GetSessionCacheSize(grpc_ssl_session_cache* cache) { - tsi_ssl_session_cache* tsi_cache = - reinterpret_cast(cache); - return tsi_ssl_session_cache_size(tsi_cache); -} - -struct SslOptions { - grpc_ssl_client_certificate_request_type request_type = - GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE; - bool use_session_cache; -}; -class SslCredentialsTest : public ::testing::TestWithParam { +class SslCredentialsTest : public ::testing::Test { protected: - void RunServer(absl::Notification* notification, - absl::string_view pem_root_certs) { + void RunServer(absl::Notification* notification) { + std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); grpc::SslServerCredentialsOptions::PemKeyCertPair key_cert_pair = { - GetFileContents(kServerKeyPath), GetFileContents(kServerCertPath)}; - grpc::SslServerCredentialsOptions ssl_options(GetParam().request_type); + grpc_core::testing::GetFileContents(kServerKeyPath), + grpc_core::testing::GetFileContents(kServerCertPath)}; + // TODO(gtcooke94) Parametrize this test for TLS and mTLS as well + grpc::SslServerCredentialsOptions ssl_options; ssl_options.pem_key_cert_pairs.push_back(key_cert_pair); - ssl_options.pem_root_certs = std::string(pem_root_certs); + ssl_options.pem_root_certs = root_cert; + ssl_options.force_client_auth = true; grpc::ServerBuilder builder; TestServiceImpl service_; @@ -115,226 +78,57 @@ class SslCredentialsTest : public ::testing::TestWithParam { } } - absl::StatusOr> DoRpc( - const SslCredentialsOptions& options, grpc_ssl_session_cache* cache, - bool override_ssl_target_name = true) { - ChannelArguments channel_args; - if (GetParam().use_session_cache) { - channel_args.SetPointer(std::string(GRPC_SSL_SESSION_CACHE_ARG), cache); - } - if (override_ssl_target_name) { - channel_args.SetSslTargetNameOverride(kTargetNameOverride); - } - - auto creds = SslCredentials(options); - std::shared_ptr channel = - grpc::CreateCustomChannel(server_addr_, creds, channel_args); - - auto stub = grpc::testing::EchoTestService::NewStub(channel); - grpc::testing::EchoRequest request; - grpc::testing::EchoResponse response; - request.set_message(kMessage); - ClientContext context; - context.set_deadline(grpc_timeout_seconds_to_deadline(/*time_s=*/10)); - grpc::Status result = stub->Echo(&context, request, &response); - if (!result.ok()) { - return absl::Status(static_cast(result.error_code()), - result.error_message()); - } - EXPECT_EQ(response.message(), kMessage); - return context.auth_context(); - } - - static std::vector GetAuthContextPropertyAsList( - const AuthContext& auth_context, const std::string& property) { - std::vector properties; - for (const grpc::string_ref& property : - auth_context.FindPropertyValues(property)) { - properties.push_back(absl::string_view(property.data(), property.size())); - } - return properties; - } - - static absl::string_view GetAuthContextProperty( - const AuthContext& auth_context, const std::string& property) { - std::vector properties = - GetAuthContextPropertyAsList(auth_context, property); - return properties.size() == 1 ? properties[0] : ""; - } - TestServiceImpl service_; std::unique_ptr server_ = nullptr; std::thread* server_thread_ = nullptr; std::string server_addr_; }; -TEST_P(SslCredentialsTest, FullHandshake) { - server_addr_ = absl::StrCat("localhost:", - std::to_string(grpc_pick_unused_port_or_die())); - absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); - notification.WaitForNotification(); - - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); - grpc::SslCredentialsOptions ssl_options; - ssl_options.pem_root_certs = root_cert; - ssl_options.pem_private_key = client_key; - ssl_options.pem_cert_chain = client_cert; - - grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - - auto full_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "false"); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME), - GRPC_SSL_TRANSPORT_SECURITY_TYPE); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME), - "TSI_PRIVACY_AND_INTEGRITY"); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_X509_CN_PROPERTY_NAME), - "*.test.google.com"); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_X509_SUBJECT_PROPERTY_NAME), - "CN=*.test.google.com,O=Example\\, Co.,L=Chicago,ST=Illinois,C=US"); - EXPECT_THAT( - GetAuthContextPropertyAsList(**full_handshake_context, - GRPC_X509_SAN_PROPERTY_NAME), - UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", - "*.test.youtube.com", "192.168.1.3")); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_X509_PEM_CERT_PROPERTY_NAME), - GetFileContents(kServerCertPath)); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME), - GetFileContents(kServerCertPath)); - EXPECT_THAT( - GetAuthContextPropertyAsList(**full_handshake_context, - GRPC_PEER_DNS_PROPERTY_NAME), - UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", - "*.test.youtube.com")); - EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, - GRPC_PEER_URI_PROPERTY_NAME), - IsEmpty()); - EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, - GRPC_PEER_EMAIL_PROPERTY_NAME), - IsEmpty()); - EXPECT_THAT(GetAuthContextPropertyAsList(**full_handshake_context, - GRPC_PEER_IP_PROPERTY_NAME), - UnorderedElementsAre("192.168.1.3")); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_PEER_SPIFFE_ID_PROPERTY_NAME), - ""); - if (GetParam().use_session_cache) { - EXPECT_EQ(GetSessionCacheSize(cache), 1); +void DoRpc(const std::string& server_addr, + const SslCredentialsOptions& ssl_options, + grpc_ssl_session_cache* cache, bool expect_session_reuse) { + ChannelArguments channel_args; + channel_args.SetPointer(std::string(GRPC_SSL_SESSION_CACHE_ARG), cache); + channel_args.SetSslTargetNameOverride("foo.test.google.fr"); + + std::shared_ptr channel = grpc::CreateCustomChannel( + server_addr, grpc::SslCredentials(ssl_options), channel_args); + + auto stub = grpc::testing::EchoTestService::NewStub(channel); + grpc::testing::EchoRequest request; + grpc::testing::EchoResponse response; + request.set_message(kMessage); + ClientContext context; + context.set_deadline(grpc_timeout_seconds_to_deadline(/*time_s=*/10)); + grpc::Status result = stub->Echo(&context, request, &response); + EXPECT_TRUE(result.ok()); + if (!result.ok()) { + gpr_log(GPR_ERROR, "%s, %s", result.error_message().c_str(), + result.error_details().c_str()); + } + EXPECT_EQ(response.message(), kMessage); + std::shared_ptr auth_context = context.auth_context(); + std::vector properties = + auth_context->FindPropertyValues(GRPC_SSL_SESSION_REUSED_PROPERTY); + ASSERT_EQ(properties.size(), 1u); + if (expect_session_reuse) { + EXPECT_EQ("true", ToString(properties[0])); + } else { + EXPECT_EQ("false", ToString(properties[0])); } - - grpc_ssl_session_cache_destroy(cache); -} - -TEST_P(SslCredentialsTest, ResumedHandshake) { - // Skip this test if session caching is disabled. - if (!GetParam().use_session_cache) return; - - server_addr_ = absl::StrCat("localhost:", - std::to_string(grpc_pick_unused_port_or_die())); - absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); - notification.WaitForNotification(); - - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); - grpc::SslCredentialsOptions ssl_options; - ssl_options.pem_root_certs = root_cert; - ssl_options.pem_private_key = client_key; - ssl_options.pem_cert_chain = client_cert; - - grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - - auto full_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "false"); - - auto resumed_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "true"); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME), - GRPC_SSL_TRANSPORT_SECURITY_TYPE); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME), - "TSI_PRIVACY_AND_INTEGRITY"); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_X509_CN_PROPERTY_NAME), - "*.test.google.com"); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_X509_SUBJECT_PROPERTY_NAME), - "CN=*.test.google.com,O=Example\\, Co.,L=Chicago,ST=Illinois,C=US"); - EXPECT_THAT( - GetAuthContextPropertyAsList(**resumed_handshake_context, - GRPC_X509_SAN_PROPERTY_NAME), - UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", - "*.test.youtube.com", "192.168.1.3")); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_X509_PEM_CERT_PROPERTY_NAME), - GetFileContents(kServerCertPath)); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_X509_PEM_CERT_CHAIN_PROPERTY_NAME), - GetFileContents(kServerCertPath)); - EXPECT_THAT( - GetAuthContextPropertyAsList(**resumed_handshake_context, - GRPC_PEER_DNS_PROPERTY_NAME), - UnorderedElementsAre("*.test.google.fr", "waterzooi.test.google.be", - "*.test.youtube.com")); - EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, - GRPC_PEER_URI_PROPERTY_NAME), - IsEmpty()); - EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, - GRPC_PEER_EMAIL_PROPERTY_NAME), - IsEmpty()); - EXPECT_THAT(GetAuthContextPropertyAsList(**resumed_handshake_context, - GRPC_PEER_IP_PROPERTY_NAME), - UnorderedElementsAre("192.168.1.3")); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_PEER_SPIFFE_ID_PROPERTY_NAME), - ""); - EXPECT_EQ(GetSessionCacheSize(cache), 1); - - grpc_ssl_session_cache_destroy(cache); } -TEST_P(SslCredentialsTest, SequentialResumption) { - // Skip this test if session caching is disabled. - if (!GetParam().use_session_cache) return; - +TEST_F(SslCredentialsTest, SequentialResumption) { server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); + server_thread_ = new std::thread([&]() { RunServer(¬ification); }); notification.WaitForNotification(); - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); + std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); + std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); + std::string client_cert = + grpc_core::testing::GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -342,38 +136,25 @@ TEST_P(SslCredentialsTest, SequentialResumption) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - auto full_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "false"); + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); for (int i = 0; i < 10; i++) { - auto resumed_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "true"); + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/true); } grpc_ssl_session_cache_destroy(cache); } -TEST_P(SslCredentialsTest, ConcurrentResumption) { - // Skip this test if session caching is disabled. - if (!GetParam().use_session_cache) return; - +TEST_F(SslCredentialsTest, ConcurrentResumption) { server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); + server_thread_ = new std::thread([&]() { RunServer(¬ification); }); notification.WaitForNotification(); - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); + std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); + std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); + std::string client_cert = + grpc_core::testing::GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -381,20 +162,12 @@ TEST_P(SslCredentialsTest, ConcurrentResumption) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(16); - auto full_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "false"); + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); std::vector threads; threads.reserve(10); for (int i = 0; i < 10; i++) { threads.push_back(std::thread([&]() { - auto resumed_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(resumed_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**resumed_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "true"); + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/true); })); } for (auto& t : threads) { @@ -404,19 +177,17 @@ TEST_P(SslCredentialsTest, ConcurrentResumption) { grpc_ssl_session_cache_destroy(cache); } -TEST_P(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { +TEST_F(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { server_addr_ = absl::StrCat("localhost:", std::to_string(grpc_pick_unused_port_or_die())); absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); + server_thread_ = new std::thread([&]() { RunServer(¬ification); }); notification.WaitForNotification(); - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); + std::string root_cert = grpc_core::testing::GetFileContents(kCaCertPath); + std::string client_key = grpc_core::testing::GetFileContents(kClientKeyPath); + std::string client_cert = + grpc_core::testing::GetFileContents(kClientCertPath); grpc::SslCredentialsOptions ssl_options; ssl_options.pem_root_certs = root_cert; ssl_options.pem_private_key = client_key; @@ -424,152 +195,12 @@ TEST_P(SslCredentialsTest, ResumptionFailsDueToNoCapacityInCache) { grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); - for (int i = 0; i < 2; ++i) { - auto full_handshake_context = DoRpc(ssl_options, cache); - EXPECT_EQ(full_handshake_context.status(), absl::OkStatus()); - EXPECT_EQ(GetAuthContextProperty(**full_handshake_context, - GRPC_SSL_SESSION_REUSED_PROPERTY), - "false"); - } + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); + DoRpc(server_addr_, ssl_options, cache, /*expect_session_reuse=*/false); grpc_ssl_session_cache_destroy(cache); } -TEST_P(SslCredentialsTest, ServerCertificateIsUntrusted) { - server_addr_ = absl::StrCat("localhost:", - std::to_string(grpc_pick_unused_port_or_die())); - absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); - notification.WaitForNotification(); - - // Use the client's own leaf cert as the root cert, so that the server's cert - // will not be trusted by the client. - std::string root_cert = GetFileContents(kClientCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); - grpc::SslCredentialsOptions ssl_options; - ssl_options.pem_root_certs = root_cert; - ssl_options.pem_private_key = client_key; - ssl_options.pem_cert_chain = client_cert; - - grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); - - auto auth_context = DoRpc(ssl_options, cache); - EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); - EXPECT_THAT(auth_context.status().message(), - HasSubstr("CERTIFICATE_VERIFY_FAILED")); - EXPECT_EQ(GetSessionCacheSize(cache), 0); - - grpc_ssl_session_cache_destroy(cache); -} - -TEST_P(SslCredentialsTest, ClientCertificateIsUntrusted) { - // Skip this test if the client certificate is not requested. - if (GetParam().request_type == grpc_ssl_client_certificate_request_type:: - GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) { - return; - } - - server_addr_ = absl::StrCat("localhost:", - std::to_string(grpc_pick_unused_port_or_die())); - absl::Notification notification; - server_thread_ = new std::thread([&]() { - // Use the server's own leaf cert as the root cert, so that the client's - // cert will not be trusted by the server. - std::string root_cert = GetFileContents(kServerCertPath); - RunServer(¬ification, root_cert); - }); - notification.WaitForNotification(); - - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); - grpc::SslCredentialsOptions ssl_options; - ssl_options.pem_root_certs = root_cert; - ssl_options.pem_private_key = client_key; - ssl_options.pem_cert_chain = client_cert; - - grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); - - auto auth_context = DoRpc(ssl_options, cache); - if (GetParam().request_type == - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY || - GetParam().request_type == - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY) { - EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); - // TODO(matthewstevenson88): Investigate having a more descriptive error - // message for the client. - EXPECT_THAT(auth_context.status().message(), - HasSubstr("failed to connect")); - EXPECT_EQ(GetSessionCacheSize(cache), 0); - } else { - // TODO(matthewstevenson88): The handshake fails with a certificate - // verification error in these cases. This is a bug. Fix this. - } - - grpc_ssl_session_cache_destroy(cache); -} - -TEST_P(SslCredentialsTest, ServerHostnameVerificationFails) { - server_addr_ = absl::StrCat("localhost:", - std::to_string(grpc_pick_unused_port_or_die())); - absl::Notification notification; - server_thread_ = new std::thread([&]() { - std::string root_cert = GetFileContents(kCaCertPath); - RunServer(¬ification, root_cert); - }); - notification.WaitForNotification(); - - std::string root_cert = GetFileContents(kCaCertPath); - std::string client_key = GetFileContents(kClientKeyPath); - std::string client_cert = GetFileContents(kClientCertPath); - grpc::SslCredentialsOptions ssl_options; - ssl_options.pem_root_certs = root_cert; - ssl_options.pem_private_key = client_key; - ssl_options.pem_cert_chain = client_cert; - - grpc_ssl_session_cache* cache = grpc_ssl_session_cache_create_lru(0); - - auto auth_context = - DoRpc(ssl_options, cache, /*override_ssl_target_name=*/false); - EXPECT_EQ(auth_context.status().code(), absl::StatusCode::kUnavailable); - // TODO(matthewstevenson88): Logs say "No match found for server name: - // localhost." but this error is not propagated to the user. Fix this. - EXPECT_FALSE(auth_context.status().message().empty()); - EXPECT_EQ(GetSessionCacheSize(cache), 0); - - grpc_ssl_session_cache_destroy(cache); -} - -std::vector GetSslOptions() { - std::vector ssl_options; - for (grpc_ssl_client_certificate_request_type type : - {grpc_ssl_client_certificate_request_type:: - GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY, - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, - grpc_ssl_client_certificate_request_type:: - GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY}) { - for (bool use_session_cache : {false, true}) { - SslOptions option = {type, use_session_cache}; - ssl_options.push_back(option); - } - } - return ssl_options; -} - -INSTANTIATE_TEST_SUITE_P(SslCredentials, SslCredentialsTest, - ::testing::ValuesIn(GetSslOptions())); - } // namespace } // namespace testing } // namespace grpc From 297e22cb5f4803061c687adf2c7ee41c63e38320 Mon Sep 17 00:00:00 2001 From: Xuan Wang Date: Mon, 22 Apr 2024 12:06:40 -0700 Subject: [PATCH 35/45] [Python Distribution] Pin setuptools and wheel to a single version (#36400) Closes #36400 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36400 from XuanWang-Amos:python_distribution bd2bd480312b3e75e711216093105f58450b830a PiperOrigin-RevId: 627114699 --- tools/release/verify_python_release.py | 1 + tools/run_tests/artifacts/build_artifact_python.bat | 4 +++- tools/run_tests/artifacts/build_artifact_python.sh | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/release/verify_python_release.py b/tools/release/verify_python_release.py index 82a4cb5cf64..56729fee737 100644 --- a/tools/release/verify_python_release.py +++ b/tools/release/verify_python_release.py @@ -44,6 +44,7 @@ _DEFAULT_PACKAGES = [ "grpcio-testing", "grpcio-admin", "grpcio-csds", + "grpcio-observability", "xds-protos", ] diff --git a/tools/run_tests/artifacts/build_artifact_python.bat b/tools/run_tests/artifacts/build_artifact_python.bat index 587d4b55ff1..f76ac6b31c7 100644 --- a/tools/run_tests/artifacts/build_artifact_python.bat +++ b/tools/run_tests/artifacts/build_artifact_python.bat @@ -19,7 +19,9 @@ set PATH=C:\%1;C:\%1\scripts;%PATH% set PATH=C:\msys64\mingw%2\bin;C:\tools\msys64\mingw%2\bin;%PATH% :end_mingw64_installation -python -m pip install --upgrade pip six setuptools wheel +python -m pip install --upgrade pip six +@rem Ping to a single version to make sure we're building the same artifacts +python -m pip install setuptools==69.5.1 wheel==0.43.0 python -m pip install --upgrade "cython<3.0.0rc1" python -m pip install -rrequirements.txt --user diff --git a/tools/run_tests/artifacts/build_artifact_python.sh b/tools/run_tests/artifacts/build_artifact_python.sh index 866fe15295c..e2bf41eb51c 100755 --- a/tools/run_tests/artifacts/build_artifact_python.sh +++ b/tools/run_tests/artifacts/build_artifact_python.sh @@ -26,7 +26,9 @@ export AUDITWHEEL=${AUDITWHEEL:-auditwheel} source tools/internal_ci/helper_scripts/prepare_ccache_symlinks_rc # Needed for building binary distribution wheels -- bdist_wheel -"${PYTHON}" -m pip install --upgrade pip wheel setuptools +"${PYTHON}" -m pip install --upgrade pip +# Ping to a single version to make sure we're building the same artifacts +"${PYTHON}" -m pip install setuptools==69.5.1 wheel==0.43.0 if [ "$GRPC_SKIP_PIP_CYTHON_UPGRADE" == "" ] then From 10a95e03d97ff694f7d41455047caf601920342d Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Mon, 22 Apr 2024 14:20:08 -0700 Subject: [PATCH 36/45] [ObjC] do not set cfstream client to null on shutdown (#36415) Duo crashes occasionally with the stack trace bellow. I wasn't able to reproduce with stress run a modified version of existing tests, however I suspect what happened was that: cfstream endpoint was shutdown while a callback is being scheduled, so a. [retain](https://github.com/opensource-apple/CF/blob/master/CFStream.c#L595-L598) is about to be called after null check b. client callback [context is cleared](https://github.com/opensource-apple/CF/blob/master/CFStream.c#L1322) during shutdown Since there is no lock in (b), a race can happen and result in retain to be a null pointer and caused the crash. This PR removed setting the client callback to null so the ongoing event delivery can continue; and added clear the dispatch queue so less likely events are scheduled while connection is shutting down. ---- Crash stack trace: ``` Thread 1 (id: 0x0025a274)CRASHED Exception infoEXC_BAD_ACCESS / KERN_INVALID_ADDRESS @0x00000008 Stack Quality95%Show frame trust levels 0x00000001034e79a4 (Tachyon -atomic:1014) long std::__1::__cxx_atomic_fetch_add[abi:v160006](std::__1::__cxx_atomic_base_impl*, long, std::__1::memory_order) 0x00000001034e79a4 (Tachyon -atomic:1649) std::__1::__atomic_base::fetch_add[abi:v160006](long, std::__1::memory_order) 0x00000001034e79a4 (Tachyon -ref_counted.h:78) grpc_core::RefCount::Ref(long) 0x00000001034e79a4 (Tachyon -ref_counted.h:379) grpc_core::RefCounted::IncrementRefCount() const 0x00000001034e79a4 (Tachyon -ref_counted.h:288) grpc_core::RefCounted::Ref() 0x00000001034e79a4 (Tachyon -cfstream_endpoint.h:75) grpc_event_engine::experimental::CFStreamEndpointImpl::Retain(void*) 0x0000000199d2a814 (CoreFoundation + 0x000b8814) _signalEventSync 0x0000000199db0654 (CoreFoundation + 0x0013e654) ___signalEventQueue_block_invoke 0x00000001a1b6d138 (libdispatch.dylib + 0x00002138) _dispatch_call_block_and_release 0x00000001a1b6edd0 (libdispatch.dylib + 0x00003dd0) _dispatch_client_callout 0x00000001a1b71f68 (libdispatch.dylib + 0x00006f68) _dispatch_queue_override_invoke 0x00000001a1b80890 (libdispatch.dylib + 0x00015890) _dispatch_root_queue_drain 0x00000001a1b81098 (libdispatch.dylib + 0x00016098) _dispatch_worker_thread2 0x00000001f5c54ee0 (libsystem_pthread.dylib + 0x00001ee0) _pthread_wqthread ``` Closes #36415 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36415 from HannahShiSFB:cf-event-engine-crash f8f609f304fbcac2d456cf252de29cb9a0ca0e4c PiperOrigin-RevId: 627154676 --- src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc index 0b14723e214..a2307fe36f9 100644 --- a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +++ b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc @@ -249,9 +249,9 @@ void CFStreamEndpointImpl::Shutdown() { read_event_.SetShutdown(shutdownStatus); write_event_.SetShutdown(shutdownStatus); - CFReadStreamSetClient(cf_read_stream_, kCFStreamEventNone, nullptr, nullptr); - CFWriteStreamSetClient(cf_write_stream_, kCFStreamEventNone, nullptr, - nullptr); + CFReadStreamSetDispatchQueue(cf_read_stream_, nullptr); + CFWriteStreamSetDispatchQueue(cf_write_stream_, nullptr); + CFReadStreamClose(cf_read_stream_); CFWriteStreamClose(cf_write_stream_); } From efc07580bf3fcd14370c25cf9935578def91a8ed Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:19:00 -0700 Subject: [PATCH 37/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36408) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement and regex. Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36408 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36408 from tanvi-jagtap:tjagtap_core_security f9eaf451402f864675549b87c637fc832a14776b PiperOrigin-RevId: 627264425 --- CMakeLists.txt | 4 + build_autogenerated.yaml | 4 + test/core/security/BUILD | 20 +- test/core/security/alts_credentials_fuzzer.cc | 10 +- test/core/security/aws_request_signer_test.cc | 12 +- test/core/security/fetch_oauth2.cc | 4 +- .../grpc_tls_certificate_distributor_test.cc | 12 +- .../grpc_tls_certificate_provider_test.cc | 12 +- .../print_google_default_creds_token.cc | 4 +- test/core/security/ssl_server_fuzzer.cc | 9 +- .../security/tls_security_connector_test.cc | 208 +++++++++--------- test/core/security/verify_jwt.cc | 6 +- 12 files changed, 171 insertions(+), 134 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7db2d856ab..d84462bd725 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7397,6 +7397,7 @@ target_include_directories(aws_request_signer_test target_link_libraries(aws_request_signer_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -15807,6 +15808,7 @@ target_include_directories(grpc_tls_certificate_distributor_test target_link_libraries(grpc_tls_certificate_distributor_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -15858,6 +15860,7 @@ target_include_directories(grpc_tls_certificate_provider_test target_link_libraries(grpc_tls_certificate_provider_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -31284,6 +31287,7 @@ target_include_directories(tls_security_connector_test target_link_libraries(tls_security_connector_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index e8e69293969..731c17d651a 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -5775,6 +5775,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: backend_metrics_lb_policy_test gtest: true @@ -10697,6 +10698,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: grpc_tls_certificate_provider_test gtest: true @@ -10727,6 +10729,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: grpc_tls_certificate_verifier_test gtest: true @@ -19560,6 +19563,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: too_many_pings_test gtest: true diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 58c2c6d63f5..8c40aa5fc50 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -23,6 +23,7 @@ grpc_fuzzer( name = "alts_credentials_fuzzer", srcs = ["alts_credentials_fuzzer.cc"], corpus = "corpus/alts_credentials_corpus", + external_deps = ["absl/log:check"], language = "C++", tags = ["no_windows"], deps = [ @@ -42,6 +43,7 @@ grpc_fuzzer( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], + external_deps = ["absl/log:check"], language = "C++", tags = ["no_windows"], deps = [ @@ -112,7 +114,10 @@ grpc_cc_test( grpc_cc_test( name = "aws_request_signer_test", srcs = ["aws_request_signer_test.cc"], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", @@ -250,6 +255,7 @@ grpc_cc_binary( grpc_cc_binary( name = "fetch_oauth2", srcs = ["fetch_oauth2.cc"], + external_deps = ["absl/log:check"], language = "C++", deps = [ ":oauth2_utils", @@ -264,6 +270,7 @@ grpc_cc_binary( grpc_cc_binary( name = "verify_jwt", srcs = ["verify_jwt.cc"], + external_deps = ["absl/log:check"], language = "C++", deps = [ "//:gpr", @@ -339,6 +346,7 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.pem", ], external_deps = [ + "absl/log:check", "gtest", ], language = "C++", @@ -389,7 +397,10 @@ grpc_cc_test( grpc_cc_test( name = "grpc_tls_certificate_distributor_test", srcs = ["grpc_tls_certificate_distributor_test.cc"], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", @@ -412,7 +423,10 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", diff --git a/test/core/security/alts_credentials_fuzzer.cc b/test/core/security/alts_credentials_fuzzer.cc index 1d47a506061..a145ee0f0b0 100644 --- a/test/core/security/alts_credentials_fuzzer.cc +++ b/test/core/security/alts_credentials_fuzzer.cc @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -82,9 +84,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_channel_credentials* cred = grpc_alts_credentials_create_customized( options, handshaker_service_url, enable_untrusted_alts); if (!enable_untrusted_alts && !is_on_gcp) { - GPR_ASSERT(cred == nullptr); + CHECK_EQ(cred, nullptr); } else { - GPR_ASSERT(cred != nullptr); + CHECK_NE(cred, nullptr); } grpc_channel_credentials_release(cred); grpc_alts_credentials_options_destroy(options); @@ -96,9 +98,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_alts_server_credentials_create_customized( options, handshaker_service_url, enable_untrusted_alts); if (!enable_untrusted_alts && !is_on_gcp) { - GPR_ASSERT(cred == nullptr); + CHECK_EQ(cred, nullptr); } else { - GPR_ASSERT(cred != nullptr); + CHECK_NE(cred, nullptr); } grpc_server_credentials_release(cred); grpc_alts_credentials_options_destroy(options); diff --git a/test/core/security/aws_request_signer_test.cc b/test/core/security/aws_request_signer_test.cc index 94f535d3b2d..c877fd5ae47 100644 --- a/test/core/security/aws_request_signer_test.cc +++ b/test/core/security/aws_request_signer_test.cc @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #include "test/core/util/test_config.h" @@ -247,9 +249,8 @@ TEST(GrpcAwsRequestSignerTest, InvalidUrl) { "token", "POST", "invalid_url", "us-east-1", "", {}, &error); std::string actual_error_description; - GPR_ASSERT(grpc_error_get_str(error, - grpc_core::StatusStrProperty::kDescription, - &actual_error_description)); + CHECK(grpc_error_get_str(error, grpc_core::StatusStrProperty::kDescription, + &actual_error_description)); EXPECT_EQ(actual_error_description, "Invalid Aws request url."); } @@ -260,9 +261,8 @@ TEST(GrpcAwsRequestSignerTest, DuplicateRequestDate) { "us-east-1", "", {{"date", kBotoTestDate}, {"x-amz-date", kAmzTestDate}}, &error); std::string actual_error_description; - GPR_ASSERT(grpc_error_get_str(error, - grpc_core::StatusStrProperty::kDescription, - &actual_error_description)); + CHECK(grpc_error_get_str(error, grpc_core::StatusStrProperty::kDescription, + &actual_error_description)); EXPECT_EQ(actual_error_description, "Only one of {date, x-amz-date} can be specified, not both."); } diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index c60c85bbf7f..8dd9c9731ad 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -137,7 +139,7 @@ int main(int argc, char** argv) { "Missing --gce, --json_sts_options, or --json_refresh_token option."); exit(1); } - GPR_ASSERT(creds != nullptr); + CHECK_NE(creds, nullptr); token = grpc_test_fetch_oauth2_token_with_credentials(creds); if (token != nullptr) { diff --git a/test/core/security/grpc_tls_certificate_distributor_test.cc b/test/core/security/grpc_tls_certificate_distributor_test.cc index 8fa6187eaf9..4b4259e9191 100644 --- a/test/core/security/grpc_tls_certificate_distributor_test.cc +++ b/test/core/security/grpc_tls_certificate_distributor_test.cc @@ -24,6 +24,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -133,17 +135,17 @@ class GrpcTlsCertificateDistributorTest : public ::testing::Test { void OnError(grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) override { - GPR_ASSERT(!root_cert_error.ok() || !identity_cert_error.ok()); + CHECK(!root_cert_error.ok() || !identity_cert_error.ok()); std::string root_error_str; std::string identity_error_str; if (!root_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str( + CHECK(grpc_error_get_str( root_cert_error, StatusStrProperty::kDescription, &root_error_str)); } if (!identity_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str(identity_cert_error, - StatusStrProperty::kDescription, - &identity_error_str)); + CHECK(grpc_error_get_str(identity_cert_error, + StatusStrProperty::kDescription, + &identity_error_str)); } state_->error_queue.emplace_back(std::move(root_error_str), std::move(identity_error_str)); diff --git a/test/core/security/grpc_tls_certificate_provider_test.cc b/test/core/security/grpc_tls_certificate_provider_test.cc index 29e9ca0960d..af5491a48e4 100644 --- a/test/core/security/grpc_tls_certificate_provider_test.cc +++ b/test/core/security/grpc_tls_certificate_provider_test.cc @@ -22,6 +22,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -134,17 +136,17 @@ class GrpcTlsCertificateProviderTest : public ::testing::Test { void OnError(grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) override { MutexLock lock(&state_->mu); - GPR_ASSERT(!root_cert_error.ok() || !identity_cert_error.ok()); + CHECK(!root_cert_error.ok() || !identity_cert_error.ok()); std::string root_error_str; std::string identity_error_str; if (!root_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str( + CHECK(grpc_error_get_str( root_cert_error, StatusStrProperty::kDescription, &root_error_str)); } if (!identity_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str(identity_cert_error, - StatusStrProperty::kDescription, - &identity_error_str)); + CHECK(grpc_error_get_str(identity_cert_error, + StatusStrProperty::kDescription, + &identity_error_str)); } state_->error_queue.emplace_back(std::move(root_error_str), std::move(identity_error_str)); diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index 66ea4a904c0..134d3e57d45 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -51,7 +53,7 @@ static void on_metadata_response(void* arg, grpc_error_handle error) { fflush(stderr); } else { char* token; - GPR_ASSERT(sync->md_array.size == 1); + CHECK_EQ(sync->md_array.size, 1u); token = grpc_slice_to_c_string(GRPC_MDVALUE(sync->md_array.md[0])); printf("\nGot token: %s\n\n", token); gpr_free(token); diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index e657550f376..ea4e82123e6 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -15,6 +15,7 @@ // limitations under the License. // // +#include "absl/log/check.h" #include #include @@ -54,10 +55,10 @@ static void on_handshake_done(void* arg, grpc_error_handle error) { static_cast(arg); struct handshake_state* state = static_cast(args->user_data); - GPR_ASSERT(state->done_callback_called == false); + CHECK(state->done_callback_called == false); state->done_callback_called = true; // The fuzzer should not pass the handshake. - GPR_ASSERT(!error.ok()); + CHECK(!error.ok()); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { @@ -86,7 +87,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Create security connector grpc_core::RefCountedPtr sc = creds->create_security_connector(grpc_core::ChannelArgs()); - GPR_ASSERT(sc != nullptr); + CHECK(sc != nullptr); grpc_core::Timestamp deadline = grpc_core::Duration::Seconds(1) + grpc_core::Timestamp::Now(); @@ -110,7 +111,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { GRPC_ERROR_CREATE("Explicit close")); grpc_core::ExecCtx::Get()->Flush(); } - GPR_ASSERT(state.done_callback_called); + CHECK(state.done_callback_called); sc.reset(DEBUG_LOCATION, "test"); grpc_server_credentials_release(creds); diff --git a/test/core/security/tls_security_connector_test.cc b/test/core/security/tls_security_connector_test.cc index 264eb8103db..41ca123eba0 100644 --- a/test/core/security/tls_security_connector_test.cc +++ b/test/core/security/tls_security_connector_test.cc @@ -24,6 +24,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -82,7 +84,7 @@ class TlsSecurityConnectorTest : public ::testing::Test { static std::string GetErrorMsg(grpc_error_handle error) { std::string error_str; - GPR_ASSERT( + CHECK( grpc_error_get_str(error, StatusStrProperty::kDescription, &error_str)); return error_str; } @@ -368,13 +370,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -404,13 +406,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -557,13 +559,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -593,13 +595,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -631,29 +633,29 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a full TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(7, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == - TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_SECURITY_LEVEL_PEER_PROPERTY, - tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), - &peer.properties[3]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", - &peer.properties[4]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[5]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", - &peer.properties[6]) == TSI_OK); + CHECK(tsi_construct_peer(7, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == + TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_SECURITY_LEVEL_PEER_PROPERTY, + tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), + &peer.properties[3]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", + &peer.properties[4]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[5]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", + &peer.properties[6]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -679,29 +681,29 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a full TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(7, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", - &peer.properties[1]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == - TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_SECURITY_LEVEL_PEER_PROPERTY, - tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), - &peer.properties[3]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", - &peer.properties[4]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", - &peer.properties[5]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", - &peer.properties[6]) == TSI_OK); + CHECK(tsi_construct_peer(7, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", + &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == + TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_SECURITY_LEVEL_PEER_PROPERTY, + tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), + &peer.properties[3]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", + &peer.properties[4]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", + &peer.properties[5]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", + &peer.properties[6]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: Hostname " @@ -988,13 +990,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -1019,13 +1021,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -1054,13 +1056,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -1087,13 +1089,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 9b64fc8e124..c9178d230f1 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -55,13 +57,13 @@ static void on_jwt_verification_done(void* user_data, sync->success = (status == GRPC_JWT_VERIFIER_OK); if (sync->success) { - GPR_ASSERT(claims != nullptr); + CHECK_NE(claims, nullptr); std::string claims_str = grpc_core::JsonDump(*grpc_jwt_claims_json(claims), /*indent=*/2); printf("Claims: \n\n%s\n", claims_str.c_str()); grpc_jwt_claims_destroy(claims); } else { - GPR_ASSERT(claims == nullptr); + CHECK_EQ(claims, nullptr); fprintf(stderr, "Verification failed with error %s\n", grpc_jwt_verifier_status_to_string(status)); fflush(stderr); From 8dd1566481ef4106f0cd550327d8e095b5b37a5c Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:05:50 -0700 Subject: [PATCH 38/45] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36398) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36398 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36398 from tanvi-jagtap:tjagtap_close_fd_test 56cad2c009ce6d16e5f50c152d0e6de92d2be257 PiperOrigin-RevId: 627272736 --- test/core/bad_connection/BUILD | 1 + test/core/bad_connection/close_fd_test.cc | 121 +++++++++++----------- 2 files changed, 62 insertions(+), 60 deletions(-) diff --git a/test/core/bad_connection/BUILD b/test/core/bad_connection/BUILD index 6a0ce0c923c..e2ae2e91d88 100644 --- a/test/core/bad_connection/BUILD +++ b/test/core/bad_connection/BUILD @@ -23,6 +23,7 @@ grpc_cc_binary( srcs = [ "close_fd_test.cc", ], + external_deps = ["absl/log:check"], language = "C++", tags = ["no_windows"], deps = [ diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index 0e6f9086e3f..33a3e8247c1 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -23,6 +23,7 @@ // #include +#include "absl/log/check.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" @@ -92,7 +93,7 @@ static void server_setup_transport(grpc_core::Transport* transport) { grpc_core::ExecCtx exec_ctx; grpc_endpoint_add_to_pollset(g_ctx.ep->server, grpc_cq_pollset(g_ctx.cq)); grpc_core::Server* core_server = grpc_core::Server::FromC(g_ctx.server); - GPR_ASSERT(GRPC_LOG_IF_ERROR( + CHECK(GRPC_LOG_IF_ERROR( "SetupTransport", core_server->SetupTransport(transport, nullptr, core_server->channel_args(), nullptr))); @@ -123,14 +124,14 @@ static void init_client() { transport = grpc_create_chttp2_transport(grpc_core::ChannelArgs(), g_ctx.ep->client, true); client_setup_transport(transport); - GPR_ASSERT(g_ctx.client); + CHECK(g_ctx.client); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr); } static void init_server() { grpc_core::ExecCtx exec_ctx; grpc_core::Transport* transport; - GPR_ASSERT(!g_ctx.server); + CHECK(!g_ctx.server); g_ctx.server = grpc_server_create(nullptr, nullptr); grpc_server_register_completion_queue(g_ctx.server, g_ctx.cq, nullptr); grpc_server_start(g_ctx.server); @@ -174,10 +175,10 @@ static void drain_and_destroy_cq(grpc_completion_queue* cq) { static void shutdown_server() { if (!g_ctx.server) return; grpc_server_shutdown_and_notify(g_ctx.server, g_ctx.shutdown_cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(g_ctx.shutdown_cq, tag(1000), - grpc_timeout_seconds_to_deadline(1), - nullptr) - .type == GRPC_OP_COMPLETE); + CHECK(grpc_completion_queue_pluck(g_ctx.shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(1), + nullptr) + .type == GRPC_OP_COMPLETE); grpc_server_destroy(g_ctx.server); g_ctx.server = nullptr; } @@ -244,7 +245,7 @@ static void _test_close_before_server_recv(fd_type fdtype) { call = grpc_channel_create_call( g_ctx.client, nullptr, GRPC_PROPAGATE_DEFAULTS, g_ctx.client_cq, grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); - GPR_ASSERT(call); + CHECK(call); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -286,17 +287,17 @@ static void _test_close_before_server_recv(fd_type fdtype) { op++; error = grpc_call_start_batch(call, ops, static_cast(op - ops), tag(1), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); error = grpc_server_request_call(g_ctx.server, &server_call, &call_details, &request_metadata_recv, g_ctx.bound_cq, g_ctx.cq, tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); event = grpc_completion_queue_next( g_ctx.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(101)); - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(101)); + CHECK(event.type == GRPC_OP_COMPLETE); memset(ops, 0, sizeof(ops)); op = ops; @@ -316,7 +317,7 @@ static void _test_close_before_server_recv(fd_type fdtype) { if (fdtype == SERVER_FD) { fd = sfd->server->vtable->get_fd(sfd->server); } else { - GPR_ASSERT(fdtype == CLIENT_FD); + CHECK(fdtype == CLIENT_FD); fd = sfd->client->vtable->get_fd(sfd->client); } // Connection is closed before the server receives the client's message. @@ -324,7 +325,7 @@ static void _test_close_before_server_recv(fd_type fdtype) { error = grpc_call_start_batch(server_call, ops, static_cast(op - ops), tag(102), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); event = grpc_completion_queue_next( g_ctx.bound_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); @@ -335,8 +336,8 @@ static void _test_close_before_server_recv(fd_type fdtype) { // happen due to a race with closing the fd resulting in pending writes // failing due to stream closure. // - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); - GPR_ASSERT(event.tag == tag(102)); + CHECK(event.type == GRPC_OP_COMPLETE); + CHECK(event.tag == tag(102)); event = grpc_completion_queue_next( g_ctx.client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); @@ -350,14 +351,14 @@ static void _test_close_before_server_recv(fd_type fdtype) { // 2. client receives GRPC_STATUS_UNAVAILABLE from server // if (event.type == GRPC_QUEUE_TIMEOUT) { - GPR_ASSERT(event.success == 0); + CHECK_EQ(event.success, 0); // status is not initialized - GPR_ASSERT(status == GRPC_STATUS__DO_NOT_USE); + CHECK_EQ(status, GRPC_STATUS__DO_NOT_USE); } else { - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(1)); - GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); + CHECK(event.type == GRPC_OP_COMPLETE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(1)); + CHECK_EQ(status, GRPC_STATUS_UNAVAILABLE); } grpc_metadata_array_destroy(&initial_metadata_recv); @@ -419,7 +420,7 @@ static void _test_close_before_server_send(fd_type fdtype) { call = grpc_channel_create_call( g_ctx.client, nullptr, GRPC_PROPAGATE_DEFAULTS, g_ctx.client_cq, grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); - GPR_ASSERT(call); + CHECK(call); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -461,17 +462,17 @@ static void _test_close_before_server_send(fd_type fdtype) { op++; error = grpc_call_start_batch(call, ops, static_cast(op - ops), tag(1), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); error = grpc_server_request_call(g_ctx.server, &server_call, &call_details, &request_metadata_recv, g_ctx.bound_cq, g_ctx.cq, tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); event = grpc_completion_queue_next( g_ctx.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(101)); - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(101)); + CHECK(event.type == GRPC_OP_COMPLETE); memset(ops, 0, sizeof(ops)); op = ops; @@ -487,13 +488,13 @@ static void _test_close_before_server_send(fd_type fdtype) { op++; error = grpc_call_start_batch(server_call, ops, static_cast(op - ops), tag(102), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); event = grpc_completion_queue_next( g_ctx.bound_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(102)); + CHECK(event.type == GRPC_OP_COMPLETE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(102)); memset(ops, 0, sizeof(ops)); op = ops; @@ -521,7 +522,7 @@ static void _test_close_before_server_send(fd_type fdtype) { if (fdtype == SERVER_FD) { fd = sfd->server->vtable->get_fd(sfd->server); } else { - GPR_ASSERT(fdtype == CLIENT_FD); + CHECK(fdtype == CLIENT_FD); fd = sfd->client->vtable->get_fd(sfd->client); } @@ -530,14 +531,14 @@ static void _test_close_before_server_send(fd_type fdtype) { close(fd); error = grpc_call_start_batch(server_call, ops, static_cast(op - ops), tag(103), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); // Batch operation succeeds on the server side event = grpc_completion_queue_next( g_ctx.bound_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(103)); + CHECK(event.type == GRPC_OP_COMPLETE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(103)); event = grpc_completion_queue_next( g_ctx.client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); @@ -547,16 +548,16 @@ static void _test_close_before_server_send(fd_type fdtype) { // waiting on the completion queue // if (event.type == GRPC_OP_COMPLETE) { - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.tag == tag(1)); - GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); + CHECK_EQ(event.success, 1); + CHECK(event.tag == tag(1)); + CHECK_EQ(status, GRPC_STATUS_UNAVAILABLE); } else { - GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); - GPR_ASSERT(event.success == 0); + CHECK(event.type == GRPC_QUEUE_TIMEOUT); + CHECK_EQ(event.success, 0); // status is not initialized - GPR_ASSERT(status == GRPC_STATUS__DO_NOT_USE); + CHECK_EQ(status, GRPC_STATUS__DO_NOT_USE); } - GPR_ASSERT(was_cancelled == 0); + CHECK_EQ(was_cancelled, 0); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); @@ -615,7 +616,7 @@ static void _test_close_before_client_send(fd_type fdtype) { call = grpc_channel_create_call( g_ctx.client, nullptr, GRPC_PROPAGATE_DEFAULTS, g_ctx.client_cq, grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); - GPR_ASSERT(call); + CHECK(call); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -661,7 +662,7 @@ static void _test_close_before_client_send(fd_type fdtype) { if (fdtype == SERVER_FD) { fd = sfd->server->vtable->get_fd(sfd->server); } else { - GPR_ASSERT(fdtype == CLIENT_FD); + CHECK(fdtype == CLIENT_FD); fd = sfd->client->vtable->get_fd(sfd->client); } // Connection is closed before the client sends a batch to the server @@ -669,22 +670,22 @@ static void _test_close_before_client_send(fd_type fdtype) { error = grpc_call_start_batch(call, ops, static_cast(op - ops), tag(1), nullptr); - GPR_ASSERT(GRPC_CALL_OK == error); + CHECK_EQ(error, GRPC_CALL_OK); // Status unavailable is returned to the client when client or server fd is // closed event = grpc_completion_queue_next( g_ctx.client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.success == 1); - GPR_ASSERT(event.type == GRPC_OP_COMPLETE); - GPR_ASSERT(event.tag == tag(1)); - GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); + CHECK_EQ(event.success, 1); + CHECK(event.type == GRPC_OP_COMPLETE); + CHECK(event.tag == tag(1)); + CHECK_EQ(status, GRPC_STATUS_UNAVAILABLE); // No event is received on the server event = grpc_completion_queue_next( g_ctx.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.success == 0); - GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); + CHECK_EQ(event.success, 0); + CHECK(event.type == GRPC_QUEUE_TIMEOUT); grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); @@ -723,7 +724,7 @@ static void _test_close_before_call_create(fd_type fdtype) { if (fdtype == SERVER_FD) { fd = sfd->server->vtable->get_fd(sfd->server); } else { - GPR_ASSERT(fdtype == CLIENT_FD); + CHECK(fdtype == CLIENT_FD); fd = sfd->client->vtable->get_fd(sfd->client); } // Connection is closed before the client creates a call @@ -732,19 +733,19 @@ static void _test_close_before_call_create(fd_type fdtype) { call = grpc_channel_create_call( g_ctx.client, nullptr, GRPC_PROPAGATE_DEFAULTS, g_ctx.client_cq, grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr); - GPR_ASSERT(call); + CHECK(call); // Client and server time out waiting on their completion queues and nothing // is sent or received event = grpc_completion_queue_next( g_ctx.client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); - GPR_ASSERT(event.success == 0); + CHECK(event.type == GRPC_QUEUE_TIMEOUT); + CHECK_EQ(event.success, 0); event = grpc_completion_queue_next( g_ctx.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr); - GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); - GPR_ASSERT(event.success == 0); + CHECK(event.type == GRPC_QUEUE_TIMEOUT); + CHECK_EQ(event.success, 0); grpc_call_unref(call); end_test(); From af67a65c42690c8f1b26b067e494164972c3eb3c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Apr 2024 10:01:42 -0700 Subject: [PATCH 39/45] [clang-format] Remove requirement that port_platform.h is at the top (#36300) Closes #36300 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36300 from ctiller:port_platform-src-core-ext-transport-chttp2-transport-clang-format 471433f90f8be34fe134541e9b0f6c70aea63633 PiperOrigin-RevId: 627422135 --- src/core/ext/transport/chttp2/transport/.clang-format | 3 --- src/core/ext/transport/chttp2/transport/bin_decoder.cc | 3 +-- src/core/ext/transport/chttp2/transport/bin_decoder.h | 3 +-- src/core/ext/transport/chttp2/transport/bin_encoder.cc | 3 +-- src/core/ext/transport/chttp2/transport/bin_encoder.h | 3 +-- src/core/ext/transport/chttp2/transport/chttp2_transport.cc | 3 +-- src/core/ext/transport/chttp2/transport/chttp2_transport.h | 3 +-- src/core/ext/transport/chttp2/transport/context_list_entry.h | 4 ++-- src/core/ext/transport/chttp2/transport/decode_huff.cc | 4 ++-- src/core/ext/transport/chttp2/transport/decode_huff.h | 4 ++-- src/core/ext/transport/chttp2/transport/flow_control.cc | 3 +-- src/core/ext/transport/chttp2/transport/flow_control.h | 3 +-- src/core/ext/transport/chttp2/transport/frame.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame.h | 4 ++-- src/core/ext/transport/chttp2/transport/frame_data.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_data.h | 3 +-- src/core/ext/transport/chttp2/transport/frame_goaway.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_goaway.h | 3 +-- src/core/ext/transport/chttp2/transport/frame_ping.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_ping.h | 3 +-- src/core/ext/transport/chttp2/transport/frame_rst_stream.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_rst_stream.h | 3 +-- src/core/ext/transport/chttp2/transport/frame_settings.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_settings.h | 3 +-- .../ext/transport/chttp2/transport/frame_window_update.cc | 3 +-- src/core/ext/transport/chttp2/transport/frame_window_update.h | 3 +-- src/core/ext/transport/chttp2/transport/hpack_constants.h | 4 ++-- src/core/ext/transport/chttp2/transport/hpack_encoder.cc | 3 +-- src/core/ext/transport/chttp2/transport/hpack_encoder.h | 3 +-- .../ext/transport/chttp2/transport/hpack_encoder_table.cc | 3 +-- src/core/ext/transport/chttp2/transport/hpack_encoder_table.h | 4 ++-- src/core/ext/transport/chttp2/transport/hpack_parse_result.cc | 4 ++-- src/core/ext/transport/chttp2/transport/hpack_parse_result.h | 3 +-- src/core/ext/transport/chttp2/transport/hpack_parser.cc | 3 +-- src/core/ext/transport/chttp2/transport/hpack_parser.h | 3 +-- src/core/ext/transport/chttp2/transport/hpack_parser_table.cc | 3 +-- src/core/ext/transport/chttp2/transport/hpack_parser_table.h | 4 ++-- src/core/ext/transport/chttp2/transport/http2_settings.cc | 4 ++-- src/core/ext/transport/chttp2/transport/http2_settings.h | 4 ++-- src/core/ext/transport/chttp2/transport/http_trace.cc | 4 ++-- src/core/ext/transport/chttp2/transport/huffsyms.cc | 4 ++-- src/core/ext/transport/chttp2/transport/internal.h | 3 +-- .../chttp2/transport/max_concurrent_streams_policy.cc | 3 +-- .../chttp2/transport/max_concurrent_streams_policy.h | 4 ++-- src/core/ext/transport/chttp2/transport/parsing.cc | 3 +-- src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc | 3 +-- src/core/ext/transport/chttp2/transport/ping_abuse_policy.h | 4 ++-- src/core/ext/transport/chttp2/transport/ping_callbacks.cc | 3 +-- src/core/ext/transport/chttp2/transport/ping_callbacks.h | 3 +-- src/core/ext/transport/chttp2/transport/ping_rate_policy.cc | 3 +-- src/core/ext/transport/chttp2/transport/ping_rate_policy.h | 4 ++-- src/core/ext/transport/chttp2/transport/stream_lists.cc | 3 +-- src/core/ext/transport/chttp2/transport/varint.cc | 4 ++-- src/core/ext/transport/chttp2/transport/varint.h | 3 +-- src/core/ext/transport/chttp2/transport/write_size_policy.cc | 3 +-- src/core/ext/transport/chttp2/transport/write_size_policy.h | 4 ++-- src/core/ext/transport/chttp2/transport/writing.cc | 3 +-- 57 files changed, 73 insertions(+), 115 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/.clang-format b/src/core/ext/transport/chttp2/transport/.clang-format index 64387e9e515..5f150ef6edb 100644 --- a/src/core/ext/transport/chttp2/transport/.clang-format +++ b/src/core/ext/transport/chttp2/transport/.clang-format @@ -5,9 +5,6 @@ DerivePointerAlignment: false PointerAlignment: Left IncludeBlocks: Regroup IncludeCategories: - # port_platform.h is before almost everything - - Regex: '^' - Priority: -100 # ruby.h is even more first if it's included - Regex: '^' Priority: -200 diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.cc b/src/core/ext/transport/chttp2/transport/bin_decoder.cc index be22231b074..78a55b6cecc 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.cc +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.cc @@ -16,14 +16,13 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/bin_decoder.h" #include "absl/base/attributes.h" #include #include +#include #include "src/core/lib/slice/slice.h" diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h index a8eacc134fa..fc87450d365 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -19,12 +19,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H -#include - #include #include #include +#include struct grpc_base64_decode_context { // input/output: diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.cc b/src/core/ext/transport/chttp2/transport/bin_encoder.cc index 033b4cb2252..821006f2ce6 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.cc @@ -16,14 +16,13 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include #include #include +#include #include "src/core/ext/transport/chttp2/transport/huffsyms.h" diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h index 1b43d017055..fbada017abc 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -19,11 +19,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H -#include - #include #include +#include // base64 encode a slice. Returns a new slice, does not take ownership of the // input diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index a1e490e44b6..dff513f47da 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -14,8 +14,6 @@ // limitations under the License. // -#include - #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include @@ -54,6 +52,7 @@ #include #include #include +#include #include #include "src/core/ext/transport/chttp2/transport/context_list_entry.h" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index 72c1d160e28..d83b38e8c5c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -19,14 +19,13 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H -#include - #include #include #include "absl/types/optional.h" #include +#include #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" diff --git a/src/core/ext/transport/chttp2/transport/context_list_entry.h b/src/core/ext/transport/chttp2/transport/context_list_entry.h index 8368d807a99..cf080874fe7 100644 --- a/src/core/ext/transport/chttp2/transport/context_list_entry.h +++ b/src/core/ext/transport/chttp2/transport/context_list_entry.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_ENTRY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_ENTRY_H -#include - #include #include @@ -28,6 +26,8 @@ #include #include +#include + #include "src/core/lib/channel/tcp_tracer.h" namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/decode_huff.cc b/src/core/ext/transport/chttp2/transport/decode_huff.cc index cdbab5a4e12..8a2300dac4b 100644 --- a/src/core/ext/transport/chttp2/transport/decode_huff.cc +++ b/src/core/ext/transport/chttp2/transport/decode_huff.cc @@ -15,9 +15,9 @@ // This file is autogenerated: see // tools/codegen/core/gen_huffman_decompressor.cc -#include - #include "src/core/ext/transport/chttp2/transport/decode_huff.h" + +#include namespace grpc_core { const uint8_t HuffDecoderCommon::table2_0_emit_[10] = { 0x30, 0x31, 0x32, 0x61, 0x63, 0x65, 0x69, 0x6f, 0x73, 0x74}; diff --git a/src/core/ext/transport/chttp2/transport/decode_huff.h b/src/core/ext/transport/chttp2/transport/decode_huff.h index 21f087585c0..2562f9d0d97 100644 --- a/src/core/ext/transport/chttp2/transport/decode_huff.h +++ b/src/core/ext/transport/chttp2/transport/decode_huff.h @@ -17,10 +17,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_DECODE_HUFF_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_DECODE_HUFF_H -#include - #include #include + +#include namespace grpc_core { class HuffDecoderCommon { protected: diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index a24828e7a11..5f8ece36e63 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include @@ -34,6 +32,7 @@ #include "absl/strings/str_join.h" #include +#include #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/lib/experiments/experiments.h" diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h index 82dde68754f..60ac7686fe3 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/src/core/ext/transport/chttp2/transport/flow_control.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FLOW_CONTROL_H -#include - #include #include @@ -34,6 +32,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/lib/debug/trace.h" diff --git a/src/core/ext/transport/chttp2/transport/frame.cc b/src/core/ext/transport/chttp2/transport/frame.cc index 4a297d546d1..e416c8d0352 100644 --- a/src/core/ext/transport/chttp2/transport/frame.cc +++ b/src/core/ext/transport/chttp2/transport/frame.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/frame.h" #include @@ -25,6 +23,7 @@ #include "absl/strings/str_cat.h" #include +#include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/ext/transport/chttp2/transport/frame.h b/src/core/ext/transport/chttp2/transport/frame.h index be20ef4a0c0..ac6b9e771dd 100644 --- a/src/core/ext/transport/chttp2/transport/frame.h +++ b/src/core/ext/transport/chttp2/transport/frame.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H -#include - #include #include #include @@ -26,6 +24,8 @@ #include "absl/types/span.h" #include "absl/types/variant.h" +#include + #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index e10dea34134..551887779f2 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_data.h" #include @@ -27,6 +25,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/experiments/experiments.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index a3327d38343..1e628d48ddf 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -21,13 +21,12 @@ // Parser for GRPC streams embedded in DATA frames -#include - #include #include "absl/status/status.h" #include +#include #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc index e7d1c558d4f..7122d67901d 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" #include @@ -30,6 +28,7 @@ #include #include #include +#include #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index e4384049df1..40f132721e7 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -19,11 +19,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H -#include - #include #include +#include #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index f2e92a2829d..e973958a60b 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include @@ -31,6 +29,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 82c477de2e8..6f4cd55ff41 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -19,11 +19,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H -#include - #include #include +#include #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc index 71e5cd7098f..635489c953e 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h" #include @@ -29,6 +27,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index 6c7f3b95d30..1da9c0e457a 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -19,11 +19,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H -#include - #include #include +#include #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index c0e24c336ee..eb3343d0c3d 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_settings.h" #include @@ -30,6 +28,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/frame_goaway.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index 56dc5baae6a..ba653c6a11c 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -19,12 +19,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H -#include - #include #include #include +#include #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/src/core/ext/transport/chttp2/transport/frame_window_update.cc index 45c122065f3..5ec5db8d0da 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/frame_window_update.h" #include @@ -27,6 +25,7 @@ #include "absl/strings/str_format.h" #include +#include #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 66f1843befa..92ea1587010 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -19,11 +19,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H -#include - #include #include +#include #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_constants.h b/src/core/ext/transport/chttp2/transport/hpack_constants.h index d709e0ba278..739c57ba3e3 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_constants.h +++ b/src/core/ext/transport/chttp2/transport/hpack_constants.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_CONSTANTS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_CONSTANTS_H -#include - #include #include +#include + namespace grpc_core { namespace hpack_constants { // Per entry overhead bytes as per the spec diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index ed615d5acd6..c359a4334a7 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include @@ -26,6 +24,7 @@ #include #include #include +#include #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 1ec60140151..94c520ae55b 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H -#include - #include #include @@ -33,6 +31,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc index 55d2e444dda..92ba2f644ba 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h" #include #include +#include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h index 9716333773d..1bde664d0fd 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h @@ -15,14 +15,14 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_TABLE_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_TABLE_H -#include - #include #include #include #include +#include + #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc b/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc index 4e87d291d8c..be7aebf28f5 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include #include "absl/strings/str_format.h" +#include + #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parse_result.h b/src/core/ext/transport/chttp2/transport/hpack_parse_result.h index 4a551e94475..f5296f61041 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parse_result.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSE_RESULT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSE_RESULT_H -#include - #include #include @@ -29,6 +27,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/ref_counted.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 9cc98d7e204..57a9a1e157a 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include @@ -39,6 +37,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/decode_huff.h" #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index fe13dd7b4f1..95f752c3ba8 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H -#include - #include #include @@ -36,6 +34,7 @@ #include "absl/types/variant.h" #include +#include #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc b/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc index c5479186e5a..2796f9571e2 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc @@ -16,8 +16,6 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h" #include @@ -32,6 +30,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser_table.h b/src/core/ext/transport/chttp2/transport/hpack_parser_table.h index f8684511f5f..d126b3eeb43 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser_table.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_TABLE_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_TABLE_H -#include - #include #include @@ -29,6 +27,8 @@ #include "absl/functional/function_ref.h" +#include + #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/lib/gprpp/no_destruct.h" diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.cc b/src/core/ext/transport/chttp2/transport/http2_settings.cc index d9e43412502..b3a6ab25417 100644 --- a/src/core/ext/transport/chttp2/transport/http2_settings.cc +++ b/src/core/ext/transport/chttp2/transport/http2_settings.cc @@ -18,12 +18,12 @@ // Automatically generated by tools/codegen/core/gen_settings_ids.py // -#include - #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "absl/strings/str_cat.h" +#include + #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/transport/http2_errors.h" diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h index 8578d913407..8d65aa91085 100644 --- a/src/core/ext/transport/chttp2/transport/http2_settings.h +++ b/src/core/ext/transport/chttp2/transport/http2_settings.h @@ -17,8 +17,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H -#include - #include #include @@ -27,6 +25,8 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include + #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/transport/http2_errors.h" diff --git a/src/core/ext/transport/chttp2/transport/http_trace.cc b/src/core/ext/transport/chttp2/transport/http_trace.cc index 1033102373f..41c17a33d34 100644 --- a/src/core/ext/transport/chttp2/transport/http_trace.cc +++ b/src/core/ext/transport/chttp2/transport/http_trace.cc @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/http_trace.h" +#include + grpc_core::TraceFlag grpc_http_trace(false, "http"); diff --git a/src/core/ext/transport/chttp2/transport/huffsyms.cc b/src/core/ext/transport/chttp2/transport/huffsyms.cc index 32f451e3913..e6ef22056d6 100644 --- a/src/core/ext/transport/chttp2/transport/huffsyms.cc +++ b/src/core/ext/transport/chttp2/transport/huffsyms.cc @@ -16,10 +16,10 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/huffsyms.h" +#include + // Constants pulled from the HPACK spec, and converted to C using the vim // command: // :%s/.* \([0-9a-f]\+\) \[ *\([0-9]\+\)\]/{0x\1, \2},/g diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 8e8be510b10..bcd2495f7b1 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -19,8 +19,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H -#include - #include #include @@ -39,6 +37,7 @@ #include #include #include +#include #include #include "src/core/channelz/channelz.h" diff --git a/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc b/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc index efe4c31011e..1479edf450a 100644 --- a/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc +++ b/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h" #include #include +#include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h b/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h index e8ec52eeef1..a2a56d2bfe5 100644 --- a/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h +++ b/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_MAX_CONCURRENT_STREAMS_POLICY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_MAX_CONCURRENT_STREAMS_POLICY_H -#include - #include #include +#include + namespace grpc_core { class Chttp2MaxConcurrentStreamsPolicy { diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 6ea01b3c1df..3a7460392a8 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -16,8 +16,6 @@ // // -#include - #include #include @@ -41,6 +39,7 @@ #include #include #include +#include #include "src/core/channelz/channelz.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc index 48e7b43586d..d1f371537f7 100644 --- a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" #include @@ -22,6 +20,7 @@ #include "absl/types/optional.h" #include +#include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h index 9663d23bb32..3d834a8665e 100644 --- a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h @@ -15,10 +15,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H -#include - #include +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/ext/transport/chttp2/transport/ping_callbacks.cc b/src/core/ext/transport/chttp2/transport/ping_callbacks.cc index 4081f22af79..4b52aa04bf2 100644 --- a/src/core/ext/transport/chttp2/transport/ping_callbacks.cc +++ b/src/core/ext/transport/chttp2/transport/ping_callbacks.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/ping_callbacks.h" #include @@ -22,6 +20,7 @@ #include "absl/random/distributions.h" #include +#include grpc_core::TraceFlag grpc_ping_trace(false, "http2_ping"); diff --git a/src/core/ext/transport/chttp2/transport/ping_callbacks.h b/src/core/ext/transport/chttp2/transport/ping_callbacks.h index f1d8b826725..58a762aa013 100644 --- a/src/core/ext/transport/chttp2/transport/ping_callbacks.h +++ b/src/core/ext/transport/chttp2/transport/ping_callbacks.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_CALLBACKS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_CALLBACKS_H -#include - #include #include @@ -30,6 +28,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc index 3bf1cf634bc..fed8ca20371 100644 --- a/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include @@ -23,6 +21,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/gprpp/match.h" diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.h b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h index bf95315c94f..b9501686d95 100644 --- a/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H -#include - #include #include @@ -24,6 +22,8 @@ #include "absl/types/variant.h" +#include + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc index 36c09e773b5..7ba1242a7ed 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -16,9 +16,8 @@ // // -#include - #include +#include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/ext/transport/chttp2/transport/legacy_frame.h" diff --git a/src/core/ext/transport/chttp2/transport/varint.cc b/src/core/ext/transport/chttp2/transport/varint.cc index db08fe054bf..7af77e772be 100644 --- a/src/core/ext/transport/chttp2/transport/varint.cc +++ b/src/core/ext/transport/chttp2/transport/varint.cc @@ -16,12 +16,12 @@ // // -#include - #include "src/core/ext/transport/chttp2/transport/varint.h" #include "absl/base/attributes.h" +#include + namespace grpc_core { size_t VarintLength(size_t tail_value) { diff --git a/src/core/ext/transport/chttp2/transport/varint.h b/src/core/ext/transport/chttp2/transport/varint.h index 72c151022fe..3dc97f5240a 100644 --- a/src/core/ext/transport/chttp2/transport/varint.h +++ b/src/core/ext/transport/chttp2/transport/varint.h @@ -19,12 +19,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H -#include - #include #include #include +#include // Helpers for hpack varint encoding diff --git a/src/core/ext/transport/chttp2/transport/write_size_policy.cc b/src/core/ext/transport/chttp2/transport/write_size_policy.cc index 9aae5197e56..34ec3e23699 100644 --- a/src/core/ext/transport/chttp2/transport/write_size_policy.cc +++ b/src/core/ext/transport/chttp2/transport/write_size_policy.cc @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/chttp2/transport/write_size_policy.h" #include #include +#include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/write_size_policy.h b/src/core/ext/transport/chttp2/transport/write_size_policy.h index a300dbd4c2e..a1eae8fec9e 100644 --- a/src/core/ext/transport/chttp2/transport/write_size_policy.h +++ b/src/core/ext/transport/chttp2/transport/write_size_policy.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_WRITE_SIZE_POLICY_H #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_WRITE_SIZE_POLICY_H -#include - #include #include +#include + #include "src/core/lib/gprpp/time.h" namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 693e43ea9a6..526bf73f83a 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -16,8 +16,6 @@ // // -#include - #include #include @@ -34,6 +32,7 @@ #include #include #include +#include #include #include "src/core/channelz/channelz.h" From 597154c2a75f082d33a05d2c182844f5d5175f7c Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Apr 2024 10:24:49 -0700 Subject: [PATCH 40/45] [reorg] move tests to directories that correspond to the src tree (#36424) Closes #36424 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36424 from markdroth:reorg_test 44c219c7ea05bd6d748a8c93682499d69d97160c PiperOrigin-RevId: 627430577 --- CMakeLists.txt | 56 +++++----- build_autogenerated.yaml | 58 +++++----- test/core/channel/BUILD | 52 --------- test/core/channelz/BUILD | 71 ++++++++++++ .../channel_trace_test.cc | 0 .../channelz_registry_test.cc | 0 .../{channel => channelz}/channelz_test.cc | 0 test/core/client_channel/BUILD | 15 --- test/core/client_channel/resolvers/BUILD | 104 ------------------ test/core/handshake/BUILD | 15 +++ .../http_proxy_mapper_test.cc | 0 .../lb_policy => load_balancing}/BUILD | 2 +- .../lb_policy_test_lib.h | 6 +- ...outlier_detection_lb_config_parser_test.cc | 0 .../outlier_detection_test.cc | 2 +- .../pick_first_test.cc | 2 +- .../ring_hash_test.cc | 2 +- .../rls_lb_config_parser_test.cc | 0 .../round_robin_test.cc | 2 +- .../static_stride_scheduler_benchmark.cc | 0 .../static_stride_scheduler_test.cc | 0 .../weighted_round_robin_config_test.cc | 0 .../weighted_round_robin_test.cc | 2 +- ...xds_override_host_lb_config_parser_test.cc | 0 .../xds_override_host_test.cc | 2 +- test/core/resolver/BUILD | 87 ++++++++++++++- .../binder_resolver_test.cc | 0 .../dns_resolver_cooldown_test.cc | 0 .../dns_resolver_test.cc | 0 .../fake_resolver_test.cc | 0 .../google_c2p_resolver_test.cc | 0 .../sockaddr_resolver_test.cc | 0 tools/run_tests/generated/tests.json | 2 +- 33 files changed, 240 insertions(+), 240 deletions(-) create mode 100644 test/core/channelz/BUILD rename test/core/{channel => channelz}/channel_trace_test.cc (100%) rename test/core/{channel => channelz}/channelz_registry_test.cc (100%) rename test/core/{channel => channelz}/channelz_test.cc (100%) delete mode 100644 test/core/client_channel/resolvers/BUILD rename test/core/{client_channel => handshake}/http_proxy_mapper_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/BUILD (99%) rename test/core/{client_channel/lb_policy => load_balancing}/lb_policy_test_lib.h (99%) rename test/core/{client_channel/lb_policy => load_balancing}/outlier_detection_lb_config_parser_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/outlier_detection_test.cc (99%) rename test/core/{client_channel/lb_policy => load_balancing}/pick_first_test.cc (99%) rename test/core/{client_channel/lb_policy => load_balancing}/ring_hash_test.cc (99%) rename test/core/{client_channel/lb_policy => load_balancing}/rls_lb_config_parser_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/round_robin_test.cc (99%) rename test/core/{client_channel/lb_policy => load_balancing}/static_stride_scheduler_benchmark.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/static_stride_scheduler_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/weighted_round_robin_config_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/weighted_round_robin_test.cc (99%) rename test/core/{client_channel/lb_policy => load_balancing}/xds_override_host_lb_config_parser_test.cc (100%) rename test/core/{client_channel/lb_policy => load_balancing}/xds_override_host_test.cc (99%) rename test/core/{client_channel/resolvers => resolver}/binder_resolver_test.cc (100%) rename test/core/{client_channel/resolvers => resolver}/dns_resolver_cooldown_test.cc (100%) rename test/core/{client_channel/resolvers => resolver}/dns_resolver_test.cc (100%) rename test/core/{client_channel/resolvers => resolver}/fake_resolver_test.cc (100%) rename test/core/{client_channel/resolvers => resolver}/google_c2p_resolver_test.cc (100%) rename test/core/{client_channel/resolvers => resolver}/sockaddr_resolver_test.cc (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d84462bd725..b2a03910b71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1448,7 +1448,7 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx tcp_server_posix_test) endif() add_dependencies(buildtests_cxx tcp_socket_utils_test) - add_dependencies(buildtests_cxx test_core_channel_channelz_test) + add_dependencies(buildtests_cxx test_core_channelz_channelz_test) add_dependencies(buildtests_cxx test_core_end2end_channelz_test) add_dependencies(buildtests_cxx test_core_event_engine_posix_timer_heap_test) add_dependencies(buildtests_cxx test_core_event_engine_posix_timer_list_test) @@ -5897,7 +5897,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) add_executable(static_stride_scheduler_benchmark src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc - test/core/client_channel/lb_policy/static_stride_scheduler_benchmark.cc + test/core/load_balancing/static_stride_scheduler_benchmark.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -8051,7 +8051,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(binder_resolver_test - test/core/client_channel/resolvers/binder_resolver_test.cc + test/core/resolver/binder_resolver_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -9928,7 +9928,7 @@ add_executable(channel_trace_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h - test/core/channel/channel_trace_test.cc + test/core/channelz/channel_trace_test.cc test/cpp/util/channel_trace_proto_helper.cc ) if(WIN32 AND MSVC) @@ -9973,7 +9973,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(channelz_registry_test - test/core/channel/channelz_registry_test.cc + test/core/channelz/channelz_registry_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -12206,7 +12206,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(dns_resolver_cooldown_test - test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc + test/core/resolver/dns_resolver_cooldown_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -12248,7 +12248,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(dns_resolver_test - test/core/client_channel/resolvers/dns_resolver_test.cc + test/core/resolver/dns_resolver_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -13667,7 +13667,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(fake_resolver_test - test/core/client_channel/resolvers/fake_resolver_test.cc + test/core/resolver/fake_resolver_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -14837,7 +14837,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(google_c2p_resolver_test - test/core/client_channel/resolvers/google_c2p_resolver_test.cc + test/core/resolver/google_c2p_resolver_test.cc test/core/util/fake_udp_and_tcp_server.cc ) if(WIN32 AND MSVC) @@ -17183,7 +17183,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(http_proxy_mapper_test - test/core/client_channel/http_proxy_mapper_test.cc + test/core/handshake/http_proxy_mapper_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -20808,7 +20808,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(outlier_detection_lb_config_parser_test - test/core/client_channel/lb_policy/outlier_detection_lb_config_parser_test.cc + test/core/load_balancing/outlier_detection_lb_config_parser_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -20854,9 +20854,9 @@ add_executable(outlier_detection_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/outlier_detection_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/outlier_detection_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -21341,9 +21341,9 @@ add_executable(pick_first_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/pick_first_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/pick_first_test.cc test/core/util/fake_stats_plugin.cc ) if(WIN32 AND MSVC) @@ -26106,9 +26106,9 @@ add_executable(ring_hash_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/ring_hash_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/ring_hash_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -26225,7 +26225,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(rls_lb_config_parser_test - test/core/client_channel/lb_policy/rls_lb_config_parser_test.cc + test/core/load_balancing/rls_lb_config_parser_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -26271,9 +26271,9 @@ add_executable(round_robin_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/round_robin_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/round_robin_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -28180,7 +28180,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(sockaddr_resolver_test - test/core/client_channel/resolvers/sockaddr_resolver_test.cc + test/core/resolver/sockaddr_resolver_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -28570,7 +28570,7 @@ if(gRPC_BUILD_TESTS) add_executable(static_stride_scheduler_test src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc - test/core/client_channel/lb_policy/static_stride_scheduler_test.cc + test/core/load_balancing/static_stride_scheduler_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -29558,18 +29558,18 @@ target_link_libraries(tcp_socket_utils_test endif() if(gRPC_BUILD_TESTS) -add_executable(test_core_channel_channelz_test +add_executable(test_core_channelz_channelz_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h - test/core/channel/channelz_test.cc + test/core/channelz/channelz_test.cc test/core/event_engine/event_engine_test_utils.cc test/cpp/util/channel_trace_proto_helper.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) - target_compile_definitions(test_core_channel_channelz_test + target_compile_definitions(test_core_channelz_channelz_test PRIVATE "GPR_DLL_IMPORTS" "GRPC_DLL_IMPORTS" @@ -29577,8 +29577,8 @@ if(WIN32 AND MSVC) ) endif() endif() -target_compile_features(test_core_channel_channelz_test PUBLIC cxx_std_14) -target_include_directories(test_core_channel_channelz_test +target_compile_features(test_core_channelz_channelz_test PUBLIC cxx_std_14) +target_include_directories(test_core_channelz_channelz_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -29597,7 +29597,7 @@ target_include_directories(test_core_channel_channelz_test ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(test_core_channel_channelz_test +target_link_libraries(test_core_channelz_channelz_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest absl::check @@ -32143,7 +32143,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(weighted_round_robin_config_test - test/core/client_channel/lb_policy/weighted_round_robin_config_test.cc + test/core/load_balancing/weighted_round_robin_config_test.cc test/core/util/fake_stats_plugin.cc ) if(WIN32 AND MSVC) @@ -32190,9 +32190,9 @@ add_executable(weighted_round_robin_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/weighted_round_robin_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/weighted_round_robin_test.cc test/core/util/fake_stats_plugin.cc ) if(WIN32 AND MSVC) @@ -35551,7 +35551,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(xds_override_host_lb_config_parser_test - test/core/client_channel/lb_policy/xds_override_host_lb_config_parser_test.cc + test/core/load_balancing/xds_override_host_lb_config_parser_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -35597,9 +35597,9 @@ add_executable(xds_override_host_test ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.pb.h ${_gRPC_PROTO_GENS_DIR}/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.grpc.pb.h - test/core/client_channel/lb_policy/xds_override_host_test.cc test/core/event_engine/event_engine_test_utils.cc test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + test/core/load_balancing/xds_override_host_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 731c17d651a..584b21c2131 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -5170,7 +5170,7 @@ targets: - src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h src: - src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc - - test/core/client_channel/lb_policy/static_stride_scheduler_benchmark.cc + - test/core/load_balancing/static_stride_scheduler_benchmark.cc deps: - absl/algorithm:container - absl/types:span @@ -6108,7 +6108,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/resolvers/binder_resolver_test.cc + - test/core/resolver/binder_resolver_test.cc deps: - gtest - grpc_test_util @@ -7576,7 +7576,7 @@ targets: - test/cpp/util/channel_trace_proto_helper.h src: - src/proto/grpc/channelz/channelz.proto - - test/core/channel/channel_trace_test.cc + - test/core/channelz/channel_trace_test.cc - test/cpp/util/channel_trace_proto_helper.cc deps: - gtest @@ -7588,7 +7588,7 @@ targets: language: c++ headers: [] src: - - test/core/channel/channelz_registry_test.cc + - test/core/channelz/channelz_registry_test.cc deps: - gtest - grpc++ @@ -8662,7 +8662,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc + - test/core/resolver/dns_resolver_cooldown_test.cc deps: - gtest - grpc_test_util @@ -8672,7 +8672,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/resolvers/dns_resolver_test.cc + - test/core/resolver/dns_resolver_test.cc deps: - gtest - grpc_test_util @@ -9460,7 +9460,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/resolvers/fake_resolver_test.cc + - test/core/resolver/fake_resolver_test.cc deps: - gtest - grpc_test_util @@ -10267,7 +10267,7 @@ targets: headers: - test/core/util/fake_udp_and_tcp_server.h src: - - test/core/client_channel/resolvers/google_c2p_resolver_test.cc + - test/core/resolver/google_c2p_resolver_test.cc - test/core/util/fake_udp_and_tcp_server.cc deps: - gtest @@ -11405,7 +11405,7 @@ targets: headers: - test/core/util/scoped_env_var.h src: - - test/core/client_channel/http_proxy_mapper_test.cc + - test/core/handshake/http_proxy_mapper_test.cc deps: - gtest - grpc_test_util @@ -13384,7 +13384,7 @@ targets: headers: - test/core/util/scoped_env_var.h src: - - test/core/client_channel/lb_policy/outlier_detection_lb_config_parser_test.cc + - test/core/load_balancing/outlier_detection_lb_config_parser_test.cc deps: - gtest - grpc_test_util @@ -13394,14 +13394,14 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/outlier_detection_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/outlier_detection_test.cc deps: - gtest - absl/log:check @@ -13671,16 +13671,16 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h - test/core/util/fake_stats_plugin.h - test/core/util/scoped_env_var.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/pick_first_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/pick_first_test.cc - test/core/util/fake_stats_plugin.cc deps: - gtest @@ -17182,14 +17182,14 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/ring_hash_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/ring_hash_test.cc deps: - gtest - absl/log:check @@ -17230,7 +17230,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/lb_policy/rls_lb_config_parser_test.cc + - test/core/load_balancing/rls_lb_config_parser_test.cc deps: - gtest - grpc_test_util @@ -17240,14 +17240,14 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/round_robin_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/round_robin_test.cc deps: - gtest - absl/log:check @@ -18222,7 +18222,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/resolvers/sockaddr_resolver_test.cc + - test/core/resolver/sockaddr_resolver_test.cc deps: - gtest - grpc_test_util @@ -18361,7 +18361,7 @@ targets: - src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h src: - src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc - - test/core/client_channel/lb_policy/static_stride_scheduler_test.cc + - test/core/load_balancing/static_stride_scheduler_test.cc deps: - gtest - absl/types:span @@ -18799,7 +18799,7 @@ targets: - absl/log:check - grpc uses_polling: false -- name: test_core_channel_channelz_test +- name: test_core_channelz_channelz_test gtest: true build: test language: c++ @@ -18808,7 +18808,7 @@ targets: - test/cpp/util/channel_trace_proto_helper.h src: - src/proto/grpc/channelz/channelz.proto - - test/core/channel/channelz_test.cc + - test/core/channelz/channelz_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/cpp/util/channel_trace_proto_helper.cc deps: @@ -19983,7 +19983,7 @@ targets: headers: - test/core/util/fake_stats_plugin.h src: - - test/core/client_channel/lb_policy/weighted_round_robin_config_test.cc + - test/core/load_balancing/weighted_round_robin_config_test.cc - test/core/util/fake_stats_plugin.cc deps: - gtest @@ -19994,15 +19994,15 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h - test/core/util/fake_stats_plugin.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/weighted_round_robin_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/weighted_round_robin_test.cc - test/core/util/fake_stats_plugin.cc deps: - gtest @@ -21392,7 +21392,7 @@ targets: language: c++ headers: [] src: - - test/core/client_channel/lb_policy/xds_override_host_lb_config_parser_test.cc + - test/core/load_balancing/xds_override_host_lb_config_parser_test.cc deps: - gtest - grpc_test_util @@ -21402,14 +21402,14 @@ targets: build: test language: c++ headers: - - test/core/client_channel/lb_policy/lb_policy_test_lib.h - test/core/event_engine/event_engine_test_utils.h - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h + - test/core/load_balancing/lb_policy_test_lib.h src: - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto - - test/core/client_channel/lb_policy/xds_override_host_test.cc - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc + - test/core/load_balancing/xds_override_host_test.cc deps: - gtest - absl/log:check diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index dc36704723c..718b0300a0e 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -95,58 +95,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "channel_trace_test", - srcs = ["channel_trace_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - "//src/core:channel_args", - "//test/core/util:grpc_test_util", - "//test/cpp/util:channel_trace_proto_helper", - ], -) - -grpc_cc_test( - name = "channelz_test", - srcs = ["channelz_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - "//src/core:channel_args", - "//test/core/event_engine:event_engine_test_utils", - "//test/core/util:grpc_test_util", - "//test/cpp/util:channel_trace_proto_helper", - ], -) - -grpc_cc_test( - name = "channelz_registry_test", - srcs = ["channelz_registry_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - uses_event_engine = False, - uses_polling = False, - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "status_util_test", srcs = ["status_util_test.cc"], diff --git a/test/core/channelz/BUILD b/test/core/channelz/BUILD new file mode 100644 index 00000000000..82c3bde0d30 --- /dev/null +++ b/test/core/channelz/BUILD @@ -0,0 +1,71 @@ +# 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. + +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") + +grpc_package(name = "test/core/channelz") + +licenses(["notice"]) + +grpc_cc_test( + name = "channel_trace_test", + srcs = ["channel_trace_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/core:channel_args", + "//test/core/util:grpc_test_util", + "//test/cpp/util:channel_trace_proto_helper", + ], +) + +grpc_cc_test( + name = "channelz_test", + srcs = ["channelz_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/core:channel_args", + "//test/core/event_engine:event_engine_test_utils", + "//test/core/util:grpc_test_util", + "//test/cpp/util:channel_trace_proto_helper", + ], +) + +grpc_cc_test( + name = "channelz_registry_test", + srcs = ["channelz_registry_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + uses_event_engine = False, + uses_polling = False, + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channelz/channel_trace_test.cc similarity index 100% rename from test/core/channel/channel_trace_test.cc rename to test/core/channelz/channel_trace_test.cc diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channelz/channelz_registry_test.cc similarity index 100% rename from test/core/channel/channelz_registry_test.cc rename to test/core/channelz/channelz_registry_test.cc diff --git a/test/core/channel/channelz_test.cc b/test/core/channelz/channelz_test.cc similarity index 100% rename from test/core/channel/channelz_test.cc rename to test/core/channelz/channelz_test.cc diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index db32f642365..1de1356f7d1 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -33,21 +33,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "http_proxy_mapper_test", - srcs = ["http_proxy_mapper_test.cc"], - external_deps = ["gtest"], - language = "C++", - uses_polling = False, - deps = [ - "//:gpr", - "//:grpc", - "//src/core:channel_args", - "//test/core/util:grpc_test_util", - "//test/core/util:scoped_env_var", - ], -) - grpc_cc_test( name = "retry_throttle_test", srcs = ["retry_throttle_test.cc"], diff --git a/test/core/client_channel/resolvers/BUILD b/test/core/client_channel/resolvers/BUILD deleted file mode 100644 index c6ff60d95d2..00000000000 --- a/test/core/client_channel/resolvers/BUILD +++ /dev/null @@ -1,104 +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. - -load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") - -grpc_package(name = "test/core/client_channel/resolvers") - -licenses(["notice"]) - -grpc_cc_test( - name = "binder_resolver_test", - srcs = ["binder_resolver_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//src/core:grpc_resolver_binder", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "dns_resolver_test", - srcs = ["dns_resolver_test.cc"], - external_deps = ["gtest"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "dns_resolver_cooldown_test", - srcs = ["dns_resolver_cooldown_test.cc"], - external_deps = ["gtest"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//src/core:channel_args", - "//src/core:closure", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "sockaddr_resolver_test", - srcs = ["sockaddr_resolver_test.cc"], - external_deps = ["gtest"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "fake_resolver_test", - srcs = ["fake_resolver_test.cc"], - external_deps = ["gtest"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//:grpc_resolver_fake", - "//src/core:channel_args", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "google_c2p_resolver_test", - srcs = ["google_c2p_resolver_test.cc"], - external_deps = [ - "absl/strings:str_format", - "gtest", - ], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - "//test/core/util:fake_udp_and_tcp_server", - "//test/core/util:grpc_test_util", - "//test/cpp/util:test_util", - ], -) diff --git a/test/core/handshake/BUILD b/test/core/handshake/BUILD index 749afb50ab3..ded4fbd4a48 100644 --- a/test/core/handshake/BUILD +++ b/test/core/handshake/BUILD @@ -105,3 +105,18 @@ grpc_cc_test( # "//test/core/util:grpc_test_util", # ], #) + +grpc_cc_test( + name = "http_proxy_mapper_test", + srcs = ["http_proxy_mapper_test.cc"], + external_deps = ["gtest"], + language = "C++", + uses_polling = False, + deps = [ + "//:gpr", + "//:grpc", + "//src/core:channel_args", + "//test/core/util:grpc_test_util", + "//test/core/util:scoped_env_var", + ], +) diff --git a/test/core/client_channel/http_proxy_mapper_test.cc b/test/core/handshake/http_proxy_mapper_test.cc similarity index 100% rename from test/core/client_channel/http_proxy_mapper_test.cc rename to test/core/handshake/http_proxy_mapper_test.cc diff --git a/test/core/client_channel/lb_policy/BUILD b/test/core/load_balancing/BUILD similarity index 99% rename from test/core/client_channel/lb_policy/BUILD rename to test/core/load_balancing/BUILD index 292fe932664..304e91c1325 100644 --- a/test/core/client_channel/lb_policy/BUILD +++ b/test/core/load_balancing/BUILD @@ -19,7 +19,7 @@ load( "grpc_package", ) -grpc_package(name = "test/core/client_channel/lb_policy") +grpc_package(name = "test/core/load_balancing") licenses(["notice"]) diff --git a/test/core/client_channel/lb_policy/lb_policy_test_lib.h b/test/core/load_balancing/lb_policy_test_lib.h similarity index 99% rename from test/core/client_channel/lb_policy/lb_policy_test_lib.h rename to test/core/load_balancing/lb_policy_test_lib.h index 3f42dbba0bf..9f2e0b113cd 100644 --- a/test/core/client_channel/lb_policy/lb_policy_test_lib.h +++ b/test/core/load_balancing/lb_policy_test_lib.h @@ -14,8 +14,8 @@ // limitations under the License. // -#ifndef GRPC_TEST_CORE_CLIENT_CHANNEL_LB_POLICY_LB_POLICY_TEST_LIB_H -#define GRPC_TEST_CORE_CLIENT_CHANNEL_LB_POLICY_LB_POLICY_TEST_LIB_H +#ifndef GRPC_TEST_CORE_LOAD_BALANCING_LB_POLICY_TEST_LIB_H +#define GRPC_TEST_CORE_LOAD_BALANCING_LB_POLICY_TEST_LIB_H #include #include @@ -1510,4 +1510,4 @@ class LoadBalancingPolicyTest : public ::testing::Test { } // namespace testing } // namespace grpc_core -#endif // GRPC_TEST_CORE_CLIENT_CHANNEL_LB_POLICY_LB_POLICY_TEST_LIB_H +#endif // GRPC_TEST_CORE_LOAD_BALANCING_LB_POLICY_TEST_LIB_H diff --git a/test/core/client_channel/lb_policy/outlier_detection_lb_config_parser_test.cc b/test/core/load_balancing/outlier_detection_lb_config_parser_test.cc similarity index 100% rename from test/core/client_channel/lb_policy/outlier_detection_lb_config_parser_test.cc rename to test/core/load_balancing/outlier_detection_lb_config_parser_test.cc diff --git a/test/core/client_channel/lb_policy/outlier_detection_test.cc b/test/core/load_balancing/outlier_detection_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/outlier_detection_test.cc rename to test/core/load_balancing/outlier_detection_test.cc index 1dbb5476037..d78af4b3d28 100644 --- a/test/core/client_channel/lb_policy/outlier_detection_test.cc +++ b/test/core/load_balancing/outlier_detection_test.cc @@ -42,7 +42,7 @@ #include "src/core/load_balancing/backend_metric_data.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/resolver/endpoint_addresses.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/test_config.h" namespace grpc_core { diff --git a/test/core/client_channel/lb_policy/pick_first_test.cc b/test/core/load_balancing/pick_first_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/pick_first_test.cc rename to test/core/load_balancing/pick_first_test.cc index cb717cb483e..f6961047d4e 100644 --- a/test/core/client_channel/lb_policy/pick_first_test.cc +++ b/test/core/load_balancing/pick_first_test.cc @@ -48,7 +48,7 @@ #include "src/core/lib/json/json.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/resolver/endpoint_addresses.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/fake_stats_plugin.h" #include "test/core/util/test_config.h" diff --git a/test/core/client_channel/lb_policy/ring_hash_test.cc b/test/core/load_balancing/ring_hash_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/ring_hash_test.cc rename to test/core/load_balancing/ring_hash_test.cc index a8739678e07..4f7493f70b7 100644 --- a/test/core/client_channel/lb_policy/ring_hash_test.cc +++ b/test/core/load_balancing/ring_hash_test.cc @@ -39,7 +39,7 @@ #include "src/core/lib/json/json.h" #include "src/core/load_balancing/lb_policy.h" #include "src/core/resolver/endpoint_addresses.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/test_config.h" namespace grpc_core { diff --git a/test/core/client_channel/lb_policy/rls_lb_config_parser_test.cc b/test/core/load_balancing/rls_lb_config_parser_test.cc similarity index 100% rename from test/core/client_channel/lb_policy/rls_lb_config_parser_test.cc rename to test/core/load_balancing/rls_lb_config_parser_test.cc diff --git a/test/core/client_channel/lb_policy/round_robin_test.cc b/test/core/load_balancing/round_robin_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/round_robin_test.cc rename to test/core/load_balancing/round_robin_test.cc index 9af35ed951d..219049dff86 100644 --- a/test/core/client_channel/lb_policy/round_robin_test.cc +++ b/test/core/load_balancing/round_robin_test.cc @@ -27,7 +27,7 @@ #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/resolver/endpoint_addresses.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/test_config.h" namespace grpc_core { diff --git a/test/core/client_channel/lb_policy/static_stride_scheduler_benchmark.cc b/test/core/load_balancing/static_stride_scheduler_benchmark.cc similarity index 100% rename from test/core/client_channel/lb_policy/static_stride_scheduler_benchmark.cc rename to test/core/load_balancing/static_stride_scheduler_benchmark.cc diff --git a/test/core/client_channel/lb_policy/static_stride_scheduler_test.cc b/test/core/load_balancing/static_stride_scheduler_test.cc similarity index 100% rename from test/core/client_channel/lb_policy/static_stride_scheduler_test.cc rename to test/core/load_balancing/static_stride_scheduler_test.cc diff --git a/test/core/client_channel/lb_policy/weighted_round_robin_config_test.cc b/test/core/load_balancing/weighted_round_robin_config_test.cc similarity index 100% rename from test/core/client_channel/lb_policy/weighted_round_robin_config_test.cc rename to test/core/load_balancing/weighted_round_robin_config_test.cc diff --git a/test/core/client_channel/lb_policy/weighted_round_robin_test.cc b/test/core/load_balancing/weighted_round_robin_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/weighted_round_robin_test.cc rename to test/core/load_balancing/weighted_round_robin_test.cc index 9e8cd2c66d1..38293b9d93d 100644 --- a/test/core/client_channel/lb_policy/weighted_round_robin_test.cc +++ b/test/core/load_balancing/weighted_round_robin_test.cc @@ -50,7 +50,7 @@ #include "src/core/load_balancing/lb_policy.h" #include "src/core/load_balancing/weighted_target/weighted_target.h" #include "src/core/resolver/endpoint_addresses.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/fake_stats_plugin.h" #include "test/core/util/test_config.h" diff --git a/test/core/client_channel/lb_policy/xds_override_host_lb_config_parser_test.cc b/test/core/load_balancing/xds_override_host_lb_config_parser_test.cc similarity index 100% rename from test/core/client_channel/lb_policy/xds_override_host_lb_config_parser_test.cc rename to test/core/load_balancing/xds_override_host_lb_config_parser_test.cc diff --git a/test/core/client_channel/lb_policy/xds_override_host_test.cc b/test/core/load_balancing/xds_override_host_test.cc similarity index 99% rename from test/core/client_channel/lb_policy/xds_override_host_test.cc rename to test/core/load_balancing/xds_override_host_test.cc index e6c74b7b2f1..1a177fc907b 100644 --- a/test/core/client_channel/lb_policy/xds_override_host_test.cc +++ b/test/core/load_balancing/xds_override_host_test.cc @@ -46,7 +46,7 @@ #include "src/core/load_balancing/lb_policy.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/xds/xds_dependency_manager.h" -#include "test/core/client_channel/lb_policy/lb_policy_test_lib.h" +#include "test/core/load_balancing/lb_policy_test_lib.h" #include "test/core/util/test_config.h" namespace grpc_core { diff --git a/test/core/resolver/BUILD b/test/core/resolver/BUILD index 04aaf120a8d..020644df369 100644 --- a/test/core/resolver/BUILD +++ b/test/core/resolver/BUILD @@ -1,4 +1,4 @@ -# Copyright 2023 gRPC authors. +# 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. @@ -32,3 +32,88 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "binder_resolver_test", + srcs = ["binder_resolver_test.cc"], + external_deps = [ + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//src/core:grpc_resolver_binder", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "dns_resolver_test", + srcs = ["dns_resolver_test.cc"], + external_deps = ["gtest"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "dns_resolver_cooldown_test", + srcs = ["dns_resolver_cooldown_test.cc"], + external_deps = ["gtest"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//src/core:channel_args", + "//src/core:closure", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "sockaddr_resolver_test", + srcs = ["sockaddr_resolver_test.cc"], + external_deps = ["gtest"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "fake_resolver_test", + srcs = ["fake_resolver_test.cc"], + external_deps = ["gtest"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//:grpc_resolver_fake", + "//src/core:channel_args", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "google_c2p_resolver_test", + srcs = ["google_c2p_resolver_test.cc"], + external_deps = [ + "absl/strings:str_format", + "gtest", + ], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//test/core/util:fake_udp_and_tcp_server", + "//test/core/util:grpc_test_util", + "//test/cpp/util:test_util", + ], +) diff --git a/test/core/client_channel/resolvers/binder_resolver_test.cc b/test/core/resolver/binder_resolver_test.cc similarity index 100% rename from test/core/client_channel/resolvers/binder_resolver_test.cc rename to test/core/resolver/binder_resolver_test.cc diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/resolver/dns_resolver_cooldown_test.cc similarity index 100% rename from test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc rename to test/core/resolver/dns_resolver_cooldown_test.cc diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/resolver/dns_resolver_test.cc similarity index 100% rename from test/core/client_channel/resolvers/dns_resolver_test.cc rename to test/core/resolver/dns_resolver_test.cc diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/resolver/fake_resolver_test.cc similarity index 100% rename from test/core/client_channel/resolvers/fake_resolver_test.cc rename to test/core/resolver/fake_resolver_test.cc diff --git a/test/core/client_channel/resolvers/google_c2p_resolver_test.cc b/test/core/resolver/google_c2p_resolver_test.cc similarity index 100% rename from test/core/client_channel/resolvers/google_c2p_resolver_test.cc rename to test/core/resolver/google_c2p_resolver_test.cc diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/resolver/sockaddr_resolver_test.cc similarity index 100% rename from test/core/client_channel/resolvers/sockaddr_resolver_test.cc rename to test/core/resolver/sockaddr_resolver_test.cc diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 15ad36dca3e..1503f00d037 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -10238,7 +10238,7 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "test_core_channel_channelz_test", + "name": "test_core_channelz_channelz_test", "platforms": [ "linux", "mac", From 5927103e143c79451219ee807746226572f02a74 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 23 Apr 2024 13:01:32 -0700 Subject: [PATCH 41/45] [clang-format] Remove requirement that port_platform.h is at the top (#36301) Closes #36301 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36301 from ctiller:port_platform-src-core-ext-transport-binder-clang-format 60eae1b1e067ec34627a10d541044a1155c2f0b5 PiperOrigin-RevId: 627479416 --- src/core/ext/transport/binder/.clang-format | 3 --- src/core/ext/transport/binder/client/binder_connector.h | 3 +-- src/core/ext/transport/binder/client/channel_create.cc | 3 +-- src/core/ext/transport/binder/client/channel_create_impl.cc | 4 ++-- src/core/ext/transport/binder/client/channel_create_impl.h | 1 - .../ext/transport/binder/client/connection_id_generator.cc | 4 ++-- .../ext/transport/binder/client/connection_id_generator.h | 4 ++-- src/core/ext/transport/binder/client/endpoint_binder_pool.cc | 4 ++-- src/core/ext/transport/binder/client/endpoint_binder_pool.h | 4 ++-- src/core/ext/transport/binder/client/jni_utils.cc | 4 ++-- src/core/ext/transport/binder/client/jni_utils.h | 4 ++-- .../ext/transport/binder/client/security_policy_setting.h | 3 +-- src/core/ext/transport/binder/server/binder_server.cc | 4 ++-- src/core/ext/transport/binder/server/binder_server.h | 3 +-- src/core/ext/transport/binder/transport/binder_transport.cc | 4 ++-- src/core/ext/transport/binder/transport/binder_transport.h | 3 +-- src/core/ext/transport/binder/utils/ndk_binder.cc | 4 ++-- .../ext/transport/binder/utils/transport_stream_receiver.h | 4 ++-- .../transport/binder/utils/transport_stream_receiver_impl.cc | 4 ++-- .../transport/binder/utils/transport_stream_receiver_impl.h | 4 ++-- src/core/ext/transport/binder/wire_format/binder.h | 4 ++-- src/core/ext/transport/binder/wire_format/binder_constants.h | 4 ++-- src/core/ext/transport/binder/wire_format/transaction.h | 3 +-- src/core/ext/transport/binder/wire_format/wire_reader.h | 4 ++-- src/core/ext/transport/binder/wire_format/wire_reader_impl.cc | 4 ++-- src/core/ext/transport/binder/wire_format/wire_reader_impl.h | 3 +-- src/core/ext/transport/binder/wire_format/wire_writer.cc | 4 ++-- src/core/ext/transport/binder/wire_format/wire_writer.h | 4 ++-- 28 files changed, 45 insertions(+), 56 deletions(-) diff --git a/src/core/ext/transport/binder/.clang-format b/src/core/ext/transport/binder/.clang-format index 64387e9e515..5f150ef6edb 100644 --- a/src/core/ext/transport/binder/.clang-format +++ b/src/core/ext/transport/binder/.clang-format @@ -5,9 +5,6 @@ DerivePointerAlignment: false PointerAlignment: Left IncludeBlocks: Regroup IncludeCategories: - # port_platform.h is before almost everything - - Regex: '^' - Priority: -100 # ruby.h is even more first if it's included - Regex: '^' Priority: -200 diff --git a/src/core/ext/transport/binder/client/binder_connector.h b/src/core/ext/transport/binder/client/binder_connector.h index 4a350251677..e054e3555c5 100644 --- a/src/core/ext/transport/binder/client/binder_connector.h +++ b/src/core/ext/transport/binder/client/binder_connector.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_BINDER_CONNECTOR_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_BINDER_CONNECTOR_H -#include - #include #include @@ -24,6 +22,7 @@ #include "absl/strings/strip.h" #include +#include #include #include diff --git a/src/core/ext/transport/binder/client/channel_create.cc b/src/core/ext/transport/binder/client/channel_create.cc index efae0104b28..484695537fb 100644 --- a/src/core/ext/transport/binder/client/channel_create.cc +++ b/src/core/ext/transport/binder/client/channel_create.cc @@ -34,13 +34,12 @@ #ifdef GPR_SUPPORT_BINDER_TRANSPORT -#include - #include "absl/memory/memory.h" #include "absl/strings/substitute.h" #include "absl/time/clock.h" #include "absl/time/time.h" +#include #include #include "src/core/client_channel/client_channel_filter.h" diff --git a/src/core/ext/transport/binder/client/channel_create_impl.cc b/src/core/ext/transport/binder/client/channel_create_impl.cc index d9d5208f9a9..3d80e329c7b 100644 --- a/src/core/ext/transport/binder/client/channel_create_impl.cc +++ b/src/core/ext/transport/binder/client/channel_create_impl.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/client/channel_create_impl.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/client/channel_create_impl.h b/src/core/ext/transport/binder/client/channel_create_impl.h index 7f00a5e1e09..0cc87a5a62e 100644 --- a/src/core/ext/transport/binder/client/channel_create_impl.h +++ b/src/core/ext/transport/binder/client/channel_create_impl.h @@ -16,7 +16,6 @@ #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_CHANNEL_CREATE_IMPL_H #include - #include #include "src/core/ext/transport/binder/wire_format/binder.h" diff --git a/src/core/ext/transport/binder/client/connection_id_generator.cc b/src/core/ext/transport/binder/client/connection_id_generator.cc index f4b4954d8a4..8f434338be0 100644 --- a/src/core/ext/transport/binder/client/connection_id_generator.cc +++ b/src/core/ext/transport/binder/client/connection_id_generator.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/client/connection_id_generator.h" +#include + #ifndef GRPC_NO_BINDER #include "absl/strings/str_cat.h" diff --git a/src/core/ext/transport/binder/client/connection_id_generator.h b/src/core/ext/transport/binder/client/connection_id_generator.h index de8c780a0a3..d756ec1ced3 100644 --- a/src/core/ext/transport/binder/client/connection_id_generator.h +++ b/src/core/ext/transport/binder/client/connection_id_generator.h @@ -15,12 +15,12 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_CONNECTION_ID_GENERATOR_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_CONNECTION_ID_GENERATOR_H -#include - #include #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gprpp/sync.h" namespace grpc_binder { diff --git a/src/core/ext/transport/binder/client/endpoint_binder_pool.cc b/src/core/ext/transport/binder/client/endpoint_binder_pool.cc index 6ed85621339..4241ccd77fd 100644 --- a/src/core/ext/transport/binder/client/endpoint_binder_pool.cc +++ b/src/core/ext/transport/binder/client/endpoint_binder_pool.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/client/endpoint_binder_pool.h" +#include + #ifndef GRPC_NO_BINDER #include "src/core/ext/transport/binder/client/jni_utils.h" diff --git a/src/core/ext/transport/binder/client/endpoint_binder_pool.h b/src/core/ext/transport/binder/client/endpoint_binder_pool.h index 8b1f27bd421..f3452009b67 100644 --- a/src/core/ext/transport/binder/client/endpoint_binder_pool.h +++ b/src/core/ext/transport/binder/client/endpoint_binder_pool.h @@ -15,13 +15,13 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_ENDPOINT_BINDER_POOL_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_ENDPOINT_BINDER_POOL_H -#include - #include #include #include "absl/container/flat_hash_map.h" +#include + #include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/ext/transport/binder/client/jni_utils.cc b/src/core/ext/transport/binder/client/jni_utils.cc index e0e3f59582b..698fb3242e7 100644 --- a/src/core/ext/transport/binder/client/jni_utils.cc +++ b/src/core/ext/transport/binder/client/jni_utils.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/client/jni_utils.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/client/jni_utils.h b/src/core/ext/transport/binder/client/jni_utils.h index 40c76693d7d..1c809b127c8 100644 --- a/src/core/ext/transport/binder/client/jni_utils.h +++ b/src/core/ext/transport/binder/client/jni_utils.h @@ -17,8 +17,6 @@ #if defined(ANDROID) || defined(__ANDROID__) -#include - #include #include @@ -26,6 +24,8 @@ #include "absl/strings/string_view.h" +#include + namespace grpc_binder { // Finds NativeConnectionHelper Java class and caches it. This is useful because diff --git a/src/core/ext/transport/binder/client/security_policy_setting.h b/src/core/ext/transport/binder/client/security_policy_setting.h index d7621ff70f1..212603744b9 100644 --- a/src/core/ext/transport/binder/client/security_policy_setting.h +++ b/src/core/ext/transport/binder/client/security_policy_setting.h @@ -15,11 +15,10 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_SECURITY_POLICY_SETTING_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_CLIENT_SECURITY_POLICY_SETTING_H -#include - #include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" +#include #include #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/ext/transport/binder/server/binder_server.cc b/src/core/ext/transport/binder/server/binder_server.cc index 994d8f82cb8..3afbd2ef615 100644 --- a/src/core/ext/transport/binder/server/binder_server.cc +++ b/src/core/ext/transport/binder/server/binder_server.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/server/binder_server.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/server/binder_server.h b/src/core/ext/transport/binder/server/binder_server.h index c5330d474ed..0a1a36e8ba3 100644 --- a/src/core/ext/transport/binder/server/binder_server.h +++ b/src/core/ext/transport/binder/server/binder_server.h @@ -15,13 +15,12 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_SERVER_BINDER_SERVER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_SERVER_BINDER_SERVER_H -#include - #include #include "absl/container/flat_hash_map.h" #include "absl/status/status.h" +#include #include #include "src/core/ext/transport/binder/transport/binder_transport.h" diff --git a/src/core/ext/transport/binder/transport/binder_transport.cc b/src/core/ext/transport/binder/transport/binder_transport.cc index aad7b43f213..8491277517a 100644 --- a/src/core/ext/transport/binder/transport/binder_transport.cc +++ b/src/core/ext/transport/binder/transport/binder_transport.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/transport/binder_transport.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/transport/binder_transport.h b/src/core/ext/transport/binder/transport/binder_transport.h index fe219ba98e9..d828ff1c3f9 100644 --- a/src/core/ext/transport/binder/transport/binder_transport.h +++ b/src/core/ext/transport/binder/transport/binder_transport.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_TRANSPORT_BINDER_TRANSPORT_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_TRANSPORT_BINDER_TRANSPORT_H -#include - #include #include #include @@ -26,6 +24,7 @@ #include "absl/container/flat_hash_map.h" #include +#include #include #include "src/core/ext/transport/binder/utils/transport_stream_receiver.h" diff --git a/src/core/ext/transport/binder/utils/ndk_binder.cc b/src/core/ext/transport/binder/utils/ndk_binder.cc index 20dd4908320..39e9e9771e5 100644 --- a/src/core/ext/transport/binder/utils/ndk_binder.cc +++ b/src/core/ext/transport/binder/utils/ndk_binder.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/utils/ndk_binder.h" +#include + #ifndef GRPC_NO_BINDER #ifdef GPR_SUPPORT_BINDER_TRANSPORT diff --git a/src/core/ext/transport/binder/utils/transport_stream_receiver.h b/src/core/ext/transport/binder/utils/transport_stream_receiver.h index cbd6f6ae247..fa7dd21472d 100644 --- a/src/core/ext/transport/binder/utils/transport_stream_receiver.h +++ b/src/core/ext/transport/binder/utils/transport_stream_receiver.h @@ -15,14 +15,14 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_UTILS_TRANSPORT_STREAM_RECEIVER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_UTILS_TRANSPORT_STREAM_RECEIVER_H -#include - #include #include #include #include "absl/status/statusor.h" +#include + #include "src/core/ext/transport/binder/wire_format/transaction.h" namespace grpc_binder { diff --git a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc index d569d1fb614..23c9a4f4734 100644 --- a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc +++ b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h index be2676a56f9..6fe22df4692 100644 --- a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h +++ b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_UTILS_TRANSPORT_STREAM_RECEIVER_IMPL_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_UTILS_TRANSPORT_STREAM_RECEIVER_IMPL_H -#include - #include #include #include @@ -24,6 +22,8 @@ #include #include +#include + #include "src/core/ext/transport/binder/utils/transport_stream_receiver.h" #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/ext/transport/binder/wire_format/binder.h b/src/core/ext/transport/binder/wire_format/binder.h index 2dce384e102..ce79c1332e8 100644 --- a/src/core/ext/transport/binder/wire_format/binder.h +++ b/src/core/ext/transport/binder/wire_format/binder.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_BINDER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_BINDER_H -#include - #include #include #include @@ -25,6 +23,8 @@ #include "absl/status/status.h" #include "absl/strings/string_view.h" +#include + #include "src/core/ext/transport/binder/wire_format/binder_constants.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/ext/transport/binder/wire_format/binder_constants.h b/src/core/ext/transport/binder/wire_format/binder_constants.h index 0dacaa742c0..562f248ec0d 100644 --- a/src/core/ext/transport/binder/wire_format/binder_constants.h +++ b/src/core/ext/transport/binder/wire_format/binder_constants.h @@ -15,12 +15,12 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_BINDER_CONSTANTS_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_BINDER_CONSTANTS_H -#include - #include #include "absl/base/attributes.h" +#include + using transaction_code_t = uint32_t; ABSL_CONST_INIT extern const int FIRST_CALL_TRANSACTION; diff --git a/src/core/ext/transport/binder/wire_format/transaction.h b/src/core/ext/transport/binder/wire_format/transaction.h index 93e0883c3f1..c4681d19cbc 100644 --- a/src/core/ext/transport/binder/wire_format/transaction.h +++ b/src/core/ext/transport/binder/wire_format/transaction.h @@ -15,14 +15,13 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_TRANSACTION_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_TRANSACTION_H -#include - #include #include #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/ext/transport/binder/wire_format/wire_reader.h b/src/core/ext/transport/binder/wire_format/wire_reader.h index 5fa98512cca..2a4092d29d9 100644 --- a/src/core/ext/transport/binder/wire_format/wire_reader.h +++ b/src/core/ext/transport/binder/wire_format/wire_reader.h @@ -15,11 +15,11 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_READER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_READER_H -#include - #include #include +#include + #include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/ext/transport/binder/wire_format/wire_writer.h" #include "src/core/lib/gprpp/orphanable.h" diff --git a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc index 3a9860a8ef1..607127400ae 100644 --- a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc +++ b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/wire_format/wire_reader_impl.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/wire_format/wire_reader_impl.h b/src/core/ext/transport/binder/wire_format/wire_reader_impl.h index 23f0235cede..48e80f718f6 100644 --- a/src/core/ext/transport/binder/wire_format/wire_reader_impl.h +++ b/src/core/ext/transport/binder/wire_format/wire_reader_impl.h @@ -15,8 +15,6 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_READER_IMPL_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_READER_IMPL_H -#include - #include #include #include @@ -24,6 +22,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/functional/any_invocable.h" +#include #include #include "src/core/ext/transport/binder/utils/transport_stream_receiver.h" diff --git a/src/core/ext/transport/binder/wire_format/wire_writer.cc b/src/core/ext/transport/binder/wire_format/wire_writer.cc index f1bfd19eb9a..1daef583ef5 100644 --- a/src/core/ext/transport/binder/wire_format/wire_writer.cc +++ b/src/core/ext/transport/binder/wire_format/wire_writer.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "src/core/ext/transport/binder/wire_format/wire_writer.h" +#include + #ifndef GRPC_NO_BINDER #include diff --git a/src/core/ext/transport/binder/wire_format/wire_writer.h b/src/core/ext/transport/binder/wire_format/wire_writer.h index eb00e9387cc..bb52c7385cc 100644 --- a/src/core/ext/transport/binder/wire_format/wire_writer.h +++ b/src/core/ext/transport/binder/wire_format/wire_writer.h @@ -15,14 +15,14 @@ #ifndef GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_WRITER_H #define GRPC_SRC_CORE_EXT_TRANSPORT_BINDER_WIRE_FORMAT_WIRE_WRITER_H -#include - #include #include #include #include "absl/container/flat_hash_map.h" +#include + #include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/ext/transport/binder/wire_format/transaction.h" #include "src/core/lib/gprpp/sync.h" From ebe061641c25cb112f29df2dbf76dc6d1579017c Mon Sep 17 00:00:00 2001 From: Anirudh Ramachandra Date: Tue, 23 Apr 2024 14:03:56 -0700 Subject: [PATCH 42/45] [handshaker] Change handshake manager to clean up read buffer even if endpoint is null (#36426) This leak only impacts handshakers that don't have any endpoint associated with them and if the shutdown occurs at the same time as the handshaker finishing successfully. Currently the memory allocated for the read buffer is only cleaned up if the endpoint is not a nullptr triggering the leak. This change unilaterally cleans up the memory for this condition. cc: @markdroth Closes #36426 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36426 from anicr7:handshaker_mem_leak 550071bce753605f708c3348165961380df2e6de PiperOrigin-RevId: 627498539 --- src/core/lib/transport/handshaker.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/lib/transport/handshaker.cc b/src/core/lib/transport/handshaker.cc index 8288002bf4d..f6f1a0db93d 100644 --- a/src/core/lib/transport/handshaker.cc +++ b/src/core/lib/transport/handshaker.cc @@ -119,11 +119,13 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) { grpc_endpoint_shutdown(args_.endpoint, error); grpc_endpoint_destroy(args_.endpoint); args_.endpoint = nullptr; - args_.args = ChannelArgs(); + } + if (args_.read_buffer != nullptr) { grpc_slice_buffer_destroy(args_.read_buffer); gpr_free(args_.read_buffer); args_.read_buffer = nullptr; } + args_.args = ChannelArgs(); } if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) { gpr_log(GPR_INFO, From a08a2f830046fe0053716f61e19a915de2b05905 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:11:00 -0700 Subject: [PATCH 43/45] [infra] Bump requests from 2.25.1 to 2.31.0 in /tools/internal_ci/helper_scripts (#36249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [requests](https://github.com/psf/requests) from 2.25.1 to 2.31.0.
Release notes

Sourced from requests's releases.

v2.31.0

2.31.0 (2023-05-22)

Security

  • Versions of Requests between v2.3.0 and v2.30.0 are vulnerable to potential forwarding of Proxy-Authorization headers to destination servers when following HTTPS redirects.

    When proxies are defined with user info (https://user:pass@proxy:8080), Requests will construct a Proxy-Authorization header that is attached to the request to authenticate with the proxy.

    In cases where Requests receives a redirect response, it previously reattached the Proxy-Authorization header incorrectly, resulting in the value being sent through the tunneled connection to the destination server. Users who rely on defining their proxy credentials in the URL are strongly encouraged to upgrade to Requests 2.31.0+ to prevent unintentional leakage and rotate their proxy credentials once the change has been fully deployed.

    Users who do not use a proxy or do not supply their proxy credentials through the user information portion of their proxy URL are not subject to this vulnerability.

    Full details can be read in our Github Security Advisory and CVE-2023-32681.

v2.30.0

2.30.0 (2023-05-03)

Dependencies

v2.29.0

2.29.0 (2023-04-26)

Improvements

  • Requests now defers chunked requests to the urllib3 implementation to improve standardization. (#6226)
  • Requests relaxes header component requirements to support bytes/str subclasses. (#6356)

... (truncated)

Changelog

Sourced from requests's changelog.

2.31.0 (2023-05-22)

Security

  • Versions of Requests between v2.3.0 and v2.30.0 are vulnerable to potential forwarding of Proxy-Authorization headers to destination servers when following HTTPS redirects.

    When proxies are defined with user info (https://user:pass@proxy:8080), Requests will construct a Proxy-Authorization header that is attached to the request to authenticate with the proxy.

    In cases where Requests receives a redirect response, it previously reattached the Proxy-Authorization header incorrectly, resulting in the value being sent through the tunneled connection to the destination server. Users who rely on defining their proxy credentials in the URL are strongly encouraged to upgrade to Requests 2.31.0+ to prevent unintentional leakage and rotate their proxy credentials once the change has been fully deployed.

    Users who do not use a proxy or do not supply their proxy credentials through the user information portion of their proxy URL are not subject to this vulnerability.

    Full details can be read in our Github Security Advisory and CVE-2023-32681.

2.30.0 (2023-05-03)

Dependencies

2.29.0 (2023-04-26)

Improvements

  • Requests now defers chunked requests to the urllib3 implementation to improve standardization. (#6226)
  • Requests relaxes header component requirements to support bytes/str subclasses. (#6356)

2.28.2 (2023-01-12)

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=requests&package-manager=pip&previous-version=2.25.1&new-version=2.31.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/grpc/grpc/network/alerts).
Closes #36249 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36249 from grpc:dependabot/pip/tools/internal_ci/helper_scripts/requests-2.31.0 9ec686f11e7a8c0936587ce7bcf9eea1391b789b PiperOrigin-RevId: 627518898 --- tools/internal_ci/helper_scripts/requirements.linux_perf.txt | 2 +- tools/internal_ci/helper_scripts/requirements.macos.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/internal_ci/helper_scripts/requirements.linux_perf.txt b/tools/internal_ci/helper_scripts/requirements.linux_perf.txt index 761d8ebfcd1..57e1a0c48c1 100644 --- a/tools/internal_ci/helper_scripts/requirements.linux_perf.txt +++ b/tools/internal_ci/helper_scripts/requirements.linux_perf.txt @@ -1,5 +1,5 @@ cryptography==3.4.6 PyJWT==2.0.1 -requests==2.25.1 +requests==2.31.0 scipy==1.5.4 tabulate==0.8.9 diff --git a/tools/internal_ci/helper_scripts/requirements.macos.txt b/tools/internal_ci/helper_scripts/requirements.macos.txt index 8f8d1d2141c..190bf328634 100644 --- a/tools/internal_ci/helper_scripts/requirements.macos.txt +++ b/tools/internal_ci/helper_scripts/requirements.macos.txt @@ -3,4 +3,4 @@ cryptography==3.4.6 PyJWT==2.0.1 pyOpenSSL==20.0.1 PyYAML==6.0 -requests==2.25.1 +requests==2.31.0 From d2cb5c355003e101ba723422d3555eb524ea034a Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Tue, 23 Apr 2024 15:32:19 -0700 Subject: [PATCH 44/45] [ObjC] log when got GRPC_QUEUE_TIMEOUT event from completion queue (#36095) This is for the tat task app sometimes crash with "Unrecognized completion type". However in obj-c wrapper, it is calling grpc_completion_queue_next with gpr_inf_future where it should never receive a timeout event. This PR add a log and reschedule another grpc_completion_queue_next for a GRPC_OP_COMPLETE or GRPC_QUEUE_SHUTDOWN event, which is similar to the [gRPC C++ implementation](https://github.com/grpc/grpc/blob/v1.62.1/src/cpp/common/completion_queue_cc.cc#L80-L85) Closes #36095 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36095 from HannahShiSFB:no-throw-on-completion-queue-timeout e6eaf2f18ae6070ddaa969571a76822f3a0b567b PiperOrigin-RevId: 627524702 --- .../GRPCClient/private/GRPCCore/GRPCCompletionQueue.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.mm b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.mm index 38dda64b72e..a49bb9c2566 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.mm +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCCompletionQueue.mm @@ -69,6 +69,9 @@ const grpc_completion_queue_attributes kCompletionQueueAttr = { case GRPC_QUEUE_SHUTDOWN: grpc_completion_queue_destroy(unmanagedQueue); return; + case GRPC_QUEUE_TIMEOUT: + NSLog(@"GRPC_QUEUE_TIMEOUT, success: %d, tag: %p", event.success, event.tag); + break; default: [NSException raise:@"Unrecognized completion type" format:@""]; } From d61144ec5130f9346e2d5fbe82511cdcdb797ef6 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Tue, 23 Apr 2024 15:42:40 -0700 Subject: [PATCH 45/45] [EventEngine] Handle null listener & engine in QueryExtension functions PiperOrigin-RevId: 627527331 --- src/core/lib/event_engine/query_extensions.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/event_engine/query_extensions.h b/src/core/lib/event_engine/query_extensions.h index 677e5b22d8b..2b39214e635 100644 --- a/src/core/lib/event_engine/query_extensions.h +++ b/src/core/lib/event_engine/query_extensions.h @@ -68,6 +68,7 @@ T* QueryExtension(EventEngine::Endpoint* endpoint) { /// supported by the listener. template T* QueryExtension(EventEngine::Listener* listener) { + if (listener == nullptr) return nullptr; return static_cast(listener->QueryExtension(T::EndpointExtensionName())); } @@ -75,6 +76,7 @@ T* QueryExtension(EventEngine::Listener* listener) { /// supported by the EventEngine. template T* QueryExtension(EventEngine* engine) { + if (engine == nullptr) return nullptr; return static_cast(engine->QueryExtension(T::EndpointExtensionName())); }