Merge branch 'master' into test_core_e2e_all

pull/36575/head
tanvi-jagtap 10 months ago
commit ef6f23db8c
  1. 10
      BUILD
  2. 8
      src/core/BUILD
  3. 19
      src/core/lib/gpr/android/log.cc
  4. 45
      src/core/lib/gpr/linux/log.cc
  5. 11
      src/core/lib/gpr/log.cc
  6. 42
      src/core/lib/gpr/posix/log.cc
  7. 43
      src/core/lib/gpr/windows/log.cc
  8. 6
      test/core/address_utils/BUILD
  9. 14
      test/core/address_utils/parse_address_test.cc
  10. 13
      test/core/address_utils/parse_address_with_named_scope_id_test.cc
  11. 15
      test/core/bad_client/bad_client.cc
  12. 7
      test/core/bad_client/generate_tests.bzl
  13. 5
      test/core/bad_connection/BUILD
  14. 14
      test/core/bad_connection/close_fd_test.cc
  15. 1
      test/core/bad_ssl/generate_tests.bzl
  16. 4
      test/core/bad_ssl/server_common.cc
  17. 2
      test/core/channel/BUILD
  18. 6
      test/core/channel/channel_args_test.cc
  19. 13
      test/core/channel/metrics_test.cc
  20. 10
      test/core/compression/BUILD
  21. 10
      test/core/compression/compression_test.cc
  22. 1
      test/core/compression/message_compress_test.cc
  23. 2
      test/cpp/interop/BUILD
  24. 40
      test/cpp/interop/grpclb_fallback_test.cc
  25. 33
      test/cpp/interop/http2_client.cc

10
BUILD

