From e5cd63f971ffbeef9afc6c6efbea85f10dd80477 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Fri, 10 May 2024 19:49:00 -0700 Subject: [PATCH] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log (#36575) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log In this CL we are migrating from gRPCs own gpr logging mechanism to absl logging mechanism. The intention is to deprecate gpr_log in the future. We have the following mapping 1. gpr_log(GPR_INFO,...) -> LOG(INFO) 2. gpr_log(GPR_ERROR,...) -> LOG(ERROR) 3. gpr_log(GPR_DEBUG,...) -> VLOG(2) Reviewers need to check : 1. If the above mapping is correct. 2. The content of the log is as before. gpr_log format strings did not use string_view or std::string . absl LOG accepts these. So there will be some elimination of string_view and std::string related conversions. This is expected. Closes #36575 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36575 from tanvi-jagtap:test_core_e2e_all ef6f23db8c4d4a48818d94501492d3382ce57af4 PiperOrigin-RevId: 632669009 --- test/core/end2end/BUILD | 27 ++++++++++-- test/core/end2end/bad_server_response_test.cc | 19 ++++---- test/core/end2end/connection_refused_test.cc | 8 ++-- test/core/end2end/cq_verifier.cc | 15 +++---- test/core/end2end/dualstack_socket_test.cc | 27 ++++++------ test/core/end2end/end2end_tests.cc | 7 +-- .../end2end/fixtures/http_proxy_fixture.cc | 8 ++-- test/core/end2end/fixtures/proxy.cc | 6 +-- test/core/end2end/fuzzers/BUILD | 2 + test/core/end2end/fuzzers/fuzzing_common.cc | 3 +- test/core/end2end/fuzzers/network_input.cc | 4 +- test/core/end2end/goaway_server_test.cc | 7 ++- test/core/end2end/grpc_core_end2end_test.bzl | 3 ++ test/core/end2end/h2_ssl_cert_test.cc | 6 +-- .../end2end/invalid_call_argument_test.cc | 44 +++++++++---------- test/core/end2end/no_server_test.cc | 6 +-- test/core/end2end/tests/call_creds.cc | 14 +++--- .../core/end2end/tests/disappearing_server.cc | 6 +-- test/core/end2end/tests/filter_context.cc | 8 ++-- .../end2end/tests/resource_quota_server.cc | 12 ++--- test/core/end2end/tests/server_streaming.cc | 4 +- .../end2end/tests/simple_delayed_request.cc | 8 ++-- test/core/end2end/tests/simple_request.cc | 4 +- .../tests/timeout_before_request_call.cc | 3 +- 24 files changed, 134 insertions(+), 117 deletions(-) diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index 08c373e425d..597fb7c0c26 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -28,6 +28,7 @@ grpc_cc_library( "absl/container:flat_hash_map", "absl/functional:any_invocable", "absl/log:check", + "absl/log:log", "absl/strings", "absl/strings:str_format", "absl/types:variant", @@ -64,6 +65,7 @@ grpc_cc_library( hdrs = ["fixtures/http_proxy_fixture.h"], external_deps = [ "absl/log:check", + "absl/log:log", "absl/status", "absl/status:statusor", "absl/strings", @@ -96,7 +98,10 @@ grpc_cc_library( name = "proxy", srcs = ["fixtures/proxy.cc"], hdrs = ["fixtures/proxy.h"], - external_deps = ["absl/log:check"], + external_deps = [ + "absl/log:check", + "absl/log:log", + ], language = "C++", deps = [ "//:channel_arg_names", @@ -120,6 +125,7 @@ grpc_cc_library( external_deps = [ "absl/functional:any_invocable", "absl/log:check", + "absl/log:log", "absl/memory", "absl/meta:type_traits", "absl/random", @@ -500,7 +506,10 @@ grpc_core_end2end_test(name = "write_buffering_at_end") grpc_cc_test( name = "bad_server_response_test", srcs = ["bad_server_response_test.cc"], - external_deps = ["absl/log:check"], + external_deps = [ + "absl/log:check", + "absl/log:log", + ], language = "C++", deps = [ "cq_verifier", @@ -523,7 +532,10 @@ grpc_cc_test( grpc_cc_test( name = "connection_refused_test", srcs = ["connection_refused_test.cc"], - external_deps = ["absl/log:check"], + external_deps = [ + "absl/log:check", + "absl/log:log", + ], language = "C++", deps = [ "cq_verifier", @@ -541,6 +553,7 @@ grpc_cc_test( srcs = ["dualstack_socket_test.cc"], external_deps = [ "absl/log:check", + "absl/log:log", "absl/status:statusor", "absl/strings", "absl/strings:str_format", @@ -565,6 +578,7 @@ grpc_cc_test( srcs = ["goaway_server_test.cc"], external_deps = [ "absl/log:check", + "absl/log:log", "absl/status", "absl/status:statusor", "absl/strings", @@ -596,7 +610,10 @@ grpc_cc_test( grpc_cc_test( name = "invalid_call_argument_test", srcs = ["invalid_call_argument_test.cc"], - external_deps = ["absl/log:check"], + external_deps = [ + "absl/log:check", + "absl/log:log", + ], language = "C++", deps = [ "cq_verifier", @@ -623,6 +640,7 @@ grpc_cc_test( srcs = ["no_server_test.cc"], external_deps = [ "absl/log:check", + "absl/log:log", "absl/status", "absl/status:statusor", "absl/time", @@ -652,6 +670,7 @@ grpc_cc_test( external_deps = [ "absl/functional:any_invocable", "absl/log:check", + "absl/log:log", "absl/memory", "absl/meta:type_traits", "absl/strings", diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index eb9b0c09a2f..b2c38dba64a 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -25,6 +25,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include @@ -135,8 +135,7 @@ static void handle_write() { static void handle_read(void* /*arg*/, grpc_error_handle error) { if (!error.ok()) { - gpr_log(GPR_ERROR, "handle_read error: %s", - grpc_core::StatusToString(error).c_str()); + LOG(ERROR) << "handle_read error: " << grpc_core::StatusToString(error); return; } state.incoming_data_length += state.temp_incoming_buffer.length; @@ -145,15 +144,13 @@ static void handle_read(void* /*arg*/, grpc_error_handle error) { for (i = 0; i < state.temp_incoming_buffer.count; i++) { char* dump = grpc_dump_slice(state.temp_incoming_buffer.slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "Server received: %s", dump); + VLOG(2) << "Server received: " << dump; gpr_free(dump); } - gpr_log(GPR_DEBUG, - "got %" PRIuPTR " bytes, expected %" PRIuPTR - " bytes or a non-HTTP2 response to be sent", - state.incoming_data_length, - SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD); + VLOG(2) << "got " << state.incoming_data_length << " bytes, expected " + << SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD + << " bytes or a non-HTTP2 response to be sent"; if (state.incoming_data_length >= SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD || !state.http2_response) { @@ -299,8 +296,8 @@ static void actually_poll_server(void* arg) { bool done = gpr_atm_acq_load(&state.done_atm) != 0; gpr_timespec time_left = gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, - time_left.tv_sec, time_left.tv_nsec); + VLOG(2) << "done=" << done << ", time_left=" << time_left.tv_sec << "." + << time_left.tv_nsec; if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) { break; } diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index 055e115a286..1e3414b8875 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -21,6 +21,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" @@ -49,8 +49,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_status_code status; grpc_slice details; - gpr_log(GPR_INFO, "TEST: wait_for_ready=%d use_service_config=%d", - wait_for_ready, use_service_config); + LOG(INFO) << "TEST: wait_for_ready=" << wait_for_ready + << " use_service_config=" << use_service_config; grpc_init(); @@ -81,7 +81,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { // create a call, channel to a port which will refuse connection int port = grpc_pick_unused_port_or_die(); std::string addr = grpc_core::JoinHostPort("127.0.0.1", port); - gpr_log(GPR_INFO, "server: %s", addr.c_str()); + LOG(INFO) << "server: " << addr; grpc_channel_credentials* creds = grpc_insecure_credentials_create(); chan = grpc_channel_create(addr.c_str(), creds, args); grpc_channel_credentials_release(creds); diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc index c318f7fa301..c0bc5b66f97 100644 --- a/test/core/end2end/cq_verifier.cc +++ b/test/core/end2end/cq_verifier.cc @@ -29,6 +29,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -41,7 +42,6 @@ #include #include #include -#include #include #include "src/core/lib/compression/message_compress.h" @@ -126,9 +126,8 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer* rbb, grpc_slice b) { 0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), GRPC_SLICE_LENGTH(a)); if (!ok) { - gpr_log(GPR_ERROR, - "SLICE MISMATCH: left_length=%" PRIuPTR " right_length=%" PRIuPTR, - GRPC_SLICE_LENGTH(a), GRPC_SLICE_LENGTH(b)); + LOG(ERROR) << "SLICE MISMATCH: left_length=" << GRPC_SLICE_LENGTH(a) + << " right_length=" << GRPC_SLICE_LENGTH(b); std::string out; const char* a_str = reinterpret_cast(GRPC_SLICE_START_PTR(a)); const char* b_str = reinterpret_cast(GRPC_SLICE_START_PTR(b)); @@ -151,7 +150,7 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer* rbb, grpc_slice b) { absl::CEscape(absl::string_view(&b_str[i], 1)), "\u001b[0m"); } - gpr_log(GPR_ERROR, "%s", out.c_str()); + LOG(ERROR) << out; } } grpc_slice_unref(a); @@ -365,8 +364,7 @@ void CqVerifier::Verify(Duration timeout, SourceLocation location) { while (!expectations_.empty()) { must_log = std::exchange(added_expectations_, false) || must_log; if (log_verifications_ && must_log) { - gpr_log(GPR_ERROR, "Verify %s for %s", ToShortString().c_str(), - timeout.ToString().c_str()); + LOG(ERROR) << "Verify " << ToShortString() << " for " << timeout; } must_log = false; grpc_event ev = Step(deadline); @@ -423,8 +421,7 @@ bool CqVerifier::AllMaybes() const { void CqVerifier::VerifyEmpty(Duration timeout, SourceLocation location) { if (log_verifications_) { - gpr_log(GPR_ERROR, "Verify empty completion queue for %s", - timeout.ToString().c_str()); + LOG(ERROR) << "Verify empty completion queue for " << timeout; } const gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), timeout.as_timespec()); diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index bf793e97bec..33ab2091c1b 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -21,6 +21,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/statusor.h" #include @@ -47,7 +48,6 @@ #include #include #include -#include #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/gprpp/host_port.h" @@ -78,7 +78,7 @@ static void log_resolved_addrs(const char* label, const char* hostname) { return; } for (const auto& addr : *addresses_or) { - gpr_log(GPR_INFO, "%s: %s", label, grpc_sockaddr_to_uri(&addr)->c_str()); + LOG(INFO) << label << ": " << grpc_sockaddr_to_uri(&addr)->c_str(); } } @@ -152,9 +152,9 @@ void test_connect(const char* server_host, const char* client_host, int port, client = grpc_channel_create(client_hostport.c_str(), creds, nullptr); grpc_channel_credentials_release(creds); - gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", - server_hostport.c_str(), client_hostport.c_str(), - expect_ok ? "success" : "failure"); + LOG(INFO) << "Testing with server=" << server_hostport.c_str() + << " client=" << client_hostport.c_str() << " (expecting " + << (expect_ok ? "success" : "failure") << ")"; log_resolved_addrs("server resolved addr", server_host); log_resolved_addrs("client resolved addr", client_host); @@ -236,7 +236,7 @@ void test_connect(const char* server_host, const char* client_host, int port, cqv.Verify(); peer = grpc_call_get_peer(c); - gpr_log(GPR_DEBUG, "got peer: '%s'", peer); + VLOG(2) << "got peer: '" << peer << "'"; gpr_free(peer); CHECK_EQ(status, GRPC_STATUS_UNIMPLEMENTED); @@ -251,8 +251,8 @@ void test_connect(const char* server_host, const char* client_host, int port, cqv.Expect(grpc_core::CqVerifier::tag(1), true); cqv.Verify(); - gpr_log(GPR_INFO, "status: %d (expected: %d)", status, - GRPC_STATUS_UNAVAILABLE); + LOG(INFO) << "status: " << status + << " (expected: " << GRPC_STATUS_UNAVAILABLE << ")"; CHECK_EQ(status, GRPC_STATUS_UNAVAILABLE); } @@ -301,10 +301,9 @@ int external_dns_works(const char* host) { // dualstack_socket_test from functioning correctly). See b/201064791. if (grpc_sockaddr_to_uri(&addr).value() == "ipv6:%5B64:ff9b::7f00:1%5D:80") { - gpr_log( - GPR_INFO, - "Detected DNS64 server response. Tests that depend on " - "*.unittest.grpc.io. will be skipped as they won't work with DNS64."); + LOG(INFO) << "Detected DNS64 server response. Tests that depend on " + "*.unittest.grpc.io. will be skipped as they won't work " + "with DNS64."; result = 0; break; } @@ -319,7 +318,7 @@ int main(int argc, char** argv) { grpc_init(); if (!grpc_ipv6_loopback_available()) { - gpr_log(GPR_INFO, "Can't bind to ::1. Skipping IPv6 tests."); + LOG(INFO) << "Can't bind to ::1. Skipping IPv6 tests."; do_ipv6 = 0; } @@ -360,7 +359,7 @@ int main(int argc, char** argv) { if (!external_dns_works("loopback4.unittest.grpc.io") || !external_dns_works("loopback46.unittest.grpc.io")) { - gpr_log(GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io."); + LOG(INFO) << "Skipping tests that depend on *.unittest.grpc.io."; } else { test_connect("loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io", 0, 1); diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc index 30615b1698a..51505c91fd5 100644 --- a/test/core/end2end/end2end_tests.cc +++ b/test/core/end2end/end2end_tests.cc @@ -23,6 +23,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include "absl/random/random.h" @@ -117,7 +118,7 @@ void CoreEnd2endTest::TearDown() { // This will wait until gRPC shutdown has actually happened to make sure // no gRPC resources (such as thread) are active. (timeout = 10s) if (!grpc_wait_until_shutdown(10)) { - gpr_log(GPR_ERROR, "Timeout in waiting for gRPC shutdown"); + LOG(ERROR) << "Timeout in waiting for gRPC shutdown"; } } CHECK_EQ(client_, nullptr); @@ -153,8 +154,8 @@ std::string CoreEnd2endTest::IncomingMessage::payload() const { grpc_slice_buffer decompressed_buffer; grpc_slice_buffer_init(&decompressed_buffer); CHECK(grpc_msg_decompress(payload_->data.raw.compression, - &payload_->data.raw.slice_buffer, - &decompressed_buffer)); + &payload_->data.raw.slice_buffer, + &decompressed_buffer)); grpc_byte_buffer* rbb = grpc_raw_byte_buffer_create( decompressed_buffer.slices, decompressed_buffer.count); grpc_byte_buffer_reader reader; diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index be2ec412014..3eca777e098 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -27,6 +27,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/escaping.h" @@ -37,7 +38,6 @@ #include #include #include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -510,8 +510,8 @@ static bool proxy_auth_header_matches(absl::string_view proxy_auth_header_val, // which will cause the client connection to be dropped. static void on_read_request_done_locked(void* arg, grpc_error_handle error) { proxy_connection* conn = static_cast(arg); - gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn, - grpc_core::StatusToString(error).c_str()); + VLOG(2) << "on_read_request_done: " << conn << " " + << grpc_core::StatusToString(error); if (!error.ok()) { proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy read request", error); @@ -670,7 +670,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( // Construct proxy address. const int proxy_port = grpc_pick_unused_port_or_die(); proxy->proxy_name = grpc_core::JoinHostPort("localhost", proxy_port); - gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name.c_str()); + LOG(INFO) << "Proxy address: " << proxy->proxy_name; // Create TCP server. auto channel_args = grpc_core::CoreConfiguration::Get() .channel_args_preconditioning() diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index cb1a2e04cb2..febdb809838 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -24,6 +24,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include @@ -106,8 +106,8 @@ grpc_end2end_proxy* grpc_end2end_proxy_create( proxy->proxy_port = grpc_core::JoinHostPort("localhost", proxy_port); proxy->server_port = grpc_core::JoinHostPort("localhost", server_port); - gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port.c_str(), - proxy->server_port.c_str()); + VLOG(2) << "PROXY ADDR:" << proxy->proxy_port + << " BACKEND:" << proxy->server_port; proxy->cq = grpc_completion_queue_create_for_next(nullptr); proxy->server = def->create_server(proxy->proxy_port.c_str(), server_args); diff --git a/test/core/end2end/fuzzers/BUILD b/test/core/end2end/fuzzers/BUILD index 35f52f6be3b..c3a1f0245c9 100644 --- a/test/core/end2end/fuzzers/BUILD +++ b/test/core/end2end/fuzzers/BUILD @@ -36,6 +36,7 @@ grpc_cc_library( hdrs = ["fuzzing_common.h"], external_deps = [ "absl/log:check", + "absl/log:log", "absl/strings", ], deps = [ @@ -92,6 +93,7 @@ grpc_cc_library( name = "network_input", srcs = ["network_input.cc"], hdrs = ["network_input.h"], + external_deps = ["absl/log:log"], deps = [ "fuzzer_input_proto", "//:chttp2_frame", diff --git a/test/core/end2end/fuzzers/fuzzing_common.cc b/test/core/end2end/fuzzers/fuzzing_common.cc index 4a20a7870fe..2597694bf3b 100644 --- a/test/core/end2end/fuzzers/fuzzing_common.cc +++ b/test/core/end2end/fuzzers/fuzzing_common.cc @@ -24,6 +24,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/types/optional.h" @@ -638,7 +639,7 @@ bool BasicFuzzer::Continue() { BasicFuzzer::Result BasicFuzzer::ExecuteAction( const api_fuzzer::Action& action) { - gpr_log(GPR_DEBUG, "EXECUTE_ACTION: %s", action.DebugString().c_str()); + VLOG(2) << "EXECUTE_ACTION: " << action.DebugString(); switch (action.type_case()) { case api_fuzzer::Action::TYPE_NOT_SET: return BasicFuzzer::Result::kFailed; diff --git a/test/core/end2end/fuzzers/network_input.cc b/test/core/end2end/fuzzers/network_input.cc index 855d3185678..278fd0ffc69 100644 --- a/test/core/end2end/fuzzers/network_input.cc +++ b/test/core/end2end/fuzzers/network_input.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" @@ -520,8 +521,7 @@ Duration ScheduleConnection( endpoint) mutable { ExecCtx exec_ctx; if (!endpoint.ok()) { - gpr_log(GPR_ERROR, "Failed to connect: %s", - endpoint.status().ToString().c_str()); + LOG(ERROR) << "Failed to connect: " << endpoint.status(); return; } std::shared_ptr ep = diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index 3efd3939364..edf58074223 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -27,6 +27,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -40,7 +41,6 @@ #include #include #include -#include #include #include @@ -212,9 +212,8 @@ static void my_cancel_ares_request(grpc_ares_request* request) { int main(int argc, char** argv) { // TODO(yijiem): rewrite this test with a custom EventEngine DNS Resolver if (grpc_core::IsEventEngineDnsEnabled()) { - gpr_log( - GPR_ERROR, - "Skipping iomgr-specific DNS test because EventEngine DNS is enabled"); + LOG(ERROR) << "Skipping iomgr-specific DNS test because EventEngine DNS is " + "enabled"; return 0; } grpc_completion_queue* cq; diff --git a/test/core/end2end/grpc_core_end2end_test.bzl b/test/core/end2end/grpc_core_end2end_test.bzl index 78733efcf2b..8b75ae6aac8 100644 --- a/test/core/end2end/grpc_core_end2end_test.bzl +++ b/test/core/end2end/grpc_core_end2end_test.bzl @@ -43,6 +43,9 @@ def grpc_core_end2end_test(name, shard_count = 10, tags = []): srcs = [ "tests/%s.cc" % name, ], + external_deps = [ + "absl/log:log", + ], deps = [ "cq_verifier", "end2end_test_lib", diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index d24c6956235..3d1470194ec 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,6 +25,7 @@ #include "absl/functional/any_invocable.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/optional.h" #include "gtest/gtest.h" @@ -37,7 +38,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" @@ -245,9 +245,7 @@ static void simple_request_body(grpc_core::CoreTestFixture* f, class H2SslCertTest : public ::testing::TestWithParam { protected: - H2SslCertTest() { - gpr_log(GPR_INFO, "SSL_CERT_tests/%s", GetParam().config.name); - } + H2SslCertTest() { LOG(INFO) << "SSL_CERT_tests/" << GetParam().config.name; } void SetUp() override { fixture_ = GetParam().config.create_fixture(grpc_core::ChannelArgs(), grpc_core::ChannelArgs()); diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index a297eb61a3b..1f086c3f98a 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 "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -32,7 +33,6 @@ #include #include #include -#include #include #include @@ -155,7 +155,7 @@ static void cleanup_test() { } static void test_non_null_reserved_on_start_batch() { - gpr_log(GPR_INFO, "test_non_null_reserved_on_start_batch"); + LOG(INFO) << "test_non_null_reserved_on_start_batch"; prepare_test(1); CHECK(GRPC_CALL_ERROR == @@ -165,7 +165,7 @@ static void test_non_null_reserved_on_start_batch() { } static void test_non_null_reserved_on_op() { - gpr_log(GPR_INFO, "test_non_null_reserved_on_op"); + LOG(INFO) << "test_non_null_reserved_on_op"; grpc_op* op; prepare_test(1); @@ -184,7 +184,7 @@ static void test_non_null_reserved_on_op() { } static void test_send_initial_metadata_more_than_once() { - gpr_log(GPR_INFO, "test_send_initial_metadata_more_than_once"); + LOG(INFO) << "test_send_initial_metadata_more_than_once"; grpc_op* op; prepare_test(1); @@ -216,7 +216,7 @@ static void test_send_initial_metadata_more_than_once() { } static void test_too_many_metadata() { - gpr_log(GPR_INFO, "test_too_many_metadata"); + LOG(INFO) << "test_too_many_metadata"; grpc_op* op; prepare_test(1); @@ -235,7 +235,7 @@ static void test_too_many_metadata() { } static void test_send_null_message() { - gpr_log(GPR_INFO, "test_send_null_message"); + LOG(INFO) << "test_send_null_message"; grpc_op* op; prepare_test(1); @@ -259,7 +259,7 @@ static void test_send_null_message() { } static void test_send_messages_at_the_same_time() { - gpr_log(GPR_INFO, "test_send_messages_at_the_same_time"); + LOG(INFO) << "test_send_messages_at_the_same_time"; grpc_op* op; grpc_slice request_payload_slice = @@ -293,7 +293,7 @@ static void test_send_messages_at_the_same_time() { } static void test_send_server_status_from_client() { - gpr_log(GPR_INFO, "test_send_server_status_from_client"); + LOG(INFO) << "test_send_server_status_from_client"; grpc_op* op; prepare_test(1); @@ -315,7 +315,7 @@ static void test_send_server_status_from_client() { } static void test_receive_initial_metadata_twice_at_client() { - gpr_log(GPR_INFO, "test_receive_initial_metadata_twice_at_client"); + LOG(INFO) << "test_receive_initial_metadata_twice_at_client"; grpc_op* op; prepare_test(1); @@ -347,7 +347,7 @@ static void test_receive_initial_metadata_twice_at_client() { } static void test_receive_message_with_invalid_flags() { - gpr_log(GPR_INFO, "test_receive_message_with_invalid_flags"); + LOG(INFO) << "test_receive_message_with_invalid_flags"; grpc_op* op; grpc_byte_buffer* payload = nullptr; @@ -366,7 +366,7 @@ static void test_receive_message_with_invalid_flags() { } static void test_receive_two_messages_at_the_same_time() { - gpr_log(GPR_INFO, "test_receive_two_messages_at_the_same_time"); + LOG(INFO) << "test_receive_two_messages_at_the_same_time"; grpc_op* op; grpc_byte_buffer* payload = nullptr; @@ -390,7 +390,7 @@ static void test_receive_two_messages_at_the_same_time() { } static void test_recv_close_on_server_from_client() { - gpr_log(GPR_INFO, "test_recv_close_on_server_from_client"); + LOG(INFO) << "test_recv_close_on_server_from_client"; grpc_op* op; prepare_test(1); @@ -409,7 +409,7 @@ static void test_recv_close_on_server_from_client() { } static void test_recv_status_on_client_twice() { - gpr_log(GPR_INFO, "test_recv_status_on_client_twice"); + LOG(INFO) << "test_recv_status_on_client_twice"; grpc_op* op; prepare_test(1); @@ -446,7 +446,7 @@ static void test_recv_status_on_client_twice() { } static void test_send_close_from_client_on_server() { - gpr_log(GPR_INFO, "test_send_close_from_client_on_server"); + LOG(INFO) << "test_send_close_from_client_on_server"; grpc_op* op; prepare_test(0); @@ -464,7 +464,7 @@ static void test_send_close_from_client_on_server() { } static void test_recv_status_on_client_from_server() { - gpr_log(GPR_INFO, "test_recv_status_on_client_from_server"); + LOG(INFO) << "test_recv_status_on_client_from_server"; grpc_op* op; prepare_test(0); @@ -486,7 +486,7 @@ static void test_recv_status_on_client_from_server() { } static void test_send_status_from_server_with_invalid_flags() { - gpr_log(GPR_INFO, "test_send_status_from_server_with_invalid_flags"); + LOG(INFO) << "test_send_status_from_server_with_invalid_flags"; grpc_op* op; prepare_test(0); @@ -508,7 +508,7 @@ static void test_send_status_from_server_with_invalid_flags() { } static void test_too_many_trailing_metadata() { - gpr_log(GPR_INFO, "test_too_many_trailing_metadata"); + LOG(INFO) << "test_too_many_trailing_metadata"; grpc_op* op; prepare_test(0); @@ -531,7 +531,7 @@ static void test_too_many_trailing_metadata() { } static void test_send_server_status_twice() { - gpr_log(GPR_INFO, "test_send_server_status_twice"); + LOG(INFO) << "test_send_server_status_twice"; grpc_op* op; prepare_test(0); @@ -560,7 +560,7 @@ static void test_send_server_status_twice() { } static void test_recv_close_on_server_with_invalid_flags() { - gpr_log(GPR_INFO, "test_recv_close_on_server_with_invalid_flags"); + LOG(INFO) << "test_recv_close_on_server_with_invalid_flags"; grpc_op* op; prepare_test(0); @@ -579,7 +579,7 @@ static void test_recv_close_on_server_with_invalid_flags() { } static void test_recv_close_on_server_twice() { - gpr_log(GPR_INFO, "test_recv_close_on_server_twice"); + LOG(INFO) << "test_recv_close_on_server_twice"; grpc_op* op; prepare_test(0); @@ -603,7 +603,7 @@ static void test_recv_close_on_server_twice() { } static void test_invalid_initial_metadata_reserved_key() { - gpr_log(GPR_INFO, "test_invalid_initial_metadata_reserved_key"); + LOG(INFO) << "test_invalid_initial_metadata_reserved_key"; grpc_metadata metadata; metadata.key = grpc_slice_from_static_string(":start_with_colon"); @@ -626,7 +626,7 @@ static void test_invalid_initial_metadata_reserved_key() { } static void test_multiple_ops_in_a_single_batch() { - gpr_log(GPR_INFO, "test_multiple_ops_in_a_single_batch"); + LOG(INFO) << "test_multiple_ops_in_a_single_batch"; grpc_op* op; prepare_test(1); diff --git a/test/core/end2end/no_server_test.cc b/test/core/end2end/no_server_test.cc index dc3db4b37bf..4b14f0a1a72 100644 --- a/test/core/end2end/no_server_test.cc +++ b/test/core/end2end/no_server_test.cc @@ -21,6 +21,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/time/time.h" @@ -31,7 +32,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" @@ -45,7 +45,7 @@ #include "test/core/test_util/test_config.h" void run_test(bool wait_for_ready) { - gpr_log(GPR_INFO, "TEST: wait_for_ready=%d", wait_for_ready); + LOG(INFO) << "TEST: wait_for_ready=" << wait_for_ready; grpc_init(); @@ -104,7 +104,7 @@ void run_test(bool wait_for_ready) { cqv.Expect(grpc_core::CqVerifier::tag(1), true); cqv.Verify(); - gpr_log(GPR_INFO, "call status: %d", status); + LOG(INFO) << "call status: " << status; if (wait_for_ready) { CHECK_EQ(status, GRPC_STATUS_DEADLINE_EXCEEDED); } else { diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc index ce6b949085f..2b078a1152d 100644 --- a/test/core/end2end/tests/call_creds.cc +++ b/test/core/end2end/tests/call_creds.cc @@ -18,6 +18,7 @@ #include +#include "absl/log/log.h" #include "absl/types/optional.h" #include "gtest/gtest.h" @@ -25,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" @@ -47,17 +47,17 @@ const char overridden_fake_md_value[] = "overridden_fake_value"; void PrintAuthContext(bool is_client, const grpc_auth_context* ctx) { const grpc_auth_property* p; grpc_auth_property_iterator it; - gpr_log(GPR_INFO, "%s peer:", is_client ? "client" : "server"); - gpr_log(GPR_INFO, "\tauthenticated: %s", - grpc_auth_context_peer_is_authenticated(ctx) ? "YES" : "NO"); + LOG(INFO) << (is_client ? "client" : "server") << " peer:"; + LOG(INFO) << "\tauthenticated: " + << (grpc_auth_context_peer_is_authenticated(ctx) ? "YES" : "NO"); it = grpc_auth_context_peer_identity(ctx); while ((p = grpc_auth_property_iterator_next(&it)) != nullptr) { - gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value); + LOG(INFO) << "\t\t" << p->name << ": " << p->value; } - gpr_log(GPR_INFO, "\tall properties:"); + LOG(INFO) << "\tall properties:"; it = grpc_auth_context_property_iterator(ctx); while ((p = grpc_auth_property_iterator_next(&it)) != nullptr) { - gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value); + LOG(INFO) << "\t\t" << p->name << ": " << p->value; } } diff --git a/test/core/end2end/tests/disappearing_server.cc b/test/core/end2end/tests/disappearing_server.cc index 81cea5a5ad2..5b65e20eb57 100644 --- a/test/core/end2end/tests/disappearing_server.cc +++ b/test/core/end2end/tests/disappearing_server.cc @@ -18,10 +18,10 @@ #include +#include "absl/log/log.h" #include "gtest/gtest.h" #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" @@ -31,13 +31,13 @@ namespace grpc_core { static void OneRequestAndShutdownServer(CoreEnd2endTest& test) { - gpr_log(GPR_ERROR, "Create client side call"); + LOG(ERROR) << "Create client side call"; auto c = test.NewClientCall("/service/method") .Timeout(Duration::Seconds(30)) .Create(); CoreEnd2endTest::IncomingMetadata server_initial_md; CoreEnd2endTest::IncomingStatusOnClient server_status; - gpr_log(GPR_ERROR, "Start initial batch"); + LOG(ERROR) << "Start initial batch"; c.NewBatch(1) .SendInitialMetadata({}) .SendCloseFromClient() diff --git a/test/core/end2end/tests/filter_context.cc b/test/core/end2end/tests/filter_context.cc index b3e2759ef1f..789a05d94d7 100644 --- a/test/core/end2end/tests/filter_context.cc +++ b/test/core/end2end/tests/filter_context.cc @@ -20,11 +20,11 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "gtest/gtest.h" #include -#include #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" @@ -53,7 +53,7 @@ grpc_error_handle init_call_elem(grpc_call_element* elem, const grpc_call_element_args* args) { call_data* calld = static_cast(elem->call_data); calld->context = args->context; - gpr_log(GPR_INFO, "init_call_elem(): context=%p", args->context); + LOG(INFO) << "init_call_elem(): context=" << args->context; return absl::OkStatus(); } @@ -63,8 +63,8 @@ void start_transport_stream_op_batch(grpc_call_element* elem, // If batch payload context is not null (which will happen in some // cancellation cases), make sure we get the same context here that we // saw in init_call_elem(). - gpr_log(GPR_INFO, "start_transport_stream_op_batch(): context=%p", - batch->payload->context); + LOG(INFO) << "start_transport_stream_op_batch(): context=" + << batch->payload->context; if (batch->payload->context != nullptr) { CHECK(calld->context == batch->payload->context); } diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc index acf4c109089..0bc7a69e034 100644 --- a/test/core/end2end/tests/resource_quota_server.cc +++ b/test/core/end2end/tests/resource_quota_server.cc @@ -21,13 +21,13 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/experiments/experiments.h" @@ -146,11 +146,11 @@ CORE_END2END_TEST(ResourceQuotaTest, ResourceQuota) { cancelled_calls_on_server++; } } - gpr_log(GPR_INFO, - "Done. %d total calls: %d cancelled at server, %d cancelled at " - "client, %d timed out, %d unavailable.", - kNumCalls, cancelled_calls_on_server, cancelled_calls_on_client, - deadline_exceeded, unavailable); + LOG(INFO) << "Done. " << kNumCalls + << " total calls: " << cancelled_calls_on_server + << " cancelled at server, " << cancelled_calls_on_client + << " cancelled at client, " << deadline_exceeded << " timed out, " + << unavailable << " unavailable."; ShutdownServerAndNotify(0); Expect(0, PerformAction{[this](bool success) { diff --git a/test/core/end2end/tests/server_streaming.cc b/test/core/end2end/tests/server_streaming.cc index 76cd2ae7382..b6fd6f30511 100644 --- a/test/core/end2end/tests/server_streaming.cc +++ b/test/core/end2end/tests/server_streaming.cc @@ -19,10 +19,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "gtest/gtest.h" #include -#include #include "src/core/lib/gprpp/time.h" #include "test/core/end2end/cq_verifier.h" @@ -70,7 +70,7 @@ void ServerStreaming(CoreEnd2endTest& test, int num_messages) { test.Expect(104, true); test.Step(); - gpr_log(GPR_DEBUG, "SEEN_STATUS:%d", seen_status); + VLOG(2) << "SEEN_STATUS:" << seen_status; // Client keeps reading messages till it gets the status int num_messages_received = 0; diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc index e22ea978335..bbdfe4ab790 100644 --- a/test/core/end2end/tests/simple_delayed_request.cc +++ b/test/core/end2end/tests/simple_delayed_request.cc @@ -18,12 +18,12 @@ #include +#include "absl/log/log.h" #include "gtest/gtest.h" #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" @@ -37,17 +37,17 @@ CORE_END2END_TEST(Http2SingleHopTest, SimpleDelayedRequestShort) { .Set(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000) .Set(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 1000) .Set(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 5000)); - gpr_log(GPR_ERROR, "Create client side call"); + LOG(ERROR) << "Create client side call"; auto c = NewClientCall("/foo").Timeout(Duration::Minutes(1)).Create(); IncomingMetadata server_initial_metadata; IncomingStatusOnClient server_status; - gpr_log(GPR_ERROR, "Start initial batch"); + LOG(ERROR) << "Start initial batch"; c.NewBatch(1) .SendInitialMetadata({}, GRPC_INITIAL_METADATA_WAIT_FOR_READY) .SendCloseFromClient() .RecvInitialMetadata(server_initial_metadata) .RecvStatusOnClient(server_status); - gpr_log(GPR_ERROR, "Start server"); + LOG(ERROR) << "Start server"; InitServer(ChannelArgs()); auto s = RequestCall(101); Expect(101, true); diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 359489f6c2d..1e39734d327 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -22,13 +22,13 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/types/optional.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include -#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" @@ -91,7 +91,7 @@ void SimpleRequestBody(CoreEnd2endTest& test) { expected_calls *= 2; } auto after = global_stats().Collect(); - gpr_log(GPR_DEBUG, "%s", StatsAsJson(after.get()).c_str()); + VLOG(2) << StatsAsJson(after.get()); EXPECT_EQ(after->client_calls_created - before->client_calls_created, expected_calls); EXPECT_EQ(after->server_calls_created - before->server_calls_created, diff --git a/test/core/end2end/tests/timeout_before_request_call.cc b/test/core/end2end/tests/timeout_before_request_call.cc index 5ad6a9872a1..bb61acd648e 100644 --- a/test/core/end2end/tests/timeout_before_request_call.cc +++ b/test/core/end2end/tests/timeout_before_request_call.cc @@ -16,6 +16,7 @@ #include +#include "absl/log/log.h" #include "gtest/gtest.h" #include @@ -147,7 +148,7 @@ CORE_END2END_TEST(CoreDeadlineSingleHopTest, bool got_call = false; std::unique_ptr client_close; Expect(2, MaybePerformAction{[this, &s, &got_call, &client_close](bool ok) { - gpr_log(GPR_INFO, "\n***\n*** got call: %d\n***", ok); + LOG(INFO) << "\n***\n*** got call: " << ok << "\n***"; got_call = true; if (ok) { // If we successfully get a call, then we should additionally get a