Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log #36575

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e05bc7a
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
559b238
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
7fc4cf5
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
f975798
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
70090e8
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
e6469e7
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
b77d863
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
9d4c966
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
fc2cbcf
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 9, 2024
b9e9c52
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
d93b01c
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
37465fe
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
9f62972
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
3886097
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
34d596a
Merge branch 'master' into test_core_e2e_all
tanvi-jagtap May 10, 2024
579c932
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
5cc29a2
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log
tanvi-jagtap May 10, 2024
ef6f23d
Merge branch 'master' into test_core_e2e_all
tanvi-jagtap May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 23 additions & 4 deletions test/core/end2end/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
19 changes: 8 additions & 11 deletions test/core/end2end/bad_server_response_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <vector>

#include "absl/log/check.h"
#include "absl/log/log.h"

#include <grpc/credentials.h>
#include <grpc/grpc.h>
Expand All @@ -35,7 +36,6 @@
#include <grpc/status.h>
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions test/core/end2end/connection_refused_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>

#include "absl/log/check.h"
#include "absl/log/log.h"

#include <grpc/credentials.h>
#include <grpc/grpc.h>
Expand All @@ -29,7 +30,6 @@
#include <grpc/impl/propagation_bits.h>
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>

#include "src/core/lib/channel/channel_args.h"
Expand All @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
15 changes: 6 additions & 9 deletions test/core/end2end/cq_verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <vector>

#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"
Expand All @@ -41,7 +42,6 @@
#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>

#include "src/core/lib/compression/message_compress.h"
Expand Down Expand Up @@ -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<const char*>(GRPC_SLICE_START_PTR(a));
const char* b_str = reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(b));
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
27 changes: 13 additions & 14 deletions test/core/end2end/dualstack_socket_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"

#include <grpc/impl/propagation_bits.h>
Expand All @@ -47,7 +48,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>

#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gprpp/host_port.h"
Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions test/core/end2end/end2end_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <tuple>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h"
#include "absl/random/random.h"

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down