@ -1136,6 +1136,7 @@ grpc_cc_library(
"absl/functional:any_invocable",
"absl/hash",
"absl/log:check",
"absl/log:log",
"absl/memory",
"absl/meta:type_traits",
"absl/status",
@ -1645,6 +1646,7 @@ grpc_cc_library(
"absl/container:flat_hash_set",
"absl/functional:any_invocable",
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2015,6 +2017,7 @@ grpc_cc_library(
"absl/functional:any_invocable",
"absl/functional:function_ref",
"absl/log:check",
"absl/log:log",
"absl/meta:type_traits",
"absl/status",
"absl/status:statusor",
@ -2694,6 +2697,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:log",
"absl/strings",
],
language = "c++",
@ -3672,6 +3676,7 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:any_invocable",
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3995,6 +4000,7 @@ grpc_cc_library(
],
external_deps = [
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4087,6 +4093,7 @@ grpc_cc_library(
],
external_deps = [
"absl/log:check",
"absl/log:log",
"absl/strings",
"@com_google_protobuf//upb:base",
"@com_google_protobuf//upb:mem",
@ -4209,6 +4216,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4342,6 +4350,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/cleanup",
"absl/log:check",
"absl/log:log",
"absl/memory",
"absl/status",
"absl/status:statusor",
@ -4719,6 +4728,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/hash",
"absl/log:check",
"absl/log:log",
"absl/meta:type_traits",
"absl/random",
"absl/random:bit_gen_ref",

@ -754,6 +754,7 @@ grpc_cc_library(
name = "join_state",
external_deps = [
"absl/log:check",
"absl/log:log",
],
language = "c++",
public_hdrs = [
@ -843,6 +844,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/log:log",
"absl/strings",
],
language = "c++",
@ -4825,6 +4827,7 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:function_ref",
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4942,6 +4945,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/hash",
"absl/log:check",
"absl/log:log",
"absl/random",
"absl/status",
"absl/status:statusor",
@ -5644,6 +5648,7 @@ grpc_cc_library(
external_deps = [
"absl/algorithm:container",
"absl/log:check",
"absl/log:log",
"absl/random",
"absl/status",
"absl/status:statusor",
@ -5868,6 +5873,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/log:log",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -5938,6 +5944,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/log:log",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -6084,6 +6091,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/functional:function_ref",
"absl/log:check",
"absl/log:log",
"absl/status",
"absl/status:statusor",
"absl/strings",

@ -57,23 +57,4 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
free(message);
}
void gpr_platform_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char* output = NULL;
final_slash = strrchr(args->file, '/');
if (final_slash == NULL)
display_file = args->file;
else
display_file = final_slash + 1;
asprintf(&output, "%s:%d] %s", display_file, args->line, args->message);
__android_log_write(severity_to_log_priority(args->severity), "GRPC", output);
// allocated by asprintf => use free, not gpr_free
free(output);
}
#endif // GPR_ANDROID

@ -47,10 +47,6 @@
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
static long sys_gettid(void) { return syscall(__NR_gettid); }
void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) {
// Avoid message construction if gpr_log_message won't log
@ -70,45 +66,4 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
free(message);
}
void gpr_platform_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
struct tm tm;
static thread_local long tid(0);
if (tid == 0) tid = sys_gettid();
timer = static_cast<time_t>(now.tv_sec);
final_slash = strrchr(args->file, '/');
if (final_slash == nullptr) {
display_file = args->file;
} else {
display_file = final_slash + 1;
}
if (!localtime_r(&timer, &tm)) {
strcpy(time_buffer, "error:localtime");
} else if (0 ==
strftime(time_buffer, sizeof(time_buffer), "%m%d %H:%M:%S", &tm)) {
strcpy(time_buffer, "error:strftime");
}
std::string prefix = absl::StrFormat(
"%s%s.%09" PRId32 " %7ld %s:%d]", gpr_log_severity_string(args->severity),
time_buffer, now.tv_nsec, tid, display_file, args->line);
absl::optional<std::string> stack_trace =
gpr_should_log_stacktrace(args->severity)
? grpc_core::GetCurrentStackTrace()
: absl::nullopt;
if (stack_trace) {
fprintf(stderr, "%-70s %s\n%s\n", prefix.c_str(), args->message,
stack_trace->c_str());
} else {
fprintf(stderr, "%-70s %s\n", prefix.c_str(), args->message);
}
}
#endif // GPR_LINUX_LOG

@ -77,10 +77,6 @@ int gpr_should_log(gpr_log_severity severity) {
}
void gpr_default_log(gpr_log_func_args* args) {
if (!grpc_core::ConfigVars::Get().AbslLogging()) {
gpr_platform_log(args);
return;
}
switch (args->severity) {
case GPR_LOG_SEVERITY_DEBUG:
// Log DEBUG messages as VLOG(2).
@ -99,13 +95,6 @@ void gpr_default_log(gpr_log_func_args* args) {
}
}
int gpr_should_log_stacktrace(gpr_log_severity severity) {
return static_cast<gpr_atm>(severity) >=
gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)
? 1
: 0;
}
void gpr_log_message(const char* file, int line, gpr_log_severity severity,
const char* message) {
if (gpr_should_log(severity) == 0) {

@ -38,10 +38,6 @@
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); }
void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) {
// Avoid message construction if gpr_log_message won't log
@ -70,42 +66,4 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
gpr_free(allocated);
}
void gpr_platform_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
struct tm tm;
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/');
if (final_slash == nullptr)
display_file = args->file;
else
display_file = final_slash + 1;
if (!localtime_r(&timer, &tm)) {
strcpy(time_buffer, "error:localtime");
} else if (0 ==
strftime(time_buffer, sizeof(time_buffer), "%m%d %H:%M:%S", &tm)) {
strcpy(time_buffer, "error:strftime");
}
std::string prefix = absl::StrFormat(
"%s%s.%09d %7" PRIdPTR " %s:%d]", gpr_log_severity_string(args->severity),
time_buffer, (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
absl::optional<std::string> stack_trace =
gpr_should_log_stacktrace(args->severity)
? grpc_core::GetCurrentStackTrace()
: absl::nullopt;
if (stack_trace) {
fprintf(stderr, "%-70s %s\n%s\n", prefix.c_str(), args->message,
stack_trace->c_str());
} else {
fprintf(stderr, "%-70s %s\n", prefix.c_str(), args->message);
}
}
#endif // defined(GPR_POSIX_LOG)

@ -33,8 +33,6 @@
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) {
// Avoid message construction if gpr_log_message won't log
@ -72,45 +70,4 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
gpr_free(message);
}
// Simple starter implementation
void gpr_platform_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
time_t timer;
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
struct tm tm;
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '\\');
if (final_slash == NULL)
display_file = args->file;
else
display_file = final_slash + 1;
if (localtime_s(&tm, &timer)) {
strcpy(time_buffer, "error:localtime");
} else if (0 ==
strftime(time_buffer, sizeof(time_buffer), "%m%d %H:%M:%S", &tm)) {
strcpy(time_buffer, "error:strftime");
}
absl::optional<std::string> stack_trace =
gpr_should_log_stacktrace(args->severity)
? grpc_core::GetCurrentStackTrace()
: absl::nullopt;
if (stack_trace) {
fprintf(stderr, "%s%s.%09u %5lu %s:%d] %s\n%s\n",
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), GetCurrentThreadId(), display_file, args->line,
args->message, stack_trace->c_str());
} else {
fprintf(stderr, "%s%s.%09u %5lu %s:%d] %s\n",
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), GetCurrentThreadId(), display_file, args->line,
args->message);
}
fflush(stderr);
}
#endif // GPR_WINDOWS_LOG

@ -41,6 +41,7 @@ grpc_cc_test(
name = "parse_address_test",
srcs = ["parse_address_test.cc"],
external_deps = [
"absl/log:log",
"absl/strings",
"gtest",
],
@ -69,7 +70,10 @@ grpc_fuzzer(
grpc_cc_test(
name = "parse_address_with_named_scope_id_test",
srcs = ["parse_address_with_named_scope_id_test.cc"],
external_deps = ["gtest"],
external_deps = [
"absl/log:log",
"gtest",
],
language = "C++",
tags = ["no_windows"],
uses_event_engine = False,

@ -34,12 +34,12 @@
#include <string>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "gtest/gtest.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/port.h"
@ -53,7 +53,7 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -70,7 +70,7 @@ static void test_grpc_parse_unix_abstract(const char* uri_text,
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -98,7 +98,7 @@ static void test_grpc_parse_vsock(const char* uri_text, uint32_t cid,
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -122,7 +122,7 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -142,7 +142,7 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -162,7 +162,7 @@ static void test_grpc_parse_ipv6_invalid(const char* uri_text) {
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;

@ -28,13 +28,13 @@
#include <string>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "gtest/gtest.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/gprpp/crash.h"
@ -114,10 +114,8 @@ TEST(ParseAddressWithNamedScopeIdTest, MainTest) {
// system recognizes, and then use that for the test.
for (size_t i = 1; i < 65536; i++) {
if (if_indextoname(i, arbitrary_interface_name) != nullptr) {
gpr_log(GPR_DEBUG,
"Found interface at index %" PRIuPTR
" named %s. Will use this for the test",
i, arbitrary_interface_name);
VLOG(2) << "Found interface at index " << i << " named "
<< arbitrary_interface_name << ". Will use this for the test";
break;
}
}
@ -127,9 +125,8 @@ TEST(ParseAddressWithNamedScopeIdTest, MainTest) {
struct sockaddr_in6 result_from_getaddrinfo =
resolve_with_gettaddrinfo(target.c_str());
// Run the test
gpr_log(GPR_DEBUG,
"Run test_grpc_parse_ipv6_parity_with_getaddrinfo with target: %s",
target.c_str());
VLOG(2) << "Run test_grpc_parse_ipv6_parity_with_getaddrinfo with target: "
<< target;
test_grpc_parse_ipv6_parity_with_getaddrinfo(target.c_str(),
result_from_getaddrinfo);
// Cleanup

@ -22,11 +22,11 @@
#include <limits.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/impl/channel_arg_names.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -111,11 +111,11 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags,
hex = gpr_dump(arg->client_payload, arg->client_payload_length,
GPR_DUMP_HEX | GPR_DUMP_ASCII);
// Add a debug log
gpr_log(GPR_INFO, "TEST: %s", hex);
LOG(INFO) << "TEST: " << hex;
gpr_free(hex);
} else {
gpr_log(GPR_INFO, "TEST: (%" PRIdPTR " byte long string)",
arg->client_payload_length);
LOG(INFO) << "TEST: (" << arg->client_payload_length
<< " byte long string)";
}
grpc_slice slice = grpc_slice_from_copied_buffer(arg->client_payload,
@ -171,9 +171,8 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags,
.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,
"client validator failed; trying additional read "
"in case we didn't get all the data");
LOG(INFO) << "client validator failed; trying additional read "
"in case we didn't get all the data";
}
grpc_slice_buffer_destroy(&incoming);
}
@ -317,7 +316,7 @@ bool rst_stream_client_validator(grpc_slice_buffer* incoming, void* /*arg*/) {
*p++ == 0 || *p++ == 0 || *p++ == 0 || *p == 0 || *p == 11;
if (!success) {
gpr_log(GPR_INFO, "client expected RST_STREAM frame, not found");
LOG(INFO) << "client expected RST_STREAM frame, not found";
}
grpc_slice_buffer_destroy(&last_frame_buffer);

@ -44,6 +44,10 @@ def grpc_bad_client_tests():
hdrs = ["bad_client.h"],
language = "C++",
testonly = 1,
external_deps = [
"absl/log:check",
"absl/log:log",
],
deps = [
"//test/core/test_util:grpc_test_util",
"//:grpc",
@ -51,9 +55,6 @@ 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(

@ -23,7 +23,10 @@ grpc_cc_binary(
srcs = [
"close_fd_test.cc",
],
external_deps = ["absl/log:check"],
external_deps = [
"absl/log:check",
"absl/log:log",
],
language = "C++",
tags = ["no_windows"],
deps = [

@ -24,6 +24,7 @@
#include <stdint.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@ -53,7 +54,6 @@
#include <grpc/byte_buffer.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/gprpp/crash.h"
@ -225,8 +225,8 @@ static void _test_close_before_server_recv(fd_type fdtype) {
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
gpr_log(GPR_INFO, "Running test: test_close_%s_before_server_recv",
fd_type_str(fdtype));
LOG(INFO) << "Running test: test_close_" << fd_type_str(fdtype)
<< "_before_server_recv";
test_init();
grpc_op ops[6];
@ -399,8 +399,8 @@ static void _test_close_before_server_send(fd_type fdtype) {
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
gpr_log(GPR_INFO, "Running test: test_close_%s_before_server_send",
fd_type_str(fdtype));
LOG(INFO) << "Running test: test_close_" << fd_type_str(fdtype)
<< "_before_server_send";
test_init();
grpc_op ops[6];
@ -596,8 +596,8 @@ static void _test_close_before_client_send(fd_type fdtype) {
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_byte_buffer* response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
gpr_log(GPR_INFO, "Running test: test_close_%s_before_client_send",
fd_type_str(fdtype));
LOG(INFO) << "Running test: test_close_" << fd_type_str(fdtype)
<< "_before_client_send";
test_init();
grpc_op ops[6];

@ -35,6 +35,7 @@ def grpc_bad_ssl_tests():
hdrs = ["server_common.h"],
external_deps = [
"absl/log:check",
"absl/log:log",
],
deps = [
"//test/core/test_util:grpc_test_util",

@ -21,8 +21,8 @@
#include <signal.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "test/core/test_util/cmdline.h"
@ -74,7 +74,7 @@ void bad_ssl_run(grpc_server* server) {
signal(SIGINT, sigint_handler);
while (!shutdown_finished) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
LOG(INFO) << "Shutting down due to SIGINT";
shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, nullptr);
CHECK(grpc_completion_queue_pluck(shutdown_cq, nullptr,

@ -37,6 +37,7 @@ grpc_cc_test(
srcs = ["channel_args_test.cc"],
external_deps = [
"absl/log:check",
"absl/log:log",
"gtest",
],
language = "C++",
@ -149,6 +150,7 @@ grpc_cc_test(
name = "metrics_test",
srcs = ["metrics_test.cc"],
external_deps = [
"absl/log:log",
"gtest",
],
language = "C++",

@ -21,6 +21,7 @@
#include <string.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/credentials.h>
@ -28,7 +29,6 @@
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/notification.h"
@ -272,7 +272,7 @@ struct fake_class {
};
static void* fake_pointer_arg_copy(void* arg) {
gpr_log(GPR_DEBUG, "fake_pointer_arg_copy");
VLOG(2) << "fake_pointer_arg_copy";
fake_class* fc = static_cast<fake_class*>(arg);
fake_class* new_fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
new_fc->foo = fc->foo;
@ -280,7 +280,7 @@ static void* fake_pointer_arg_copy(void* arg) {
}
static void fake_pointer_arg_destroy(void* arg) {
gpr_log(GPR_DEBUG, "fake_pointer_arg_destroy");
VLOG(2) << "fake_pointer_arg_destroy";
fake_class* fc = static_cast<fake_class*>(arg);
gpr_free(fc);
}

@ -16,6 +16,7 @@
#include <memory>
#include "absl/log/log.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@ -217,7 +218,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) {
auto plugin3 = MakeStatsPluginForTarget(kDomain1To4);
// Register two callbacks that set the same metric but with different
// label values. The callbacks get used only by plugin1.
gpr_log(GPR_INFO, "testing callbacks for: plugin1");
LOG(INFO) << "testing callbacks for: plugin1";
auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain3To4, ""));
auto callback1 = group1.RegisterCallback(
@ -278,7 +279,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) {
callback1.reset();
callback2.reset();
// Now register callbacks that hit both plugin1 and plugin2.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2");
LOG(INFO) << "testing callbacks for: plugin1, plugin2";
auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain2To4, ""));
callback1 = group2.RegisterCallback(
@ -339,7 +340,7 @@ TEST_F(MetricsTest, Int64CallbackGauge) {
callback1.reset();
callback2.reset();
// Now register callbacks that hit all three plugins.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2, plugin3");
LOG(INFO) << "testing callbacks for: plugin1, plugin2, plugin3";
auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain1To4, ""));
callback1 = group3.RegisterCallback(
@ -422,7 +423,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) {
auto plugin3 = MakeStatsPluginForTarget(kDomain1To4);
// Register two callbacks that set the same metric but with different
// label values. The callbacks get used only by plugin1.
gpr_log(GPR_INFO, "testing callbacks for: plugin1");
LOG(INFO) << "testing callbacks for: plugin1";
auto group1 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain3To4, ""));
auto callback1 = group1.RegisterCallback(
@ -483,7 +484,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) {
callback1.reset();
callback2.reset();
// Now register callbacks that hit both plugin1 and plugin2.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2");
LOG(INFO) << "testing callbacks for: plugin1, plugin2";
auto group2 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain2To4, ""));
callback1 = group2.RegisterCallback(
@ -544,7 +545,7 @@ TEST_F(MetricsTest, DoubleCallbackGauge) {
callback1.reset();
callback2.reset();
// Now register callbacks that hit all three plugins.
gpr_log(GPR_INFO, "testing callbacks for: plugin1, plugin2, plugin3");
LOG(INFO) << "testing callbacks for: plugin1, plugin2, plugin3";
auto group3 = GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
StatsPluginChannelScope(kDomain1To4, ""));
callback1 = group3.RegisterCallback(

@ -26,7 +26,10 @@ licenses(["notice"])
grpc_cc_test(
name = "compression_test",
srcs = ["compression_test.cc"],
external_deps = ["gtest"],
external_deps = [
"absl/log:log",
"gtest",
],
language = "C++",
uses_event_engine = False,
uses_polling = False,
@ -67,7 +70,10 @@ grpc_fuzzer(
grpc_cc_test(
name = "message_compress_test",
srcs = ["message_compress_test.cc"],
external_deps = ["gtest"],
external_deps = [
"absl/log:log",
"gtest",
],
language = "C++",
uses_event_engine = False,
uses_polling = False,

@ -21,11 +21,11 @@
#include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/compression.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h"
#include "test/core/test_util/test_config.h"
@ -40,7 +40,7 @@ TEST(CompressionTest, CompressionAlgorithmParse) {
};
const char* invalid_names[] = {"gzip2", "foo", "", "2gzip"};
gpr_log(GPR_DEBUG, "test_compression_algorithm_parse");
VLOG(2) << "test_compression_algorithm_parse";
for (i = 0; i < GPR_ARRAY_SIZE(valid_names); i++) {
const char* valid_name = valid_names[i];
@ -73,7 +73,7 @@ TEST(CompressionTest, CompressionAlgorithmName) {
GRPC_COMPRESS_DEFLATE,
};
gpr_log(GPR_DEBUG, "test_compression_algorithm_name");
VLOG(2) << "test_compression_algorithm_name";
for (i = 0; i < GPR_ARRAY_SIZE(valid_algorithms); i++) {
success = grpc_compression_algorithm_name(valid_algorithms[i], &name);
@ -88,7 +88,7 @@ TEST(CompressionTest, CompressionAlgorithmName) {
}
TEST(CompressionTest, CompressionAlgorithmForLevel) {
gpr_log(GPR_DEBUG, "test_compression_algorithm_for_level");
VLOG(2) << "test_compression_algorithm_for_level";
{
// accept only identity (aka none)
@ -211,7 +211,7 @@ TEST(CompressionTest, CompressionEnableDisableAlgorithm) {
grpc_compression_options options;
grpc_compression_algorithm algorithm;
gpr_log(GPR_DEBUG, "test_compression_enable_disable_algorithm");
VLOG(2) << "test_compression_enable_disable_algorithm";
grpc_compression_options_init(&options);
for (algorithm = GRPC_COMPRESS_NONE;

@ -28,7 +28,6 @@
#include <grpc/compression.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/iomgr/exec_ctx.h"

@ -46,6 +46,7 @@ grpc_cc_binary(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
"absl/time:time",
],
language = "C++",
@ -429,6 +430,7 @@ grpc_cc_binary(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
],
deps = [
"//:grpc++",

@ -32,11 +32,11 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "absl/time/time.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -87,8 +87,8 @@ enum RpcMode {
GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds,
RpcMode rpc_mode) {
gpr_log(GPR_INFO, "DoRPCAndGetPath deadline_seconds:%d rpc_mode:%d",
deadline_seconds, rpc_mode);
LOG(INFO) << "DoRPCAndGetPath deadline_seconds:" << deadline_seconds
<< " rpc_mode:" << rpc_mode;
SimpleRequest request;
SimpleResponse response;
grpc::ClientContext context;
@ -101,16 +101,16 @@ GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds,
context.set_deadline(deadline);
grpc::Status s = stub->UnaryCall(&context, request, &response);
if (!s.ok()) {
gpr_log(GPR_INFO, "DoRPCAndGetPath failed. status-message: %s",
s.error_message().c_str());
LOG(INFO) << "DoRPCAndGetPath failed. status-message: "
<< s.error_message();
return GrpclbRouteType::GRPCLB_ROUTE_TYPE_UNKNOWN;
}
CHECK(response.grpclb_route_type() ==
GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND ||
response.grpclb_route_type() ==
GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK);
gpr_log(GPR_INFO, "DoRPCAndGetPath done. grpclb_route_type:%d",
response.grpclb_route_type());
LOG(INFO) << "DoRPCAndGetPath done. grpclb_route_type:"
<< response.grpclb_route_type();
return response.grpclb_route_type();
}
@ -120,7 +120,7 @@ GrpclbRouteType DoRPCAndGetPath(TestService::Stub* stub, int deadline_seconds) {
bool TcpUserTimeoutMutateFd(int fd, grpc_socket_mutator* /*mutator*/) {
int timeout = 20000; // 20 seconds
gpr_log(GPR_INFO, "Setting socket option TCP_USER_TIMEOUT on fd: %d", fd);
LOG(INFO) << "Setting socket option TCP_USER_TIMEOUT on fd: " << fd;
if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
sizeof(timeout))) {
grpc_core::Crash("Failed to set socket option TCP_USER_TIMEOUT");
@ -161,7 +161,7 @@ std::unique_ptr<TestService::Stub> CreateFallbackTestStub() {
}
void RunCommand(const std::string& command) {
gpr_log(GPR_INFO, "RunCommand: |%s|", command.c_str());
LOG(INFO) << "RunCommand: |" << command << "|";
int out = std::system(command.c_str());
if (WIFEXITED(out)) {
int code = WEXITSTATUS(out);
@ -185,25 +185,23 @@ void WaitForFallbackAndDoRPCs(TestService::Stub* stub) {
while (absl::Now() < fallback_deadline) {
GrpclbRouteType grpclb_route_type = DoRPCAndGetPath(stub, 1);
if (grpclb_route_type == GrpclbRouteType::GRPCLB_ROUTE_TYPE_BACKEND) {
gpr_log(GPR_ERROR,
"Got grpclb route type backend. Backends are "
"supposed to be unreachable, so this test is broken");
LOG(ERROR) << "Got grpclb route type backend. Backends are "
"supposed to be unreachable, so this test is broken";
CHECK(0);
}
if (grpclb_route_type == GrpclbRouteType::GRPCLB_ROUTE_TYPE_FALLBACK) {
gpr_log(GPR_INFO,
"Made one successful RPC to a fallback. Now expect the same for "
"the rest.");
LOG(INFO) << "Made one successful RPC to a fallback. Now expect the same "
"for the rest.";
fallback = true;
break;
} else {
gpr_log(GPR_ERROR, "Retryable RPC failure on iteration: %d",
fallback_retry_count);
LOG(ERROR) << "Retryable RPC failure on iteration: "
<< fallback_retry_count;
}
fallback_retry_count++;
}
if (!fallback) {
gpr_log(GPR_ERROR, "Didn't fall back within deadline");
LOG(ERROR) << "Didn't fall back within deadline";
CHECK(0);
}
for (int i = 0; i < 30; i++) {
@ -231,13 +229,13 @@ void DoFallbackAfterStartupTest() {
int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
gpr_log(GPR_INFO, "Testing: %s", absl::GetFlag(FLAGS_test_case).c_str());
LOG(INFO) << "Testing: " << absl::GetFlag(FLAGS_test_case);
if (absl::GetFlag(FLAGS_test_case) == "fallback_before_startup") {
DoFallbackBeforeStartupTest();
gpr_log(GPR_INFO, "DoFallbackBeforeStartup done!");
LOG(INFO) << "DoFallbackBeforeStartup done!";
} else if (absl::GetFlag(FLAGS_test_case) == "fallback_after_startup") {
DoFallbackAfterStartupTest();
gpr_log(GPR_INFO, "DoFallbackBeforeStartup done!");
LOG(INFO) << "DoFallbackBeforeStartup done!";
} else {
grpc_core::Crash(absl::StrFormat("Invalid test case: %s",
absl::GetFlag(FLAGS_test_case).c_str()));

@ -22,10 +22,10 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -81,40 +81,40 @@ SimpleRequest Http2Client::BuildDefaultRequest() {
}
bool Http2Client::DoRstAfterHeader() {
gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream after header");
VLOG(2) << "Sending RPC and expecting reset stream after header";
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::INTERNAL);
CHECK(!response.has_payload()); // no data should be received
gpr_log(GPR_DEBUG, "Done testing reset stream after header");
VLOG(2) << "Done testing reset stream after header";
return true;
}
bool Http2Client::DoRstAfterData() {
gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream after data");
VLOG(2) << "Sending RPC and expecting reset stream after data";
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::INTERNAL);
// There is no guarantee that data would be received.
gpr_log(GPR_DEBUG, "Done testing reset stream after data");
VLOG(2) << "Done testing reset stream after data";
return true;
}
bool Http2Client::DoRstDuringData() {
gpr_log(GPR_DEBUG, "Sending RPC and expecting reset stream during data");
VLOG(2) << "Sending RPC and expecting reset stream during data";
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::INTERNAL);
CHECK(!response.has_payload()); // no data should be received
gpr_log(GPR_DEBUG, "Done testing reset stream during data");
VLOG(2) << "Done testing reset stream during data";
return true;
}
bool Http2Client::DoGoaway() {
gpr_log(GPR_DEBUG, "Sending two RPCs and expecting goaway");
VLOG(2) << "Sending two RPCs and expecting goaway";
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK);
CHECK(response.payload().body() == std::string(kLargeResponseSize, '\0'));
@ -127,16 +127,16 @@ bool Http2Client::DoGoaway() {
response.Clear();
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK);
CHECK(response.payload().body() == std::string(kLargeResponseSize, '\0'));
gpr_log(GPR_DEBUG, "Done testing goaway");
VLOG(2) << "Done testing goaway";
return true;
}
bool Http2Client::DoPing() {
gpr_log(GPR_DEBUG, "Sending RPC and expecting ping");
VLOG(2) << "Sending RPC and expecting ping";
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK);
CHECK(response.payload().body() == std::string(kLargeResponseSize, '\0'));
gpr_log(GPR_DEBUG, "Done testing ping");
VLOG(2) << "Done testing ping";
return true;
}
@ -148,7 +148,7 @@ void Http2Client::MaxStreamsWorker(
}
bool Http2Client::DoMaxStreams() {
gpr_log(GPR_DEBUG, "Testing max streams");
VLOG(2) << "Testing max streams";
// Make an initial call on the channel to ensure the server's max streams
// setting is received
@ -167,7 +167,7 @@ bool Http2Client::DoMaxStreams() {
it->join();
}
gpr_log(GPR_DEBUG, "Done testing max streams");
VLOG(2) << "Done testing max streams";
return true;
}
@ -198,7 +198,7 @@ int main(int argc, char** argv) {
CHECK(channel->WaitForConnected(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(300, GPR_TIMESPAN))));
grpc::testing::Http2Client client(channel);
gpr_log(GPR_INFO, "Testing case: %s", absl::GetFlag(FLAGS_test_case).c_str());
LOG(INFO) << "Testing case: " << absl::GetFlag(FLAGS_test_case);
int ret = 0;
if (absl::GetFlag(FLAGS_test_case) == "rst_after_header") {
client.DoRstAfterHeader();
@ -219,8 +219,9 @@ int main(int argc, char** argv) {
char* joined_testcases =
gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", nullptr);
gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s",
absl::GetFlag(FLAGS_test_case).c_str(), joined_testcases);
LOG(ERROR) << "Unsupported test case " << absl::GetFlag(FLAGS_test_case)
<< ". Valid options are\n"
<< joined_testcases;
gpr_free(joined_testcases);
ret = 1;
}

Loading…
Cancel
Save