Merge branch 'transport-refs-2' into transport-refs-3

pull/36509/head
Craig Tiller 10 months ago
commit f15f73832b
  1. 4
      BUILD
  2. 11
      CMakeLists.txt
  3. 1
      build_autogenerated.yaml
  4. 1
      gRPC-C++.podspec
  5. 1
      gRPC-Core.podspec
  6. 8
      src/core/BUILD
  7. 4
      src/core/lib/gpr/alloc.cc
  8. 48
      src/core/lib/gpr/posix/sync.cc
  9. 15
      src/core/lib/gpr/posix/time.cc
  10. 4
      src/core/lib/gpr/posix/tmpfile.cc
  11. 9
      src/core/lib/gpr/subprocess_posix.cc
  12. 8
      src/core/lib/gpr/sync.cc
  13. 18
      src/core/lib/gpr/time.cc
  14. 4
      src/core/lib/gpr/windows/sync.cc
  15. 5
      src/core/lib/gpr/windows/time.cc
  16. 8
      src/core/lib/gprpp/chunked_vector.h
  17. 3
      src/core/lib/gprpp/down_cast.h
  18. 14
      src/core/lib/gprpp/dual_ref_counted.h
  19. 7
      src/core/lib/gprpp/host_port.cc
  20. 6
      src/core/lib/gprpp/mpscq.h
  21. 6
      src/core/lib/gprpp/posix/stat.cc
  22. 16
      src/core/lib/gprpp/posix/thd.cc
  23. 6
      src/core/lib/gprpp/ref_counted.h
  24. 4
      src/core/lib/gprpp/single_set_ptr.h
  25. 3
      src/core/lib/gprpp/status_helper.cc
  26. 7
      src/core/lib/gprpp/sync.h
  27. 11
      src/core/lib/gprpp/thd.h
  28. 9
      src/core/lib/gprpp/time.cc
  29. 6
      src/core/lib/gprpp/time_util.cc
  30. 6
      src/core/lib/gprpp/windows/stat.cc
  31. 6
      src/core/lib/gprpp/windows/thd.cc
  32. 7
      src/core/lib/gprpp/work_serializer.cc
  33. 1
      src/core/lib/surface/call.h
  34. 1
      test/cpp/interop/BUILD
  35. 339
      test/cpp/interop/interop_client.cc

@ -786,6 +786,8 @@ grpc_cc_library(
"absl/base:log_severity",
"absl/functional:any_invocable",
"absl/log",
"absl/log:check",
"absl/log:globals",
"absl/memory",
"absl/random",
"absl/status",
@ -2962,6 +2964,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/container:inlined_vector",
"absl/log:check",
],
language = "c++",
visibility = ["@grpc:client_channel"],
@ -4836,6 +4839,7 @@ grpc_cc_library(
"//src/core:lib/gpr/subprocess.h",
],
external_deps = [
"absl/log:check",
"absl/strings",
"absl/types:span",
],

11
CMakeLists.txt generated

@ -1749,6 +1749,7 @@ target_link_libraries(gpr
absl::flags_marshalling
absl::any_invocable
absl::check
absl::log_globals
absl::log
absl::memory
absl::random_random
@ -36922,7 +36923,7 @@ generate_pkgconfig(
"gpr"
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_globals absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
""
"-lgpr"
""
@ -36933,7 +36934,7 @@ generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares openssl re2 zlib"
"-lgrpc"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36944,7 +36945,7 @@ generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares zlib"
"-lgrpc_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36955,7 +36956,7 @@ generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"libcares openssl re2 zlib"
"-lgrpc++"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36966,7 +36967,7 @@ generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"libcares zlib"
"-lgrpc++_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"

@ -130,6 +130,7 @@ libs:
- absl/flags:marshalling
- absl/functional:any_invocable
- absl/log:check
- absl/log:globals
- absl/log:log
- absl/memory:memory
- absl/random:random

1
gRPC-C++.podspec generated

@ -244,6 +244,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version

1
gRPC-Core.podspec generated

@ -216,6 +216,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version

@ -329,6 +329,9 @@ grpc_cc_library(
grpc_cc_library(
name = "chunked_vector",
hdrs = ["lib/gprpp/chunked_vector.h"],
external_deps = [
"absl/log:check",
],
deps = [
"arena",
"gpr_manual_constructor",
@ -352,6 +355,7 @@ grpc_cc_library(
"lib/gprpp/status_helper.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/strings",
"absl/strings:cord",
@ -1648,6 +1652,7 @@ grpc_cc_library(
"lib/gprpp/time.h",
],
external_deps = [
"absl/log:check",
"absl/strings:str_format",
"absl/types:optional",
],
@ -3086,6 +3091,9 @@ grpc_cc_library(
hdrs = [
"lib/gprpp/single_set_ptr.h",
],
external_deps = [
"absl/log:check",
],
language = "c++",
deps = ["//:gpr"],
)

@ -21,6 +21,8 @@
#include <stdlib.h>
#include <string.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -59,7 +61,7 @@ void* gpr_realloc(void* p, size_t size) {
}
void* gpr_malloc_aligned(size_t size, size_t alignment) {
GPR_ASSERT(((alignment - 1) & alignment) == 0); // Must be power of 2.
CHECK_EQ(((alignment - 1) & alignment), 0u); // Must be power of 2.
size_t extra = alignment - 1 + sizeof(void*);
void* p = gpr_malloc(size + extra);
void** ret = reinterpret_cast<void**>(

@ -24,6 +24,8 @@
#include <errno.h>
#include <time.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@ -33,36 +35,36 @@
void gpr_mu_init(gpr_mu* mu) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_mutex_init(&mu->mutex, nullptr) == 0);
CHECK_EQ(pthread_mutex_init(&mu->mutex, nullptr), 0);
mu->leak_checker = static_cast<int*>(malloc(sizeof(*mu->leak_checker)));
GPR_ASSERT(mu->leak_checker != nullptr);
CHECK_NE(mu->leak_checker, nullptr);
#else
GPR_ASSERT(pthread_mutex_init(mu, nullptr) == 0);
CHECK_EQ(pthread_mutex_init(mu, nullptr), 0);
#endif
}
void gpr_mu_destroy(gpr_mu* mu) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_mutex_destroy(&mu->mutex) == 0);
CHECK_EQ(pthread_mutex_destroy(&mu->mutex), 0);
free(mu->leak_checker);
#else
GPR_ASSERT(pthread_mutex_destroy(mu) == 0);
CHECK_EQ(pthread_mutex_destroy(mu), 0);
#endif
}
void gpr_mu_lock(gpr_mu* mu) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_mutex_lock(&mu->mutex) == 0);
CHECK_EQ(pthread_mutex_lock(&mu->mutex), 0);
#else
GPR_ASSERT(pthread_mutex_lock(mu) == 0);
CHECK_EQ(pthread_mutex_lock(mu), 0);
#endif
}
void gpr_mu_unlock(gpr_mu* mu) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_mutex_unlock(&mu->mutex) == 0);
CHECK_EQ(pthread_mutex_unlock(&mu->mutex), 0);
#else
GPR_ASSERT(pthread_mutex_unlock(mu) == 0);
CHECK_EQ(pthread_mutex_unlock(mu), 0);
#endif
}
@ -73,7 +75,7 @@ int gpr_mu_trylock(gpr_mu* mu) {
#else
err = pthread_mutex_trylock(mu);
#endif
GPR_ASSERT(err == 0 || err == EBUSY);
CHECK(err == 0 || err == EBUSY);
return err == 0;
}
@ -81,26 +83,26 @@ int gpr_mu_trylock(gpr_mu* mu) {
void gpr_cv_init(gpr_cv* cv) {
pthread_condattr_t attr;
GPR_ASSERT(pthread_condattr_init(&attr) == 0);
CHECK_EQ(pthread_condattr_init(&attr), 0);
#if GPR_LINUX
GPR_ASSERT(pthread_condattr_setclock(&attr, CLOCK_MONOTONIC) == 0);
CHECK_EQ(pthread_condattr_setclock(&attr, CLOCK_MONOTONIC), 0);
#endif // GPR_LINUX
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_cond_init(&cv->cond_var, &attr) == 0);
CHECK_EQ(pthread_cond_init(&cv->cond_var, &attr), 0);
cv->leak_checker = static_cast<int*>(malloc(sizeof(*cv->leak_checker)));
GPR_ASSERT(cv->leak_checker != nullptr);
CHECK_NE(cv->leak_checker, nullptr);
#else
GPR_ASSERT(pthread_cond_init(cv, &attr) == 0);
CHECK_EQ(pthread_cond_init(cv, &attr), 0);
#endif
}
void gpr_cv_destroy(gpr_cv* cv) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_cond_destroy(&cv->cond_var) == 0);
CHECK_EQ(pthread_cond_destroy(&cv->cond_var), 0);
free(cv->leak_checker);
#else
GPR_ASSERT(pthread_cond_destroy(cv) == 0);
CHECK_EQ(pthread_cond_destroy(cv), 0);
#endif
}
@ -129,30 +131,30 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
#endif
}
GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN);
CHECK(err == 0 || err == ETIMEDOUT || err == EAGAIN);
return err == ETIMEDOUT;
}
void gpr_cv_signal(gpr_cv* cv) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_cond_signal(&cv->cond_var) == 0);
CHECK_EQ(pthread_cond_signal(&cv->cond_var), 0);
#else
GPR_ASSERT(pthread_cond_signal(cv) == 0);
CHECK_EQ(pthread_cond_signal(cv), 0);
#endif
}
void gpr_cv_broadcast(gpr_cv* cv) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_cond_broadcast(&cv->cond_var) == 0);
CHECK_EQ(pthread_cond_broadcast(&cv->cond_var), 0);
#else
GPR_ASSERT(pthread_cond_broadcast(cv) == 0);
CHECK_EQ(pthread_cond_broadcast(cv), 0);
#endif
}
//----------------------------------------
void gpr_once_init(gpr_once* once, void (*init_function)(void)) {
GPR_ASSERT(pthread_once(once, init_function) == 0);
CHECK_EQ(pthread_once(once, init_function), 0);
}
#endif // defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) &&

@ -28,6 +28,8 @@
#ifdef __linux__
#include <sys/syscall.h>
#endif
#include "absl/log/check.h"
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@ -38,7 +40,8 @@ static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
if (sizeof(time_t) < sizeof(int64_t)) {
// fine to assert, as this is only used in gpr_sleep_until
GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN);
CHECK(gts.tv_sec <= INT32_MAX);
CHECK(gts.tv_sec >= INT32_MIN);
}
rv.tv_sec = static_cast<time_t>(gts.tv_sec);
rv.tv_nsec = gts.tv_nsec;
@ -67,7 +70,7 @@ void gpr_time_init(void) { gpr_precise_clock_init(); }
static gpr_timespec now_impl(gpr_clock_type clock_type) {
struct timespec now;
GPR_ASSERT(clock_type != GPR_TIMESPAN);
CHECK(clock_type != GPR_TIMESPAN);
if (clock_type == GPR_CLOCK_PRECISE) {
gpr_timespec ret;
gpr_precise_clock_now(&ret);
@ -87,12 +90,12 @@ gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl;
gpr_timespec gpr_now(gpr_clock_type clock_type) {
// validate clock type
GPR_ASSERT(clock_type == GPR_CLOCK_MONOTONIC ||
clock_type == GPR_CLOCK_REALTIME ||
clock_type == GPR_CLOCK_PRECISE);
CHECK(clock_type == GPR_CLOCK_MONOTONIC || clock_type == GPR_CLOCK_REALTIME ||
clock_type == GPR_CLOCK_PRECISE);
gpr_timespec ts = gpr_now_impl(clock_type);
// tv_nsecs must be in the range [0, 1e9).
GPR_ASSERT(ts.tv_nsec >= 0 && ts.tv_nsec < 1e9);
CHECK(ts.tv_nsec >= 0);
CHECK(ts.tv_nsec < 1e9);
return ts;
}

@ -25,6 +25,8 @@
#include <string.h>
#include <unistd.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@ -42,7 +44,7 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
if (tmp_filename != nullptr) *tmp_filename = nullptr;
gpr_asprintf(&filename_template, "/tmp/%s_XXXXXX", prefix);
GPR_ASSERT(filename_template != nullptr);
CHECK_NE(filename_template, nullptr);
fd = mkstemp(filename_template);
if (fd == -1) {

@ -28,6 +28,7 @@
#include <iostream>
#include "absl/log/check.h"
#include "absl/strings/substitute.h"
#include <grpc/support/alloc.h>
@ -81,8 +82,8 @@ gpr_subprocess* gpr_subprocess_create_with_envp(int argc, const char** argv,
int stdout_pipe[2];
int p0 = pipe(stdin_pipe);
int p1 = pipe(stdout_pipe);
GPR_ASSERT(p0 != -1);
GPR_ASSERT(p1 != -1);
CHECK_NE(p0, -1);
CHECK_NE(p1, -1);
pid = fork();
if (pid == -1) {
return nullptr;
@ -145,7 +146,7 @@ bool gpr_subprocess_communicate(gpr_subprocess* p, std::string& input_data,
continue;
} else {
std::cerr << "select: " << strerror(errno) << std::endl;
GPR_ASSERT(0);
CHECK(0);
}
}
@ -192,7 +193,7 @@ bool gpr_subprocess_communicate(gpr_subprocess* p, std::string& input_data,
while (waitpid(p->pid, &status, 0) == -1) {
if (errno != EINTR) {
std::cerr << "waitpid: " << strerror(errno) << std::endl;
GPR_ASSERT(0);
CHECK(0);
}
}

@ -22,6 +22,8 @@
#include <assert.h>
#include "absl/log/check.h"
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@ -59,11 +61,11 @@ void gpr_event_init(gpr_event* ev) {
void gpr_event_set(gpr_event* ev, void* value) {
struct sync_array_s* s = hash(ev);
gpr_mu_lock(&s->mu);
GPR_ASSERT(gpr_atm_acq_load(&ev->state) == 0);
CHECK_EQ(gpr_atm_acq_load(&ev->state), 0);
gpr_atm_rel_store(&ev->state, (gpr_atm)value);
gpr_cv_broadcast(&s->cv);
gpr_mu_unlock(&s->mu);
GPR_ASSERT(value != nullptr);
CHECK_NE(value, nullptr);
}
void* gpr_event_get(gpr_event* ev) {
@ -102,7 +104,7 @@ void gpr_refn(gpr_refcount* r, int n) {
int gpr_unref(gpr_refcount* r) {
gpr_atm prior = gpr_atm_full_fetch_add(&r->count, -1);
GPR_ASSERT(prior > 0);
CHECK_GT(prior, 0);
return prior == 1;
}

@ -24,6 +24,8 @@
#include <stdio.h>
#include <string.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@ -31,7 +33,7 @@
int gpr_time_cmp(gpr_timespec a, gpr_timespec b) {
int cmp = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
GPR_ASSERT(a.clock_type == b.clock_type);
CHECK(a.clock_type == b.clock_type);
if (cmp == 0 && a.tv_sec != INT64_MAX && a.tv_sec != INT64_MIN) {
cmp = (a.tv_nsec > b.tv_nsec) - (a.tv_nsec < b.tv_nsec);
}
@ -79,7 +81,7 @@ static gpr_timespec to_seconds_from_sub_second_time(int64_t time_in_units,
} else if (time_in_units == INT64_MIN) {
out = gpr_inf_past(type);
} else {
GPR_DEBUG_ASSERT(GPR_NS_PER_SEC % units_per_sec == 0);
DCHECK_EQ(GPR_NS_PER_SEC % units_per_sec, 0);
out.tv_sec = time_in_units / units_per_sec;
out.tv_nsec =
@ -139,11 +141,11 @@ gpr_timespec gpr_time_from_hours(int64_t h, gpr_clock_type clock_type) {
gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) {
gpr_timespec sum;
int64_t inc = 0;
GPR_ASSERT(b.clock_type == GPR_TIMESPAN);
CHECK(b.clock_type == GPR_TIMESPAN);
// tv_nsec in a timespan is always +ve. -ve timespan is represented as (-ve
// tv_sec, +ve tv_nsec). For example, timespan = -2.5 seconds is represented
// as {-3, 5e8, GPR_TIMESPAN}
GPR_ASSERT(b.tv_nsec >= 0);
CHECK_GE(b.tv_nsec, 0);
sum.clock_type = a.clock_type;
sum.tv_nsec = a.tv_nsec + b.tv_nsec;
if (sum.tv_nsec >= GPR_NS_PER_SEC) {
@ -177,9 +179,9 @@ gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b) {
// tv_nsec in a timespan is always +ve. -ve timespan is represented as (-ve
// tv_sec, +ve tv_nsec). For example, timespan = -2.5 seconds is represented
// as {-3, 5e8, GPR_TIMESPAN}
GPR_ASSERT(b.tv_nsec >= 0);
CHECK_GE(b.tv_nsec, 0);
} else {
GPR_ASSERT(a.clock_type == b.clock_type);
CHECK(a.clock_type == b.clock_type);
diff.clock_type = GPR_TIMESPAN;
}
diff.tv_nsec = a.tv_nsec - b.tv_nsec;
@ -210,8 +212,8 @@ gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b) {
int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) {
int cmp_ab;
GPR_ASSERT(a.clock_type == b.clock_type);
GPR_ASSERT(threshold.clock_type == GPR_TIMESPAN);
CHECK(a.clock_type == b.clock_type);
CHECK(threshold.clock_type == GPR_TIMESPAN);
cmp_ab = gpr_time_cmp(a, b);
if (cmp_ab == 0) return 1;

@ -23,6 +23,8 @@
#if defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \
!defined(GPR_CUSTOM_SYNC)
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -38,7 +40,7 @@ void gpr_mu_destroy(gpr_mu* mu) { DeleteCriticalSection(&mu->cs); }
void gpr_mu_lock(gpr_mu* mu) {
EnterCriticalSection(&mu->cs);
GPR_ASSERT(!mu->locked);
CHECK(!mu->locked);
mu->locked = 1;
}

@ -26,6 +26,8 @@
#include <process.h>
#include <sys/timeb.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@ -97,7 +99,8 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
sleep_millis =
delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
GPR_ASSERT((sleep_millis >= 0) && (sleep_millis <= INT_MAX));
CHECK_GE(sleep_millis, 0);
CHECK_LE(sleep_millis, INT_MAX);
Sleep((DWORD)sleep_millis);
}
}

@ -19,6 +19,8 @@
#include <iterator>
#include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -86,9 +88,9 @@ class ChunkedVector {
// Remove the last element and return it.
T PopBack() {
GPR_ASSERT(append_ != nullptr);
CHECK_NE(append_, nullptr);
if (append_->count == 0) {
GPR_ASSERT(first_ != append_);
CHECK(first_ != append_);
Chunk* chunk = first_;
while (chunk->next != append_) {
chunk = chunk->next;
@ -234,7 +236,7 @@ class ChunkedVector {
private:
ManualConstructor<T>* AppendSlot() {
if (append_ == nullptr) {
GPR_ASSERT(first_ == nullptr);
CHECK_EQ(first_, nullptr);
first_ = arena_->New<Chunk>();
append_ = first_;
} else if (append_->count == kChunkSize) {

@ -18,6 +18,7 @@
#include <type_traits>
#include "absl/base/config.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -32,7 +33,7 @@ inline To DownCast(From* f) {
// If we have RTTI & we're in debug, assert that the cast is legal.
#if ABSL_INTERNAL_HAS_RTTI
#ifndef NDEBUG
if (f != nullptr) GPR_ASSERT(dynamic_cast<To>(f) != nullptr);
if (f != nullptr) CHECK_NE(dynamic_cast<To>(f), nullptr);
#endif
#endif
return static_cast<To>(f);

@ -20,6 +20,8 @@
#include <atomic>
#include <cstdint>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -92,7 +94,7 @@ class DualRefCounted {
gpr_log(GPR_INFO, "%s:%p unref %d -> %d, weak_ref %d -> %d", trace_, this,
strong_refs, strong_refs - 1, weak_refs, weak_refs + 1);
}
GPR_ASSERT(strong_refs > 0);
CHECK_GT(strong_refs, 0u);
#endif
if (GPR_UNLIKELY(strong_refs == 1)) {
Orphaned();
@ -111,7 +113,7 @@ class DualRefCounted {
trace_, this, location.file(), location.line(), strong_refs,
strong_refs - 1, weak_refs, weak_refs + 1, reason);
}
GPR_ASSERT(strong_refs > 0);
CHECK_GT(strong_refs, 0u);
#else
// Avoid unused-parameter warnings for debug-only parameters
(void)location;
@ -210,7 +212,7 @@ class DualRefCounted {
gpr_log(GPR_INFO, "%s:%p weak_unref %d -> %d (refs=%d)", trace, this,
weak_refs, weak_refs - 1, strong_refs);
}
GPR_ASSERT(weak_refs > 0);
CHECK_GT(weak_refs, 0u);
#endif
if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
delete static_cast<Child*>(this);
@ -233,7 +235,7 @@ class DualRefCounted {
this, location.file(), location.line(), weak_refs, weak_refs - 1,
strong_refs, reason);
}
GPR_ASSERT(weak_refs > 0);
CHECK_GT(weak_refs, 0u);
#else
// Avoid unused-parameter warnings for debug-only parameters
(void)location;
@ -289,7 +291,7 @@ class DualRefCounted {
refs_.fetch_add(MakeRefPair(1, 0), std::memory_order_relaxed);
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
GPR_ASSERT(strong_refs != 0);
CHECK_NE(strong_refs, 0u);
if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p ref %d -> %d; (weak_refs=%d)", trace_, this,
strong_refs, strong_refs + 1, weak_refs);
@ -304,7 +306,7 @@ class DualRefCounted {
refs_.fetch_add(MakeRefPair(1, 0), std::memory_order_relaxed);
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
GPR_ASSERT(strong_refs != 0);
CHECK_NE(strong_refs, 0u);
if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d ref %d -> %d (weak_refs=%d) %s", trace_,
this, location.file(), location.line(), strong_refs,

@ -20,6 +20,7 @@
#include <stddef.h>
#include "absl/log/check.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
@ -92,8 +93,10 @@ bool SplitHostPort(absl::string_view name, absl::string_view* host,
bool SplitHostPort(absl::string_view name, std::string* host,
std::string* port) {
GPR_DEBUG_ASSERT(host != nullptr && host->empty());
GPR_DEBUG_ASSERT(port != nullptr && port->empty());
DCHECK(host != nullptr);
DCHECK(host->empty());
DCHECK(port != nullptr);
DCHECK(port->empty());
absl::string_view host_view;
absl::string_view port_view;
bool has_port;

@ -21,6 +21,8 @@
#include <atomic>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -40,8 +42,8 @@ class MultiProducerSingleConsumerQueue {
MultiProducerSingleConsumerQueue() : head_{&stub_}, tail_(&stub_) {}
~MultiProducerSingleConsumerQueue() {
GPR_ASSERT(head_.load(std::memory_order_relaxed) == &stub_);
GPR_ASSERT(tail_ == &stub_);
CHECK(head_.load(std::memory_order_relaxed) == &stub_);
CHECK(tail_ == &stub_);
}
// Push a node

@ -27,6 +27,8 @@
#include <errno.h>
#include <sys/stat.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/stat.h"
@ -35,8 +37,8 @@
namespace grpc_core {
absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
GPR_ASSERT(filename != nullptr);
GPR_ASSERT(timestamp != nullptr);
CHECK_NE(filename, nullptr);
CHECK_NE(timestamp, nullptr);
struct stat buf;
if (stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno);

@ -32,6 +32,8 @@
#include <string.h>
#include <unistd.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd_id.h>
@ -88,7 +90,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
// don't use gpr_malloc as we may cause an infinite recursion with
// the profiling code
thd_arg* info = static_cast<thd_arg*>(malloc(sizeof(*info)));
GPR_ASSERT(info != nullptr);
CHECK_NE(info, nullptr);
info->thread = this;
info->body = thd_body;
info->arg = arg;
@ -99,18 +101,16 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
Fork::IncThreadCount();
}
GPR_ASSERT(pthread_attr_init(&attr) == 0);
CHECK_EQ(pthread_attr_init(&attr), 0);
if (options.joinable()) {
GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ==
0);
CHECK(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) == 0);
} else {
GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) ==
0);
CHECK(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0);
}
if (options.stack_size() != 0) {
size_t stack_size = MinValidStackSize(options.stack_size());
GPR_ASSERT(pthread_attr_setstacksize(&attr, stack_size) == 0);
CHECK_EQ(pthread_attr_setstacksize(&attr, stack_size), 0);
}
int pthread_create_err = pthread_create(
@ -154,7 +154,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
info);
*success = (pthread_create_err == 0);
GPR_ASSERT(pthread_attr_destroy(&attr) == 0);
CHECK_EQ(pthread_attr_destroy(&attr), 0);
if (!(*success)) {
gpr_log(GPR_ERROR, "pthread_create failed: %s",

@ -23,6 +23,8 @@
#include <cassert>
#include <cinttypes>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -164,7 +166,7 @@ class RefCount {
gpr_log(GPR_INFO, "%s:%p unref %" PRIdPTR " -> %" PRIdPTR, trace, this,
prior, prior - 1);
}
GPR_DEBUG_ASSERT(prior > 0);
DCHECK_GT(prior, 0);
#endif
return prior == 1;
}
@ -182,7 +184,7 @@ class RefCount {
trace, this, location.file(), location.line(), prior, prior - 1,
reason);
}
GPR_DEBUG_ASSERT(prior > 0);
DCHECK_GT(prior, 0);
#else
// Avoid unused-parameter warnings for debug-only parameters
(void)location;

@ -18,6 +18,8 @@
#include <atomic>
#include <memory>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -67,7 +69,7 @@ class SingleSetPtr {
T* operator->() const {
T* p = p_.load(std::memory_order_acquire);
GPR_DEBUG_ASSERT(p != nullptr);
DCHECK_NE(p, nullptr);
return p;
}

@ -22,6 +22,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/strings/cord.h"
#include "absl/strings/escaping.h"
#include "absl/strings/match.h"
@ -153,7 +154,7 @@ std::vector<absl::Status> ParseChildren(absl::Cord children) {
while (buf.size() - cur >= sizeof(uint32_t)) {
size_t msg_size = DecodeUInt32FromBytes(buf.data() + cur);
cur += sizeof(uint32_t);
GPR_ASSERT(buf.size() - cur >= msg_size);
CHECK(buf.size() - cur >= msg_size);
google_rpc_Status* msg =
google_rpc_Status_parse(buf.data() + cur, msg_size, arena.ptr());
cur += msg_size;

@ -20,6 +20,7 @@
#define GRPC_SRC_CORE_LIB_GPRPP_SYNC_H
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/synchronization/mutex.h"
#include <grpc/support/log.h>
@ -112,7 +113,7 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete;
void Release() ABSL_UNLOCK_FUNCTION() {
GPR_DEBUG_ASSERT(!released_);
DCHECK(!released_);
released_ = true;
mu_->Unlock();
}
@ -178,13 +179,13 @@ class ABSL_SCOPED_LOCKABLE LockableAndReleasableMutexLock {
const LockableAndReleasableMutexLock&) = delete;
void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION() {
GPR_DEBUG_ASSERT(released_);
DCHECK(released_);
mu_->Lock();
released_ = false;
}
void Release() ABSL_UNLOCK_FUNCTION() {
GPR_DEBUG_ASSERT(!released_);
DCHECK(!released_);
released_ = true;
mu_->Unlock();
}

@ -27,6 +27,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -124,7 +125,7 @@ class Thread {
Thread& operator=(Thread&& other) noexcept {
if (this != &other) {
// TODO(vjpai): if we can be sure that all Thread's are actually
// constructed, then we should assert GPR_ASSERT(impl_ == nullptr) here.
// constructed, then we should assert CHECK(impl_ == nullptr) here.
// However, as long as threads come in structures that are
// allocated via gpr_malloc, this will not be the case, so we cannot
// assert it for the time being.
@ -143,11 +144,11 @@ class Thread {
/// the Join function kills it, or it was detached (non-joinable) and it has
/// run to completion and is now killing itself. The destructor shouldn't have
/// to do anything.
~Thread() { GPR_ASSERT(!options_.joinable() || impl_ == nullptr); }
~Thread() { CHECK(!options_.joinable() || impl_ == nullptr); }
void Start() {
if (impl_ != nullptr) {
GPR_ASSERT(state_ == ALIVE);
CHECK(state_ == ALIVE);
state_ = STARTED;
impl_->Start();
// If the Thread is not joinable, then the impl_ will cause the deletion
@ -156,7 +157,7 @@ class Thread {
// no need to change the value of the impl_ or state_ . The next operation
// on this object will be the deletion, which will trigger the destructor.
} else {
GPR_ASSERT(state_ == FAILED);
CHECK(state_ == FAILED);
}
}
@ -168,7 +169,7 @@ class Thread {
state_ = DONE;
impl_ = nullptr;
} else {
GPR_ASSERT(state_ == FAILED);
CHECK(state_ == FAILED);
}
}

@ -20,6 +20,7 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
@ -66,13 +67,13 @@ GPR_ATTRIBUTE_NOINLINE std::pair<int64_t, gpr_cycle_counter> InitTime() {
}
// Check time has increased past 1 second.
GPR_ASSERT(process_epoch_seconds > 1);
CHECK_GT(process_epoch_seconds, 1);
// Fake the epoch to always return >=1 second from our monotonic clock (to
// avoid bugs elsewhere)
process_epoch_seconds -= 1;
int64_t expected = 0;
gpr_cycle_counter process_epoch_cycles = (cycles_start + cycles_end) / 2;
GPR_ASSERT(process_epoch_cycles != 0);
CHECK_NE(process_epoch_cycles, 0);
if (!g_process_epoch_seconds.compare_exchange_strong(
expected, process_epoch_seconds, std::memory_order_relaxed,
std::memory_order_relaxed)) {
@ -119,7 +120,7 @@ gpr_timespec MillisecondsAsTimespec(int64_t millis, gpr_clock_type clock_type) {
}
int64_t TimespanToMillisRoundUp(gpr_timespec ts) {
GPR_ASSERT(ts.clock_type == GPR_TIMESPAN);
CHECK(ts.clock_type == GPR_TIMESPAN);
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS +
static_cast<double>(GPR_NS_PER_SEC - 1) /
@ -134,7 +135,7 @@ int64_t TimespanToMillisRoundUp(gpr_timespec ts) {
}
int64_t TimespanToMillisRoundDown(gpr_timespec ts) {
GPR_ASSERT(ts.clock_type == GPR_TIMESPAN);
CHECK(ts.clock_type == GPR_TIMESPAN);
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS;
if (x <= static_cast<double>(std::numeric_limits<int64_t>::min())) {

@ -19,6 +19,8 @@
#include <stdint.h>
#include <time.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -54,7 +56,7 @@ gpr_timespec ToGprTimeSpec(absl::Time time) {
}
absl::Duration ToAbslDuration(gpr_timespec ts) {
GPR_ASSERT(ts.clock_type == GPR_TIMESPAN);
CHECK(ts.clock_type == GPR_TIMESPAN);
if (gpr_time_cmp(ts, gpr_inf_future(GPR_TIMESPAN)) == 0) {
return absl::InfiniteDuration();
} else if (gpr_time_cmp(ts, gpr_inf_past(GPR_TIMESPAN)) == 0) {
@ -65,7 +67,7 @@ absl::Duration ToAbslDuration(gpr_timespec ts) {
}
absl::Time ToAbslTime(gpr_timespec ts) {
GPR_ASSERT(ts.clock_type != GPR_TIMESPAN);
CHECK(ts.clock_type != GPR_TIMESPAN);
gpr_timespec rts = gpr_convert_clock_type(ts, GPR_CLOCK_REALTIME);
if (gpr_time_cmp(rts, gpr_inf_future(GPR_CLOCK_REALTIME)) == 0) {
return absl::InfiniteFuture();

@ -22,6 +22,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
@ -31,8 +33,8 @@
namespace grpc_core {
absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
GPR_ASSERT(filename != nullptr);
GPR_ASSERT(timestamp != nullptr);
CHECK_NE(filename, nullptr);
CHECK_NE(timestamp, nullptr);
struct _stat buf;
if (_stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno);

@ -23,6 +23,8 @@
#include <string.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@ -101,7 +103,7 @@ class ThreadInternalsWindows
void Join() override {
DWORD ret = WaitForSingleObject(info_->join_event, INFINITE);
GPR_ASSERT(ret == WAIT_OBJECT_0);
CHECK(ret == WAIT_OBJECT_0);
destroy_thread();
}
@ -121,7 +123,7 @@ class ThreadInternalsWindows
g_thd_info->body(g_thd_info->arg);
if (g_thd_info->joinable) {
BOOL ret = SetEvent(g_thd_info->join_event);
GPR_ASSERT(ret);
CHECK(ret);
} else {
gpr_free(g_thd_info);
}

@ -27,6 +27,7 @@
#include <utility>
#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
@ -107,7 +108,7 @@ class WorkSerializer::LegacyWorkSerializer final : public WorkSerializerImpl {
// First 16 bits indicate ownership of the WorkSerializer, next 48 bits are
// queue size (i.e., refs).
static uint64_t MakeRefPair(uint16_t owners, uint64_t size) {
GPR_ASSERT(size >> 48 == 0);
CHECK_EQ(size >> 48, 0u);
return (static_cast<uint64_t>(owners) << 48) + static_cast<int64_t>(size);
}
static uint32_t GetOwners(uint64_t ref_pair) {
@ -145,7 +146,7 @@ void WorkSerializer::LegacyWorkSerializer::Run(std::function<void()> callback,
const uint64_t prev_ref_pair =
refs_.fetch_add(MakeRefPair(1, 1), std::memory_order_acq_rel);
// The work serializer should not have been orphaned.
GPR_DEBUG_ASSERT(GetSize(prev_ref_pair) > 0);
DCHECK_GT(GetSize(prev_ref_pair), 0u);
if (GetOwners(prev_ref_pair) == 0) {
// We took ownership of the WorkSerializer. Invoke callback and drain queue.
SetCurrentThread();
@ -424,7 +425,7 @@ void WorkSerializer::DispatchingWorkSerializer::Run(
running_start_time_ = std::chrono::steady_clock::now();
items_processed_during_run_ = 0;
time_running_items_ = std::chrono::steady_clock::duration();
GPR_ASSERT(processing_.empty());
CHECK(processing_.empty());
processing_.emplace_back(std::move(callback), location);
event_engine_->Run(this);
} else {

@ -24,6 +24,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"

@ -109,6 +109,7 @@ grpc_cc_library(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
],
language = "C++",
deps = [

@ -27,6 +27,7 @@
#include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/match.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
@ -205,11 +206,10 @@ bool InteropClient::AssertStatusCode(const Status& s, StatusCode expected_code,
return true;
}
gpr_log(GPR_ERROR,
"Error status code: %d (expected: %d), message: %s,"
" debug string: %s",
s.error_code(), expected_code, s.error_message().c_str(),
optional_debug_string.c_str());
LOG(ERROR) << "Error status code: " << s.error_code()
<< " (expected: " << expected_code
<< "), message: " << s.error_message()
<< ", debug string: " << optional_debug_string;
// In case of transient transient/retryable failures (like a broken
// connection) we may or may not abort (see TransientFailureOrAbort())
@ -221,7 +221,7 @@ bool InteropClient::AssertStatusCode(const Status& s, StatusCode expected_code,
}
bool InteropClient::DoEmpty() {
gpr_log(GPR_DEBUG, "Sending an empty rpc...");
VLOG(2) << "Sending an empty rpc...";
Empty request;
Empty response;
@ -233,7 +233,7 @@ bool InteropClient::DoEmpty() {
return false;
}
gpr_log(GPR_DEBUG, "Empty rpc done.");
VLOG(2) << "Empty rpc done.";
return true;
}
@ -273,8 +273,7 @@ bool InteropClient::PerformLargeUnary(SimpleRequest* request,
bool InteropClient::DoComputeEngineCreds(
const std::string& default_service_account,
const std::string& oauth_scope) {
gpr_log(GPR_DEBUG,
"Sending a large unary rpc with compute engine credentials ...");
VLOG(2) << "Sending a large unary rpc with compute engine credentials ...";
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
@ -284,21 +283,20 @@ bool InteropClient::DoComputeEngineCreds(
return false;
}
gpr_log(GPR_DEBUG, "Got username %s", response.username().c_str());
gpr_log(GPR_DEBUG, "Got oauth_scope %s", response.oauth_scope().c_str());
VLOG(2) << "Got username " << response.username();
VLOG(2) << "Got oauth_scope " << response.oauth_scope();
CHECK(!response.username().empty());
CHECK(response.username() == default_service_account);
CHECK(!response.oauth_scope().empty());
const char* oauth_scope_str = response.oauth_scope().c_str();
CHECK(absl::StrContains(oauth_scope, oauth_scope_str));
gpr_log(GPR_DEBUG, "Large unary with compute engine creds done.");
VLOG(2) << "Large unary with compute engine creds done.";
return true;
}
bool InteropClient::DoOauth2AuthToken(const std::string& username,
const std::string& oauth_scope) {
gpr_log(GPR_DEBUG,
"Sending a unary rpc with raw oauth2 access token credentials ...");
VLOG(2) << "Sending a unary rpc with raw oauth2 access token credentials ...";
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
@ -317,12 +315,12 @@ bool InteropClient::DoOauth2AuthToken(const std::string& username,
CHECK(username == response.username());
const char* oauth_scope_str = response.oauth_scope().c_str();
CHECK(absl::StrContains(oauth_scope, oauth_scope_str));
gpr_log(GPR_DEBUG, "Unary with oauth2 access token credentials done.");
VLOG(2) << "Unary with oauth2 access token credentials done.";
return true;
}
bool InteropClient::DoPerRpcCreds(const std::string& json_key) {
gpr_log(GPR_DEBUG, "Sending a unary rpc with per-rpc JWT access token ...");
VLOG(2) << "Sending a unary rpc with per-rpc JWT access token ...";
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
@ -342,13 +340,12 @@ bool InteropClient::DoPerRpcCreds(const std::string& json_key) {
CHECK(!response.username().empty());
CHECK(json_key.find(response.username()) != std::string::npos);
gpr_log(GPR_DEBUG, "Unary with per-rpc JWT access token done.");
VLOG(2) << "Unary with per-rpc JWT access token done.";
return true;
}
bool InteropClient::DoJwtTokenCreds(const std::string& username) {
gpr_log(GPR_DEBUG,
"Sending a large unary rpc with JWT token credentials ...");
VLOG(2) << "Sending a large unary rpc with JWT token credentials ...";
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
@ -359,14 +356,13 @@ bool InteropClient::DoJwtTokenCreds(const std::string& username) {
CHECK(!response.username().empty());
CHECK(username.find(response.username()) != std::string::npos);
gpr_log(GPR_DEBUG, "Large unary with JWT token creds done.");
VLOG(2) << "Large unary with JWT token creds done.";
return true;
}
bool InteropClient::DoGoogleDefaultCredentials(
const std::string& default_service_account) {
gpr_log(GPR_DEBUG,
"Sending a large unary rpc with GoogleDefaultCredentials...");
VLOG(2) << "Sending a large unary rpc with GoogleDefaultCredentials...";
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
@ -375,21 +371,21 @@ bool InteropClient::DoGoogleDefaultCredentials(
return false;
}
gpr_log(GPR_DEBUG, "Got username %s", response.username().c_str());
VLOG(2) << "Got username " << response.username();
CHECK(!response.username().empty());
CHECK(response.username() == default_service_account);
gpr_log(GPR_DEBUG, "Large unary rpc with GoogleDefaultCredentials done.");
VLOG(2) << "Large unary rpc with GoogleDefaultCredentials done.";
return true;
}
bool InteropClient::DoLargeUnary() {
gpr_log(GPR_DEBUG, "Sending a large unary rpc...");
VLOG(2) << "Sending a large unary rpc...";
SimpleRequest request;
SimpleResponse response;
if (!PerformLargeUnary(&request, &response)) {
return false;
}
gpr_log(GPR_DEBUG, "Large unary done.");
VLOG(2) << "Large unary done.";
return true;
}
@ -405,35 +401,32 @@ bool InteropClient::DoClientCompressedUnary() {
probe_req.set_response_size(kLargeResponseSize);
probe_req.mutable_payload()->set_body(std::string(kLargeRequestSize, '\0'));
gpr_log(GPR_DEBUG, "Sending probe for compressed unary request.");
VLOG(2) << "Sending probe for compressed unary request.";
const Status s =
serviceStub_.Get()->UnaryCall(&probe_context, probe_req, &probe_res);
if (s.error_code() != grpc::StatusCode::INVALID_ARGUMENT) {
// The server isn't able to evaluate incoming compression, making the rest
// of this test moot.
gpr_log(GPR_DEBUG, "Compressed unary request probe failed");
VLOG(2) << "Compressed unary request probe failed";
return false;
}
gpr_log(GPR_DEBUG, "Compressed unary request probe succeeded. Proceeding.");
VLOG(2) << "Compressed unary request probe succeeded. Proceeding.";
const std::vector<bool> compressions = {true, false};
for (size_t i = 0; i < compressions.size(); i++) {
std::string log_suffix =
absl::StrFormat("(compression=%s)", compressions[i] ? "true" : "false");
gpr_log(GPR_DEBUG, "Sending compressed unary request %s.",
log_suffix.c_str());
VLOG(2) << "Sending compressed unary request " << log_suffix;
SimpleRequest request;
SimpleResponse response;
request.mutable_expect_compressed()->set_value(compressions[i]);
if (!PerformLargeUnary(&request, &response, UnaryCompressionChecks)) {
gpr_log(GPR_ERROR, "Compressed unary request failed %s",
log_suffix.c_str());
LOG(ERROR) << "Compressed unary request failed " << log_suffix;
return false;
}
gpr_log(GPR_DEBUG, "Compressed unary request failed %s",
log_suffix.c_str());
VLOG(2) << "Compressed unary request failed " << log_suffix;
}
return true;
@ -445,20 +438,17 @@ bool InteropClient::DoServerCompressedUnary() {
std::string log_suffix =
absl::StrFormat("(compression=%s)", compressions[i] ? "true" : "false");
gpr_log(GPR_DEBUG, "Sending unary request for compressed response %s.",
log_suffix.c_str());
VLOG(2) << "Sending unary request for compressed response " << log_suffix;
SimpleRequest request;
SimpleResponse response;
request.mutable_response_compressed()->set_value(compressions[i]);
if (!PerformLargeUnary(&request, &response, UnaryCompressionChecks)) {
gpr_log(GPR_ERROR, "Request for compressed unary failed %s",
log_suffix.c_str());
LOG(ERROR) << "Request for compressed unary failed " << log_suffix;
return false;
}
gpr_log(GPR_DEBUG, "Request for compressed unary failed %s",
log_suffix.c_str());
VLOG(2) << "Request for compressed unary failed " << log_suffix;
}
return true;
@ -475,7 +465,7 @@ bool InteropClient::TransientFailureOrAbort() {
}
bool InteropClient::DoRequestStreaming() {
gpr_log(GPR_DEBUG, "Sending request steaming rpc ...");
VLOG(2) << "Sending request steaming rpc ...";
ClientContext context;
StreamingInputCallRequest request;
@ -489,7 +479,7 @@ bool InteropClient::DoRequestStreaming() {
Payload* payload = request.mutable_payload();
payload->set_body(std::string(request_stream_sizes[i], '\0'));
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoRequestStreaming(): stream->Write() failed");
LOG(ERROR) << "DoRequestStreaming(): stream->Write() failed.";
return TransientFailureOrAbort();
}
aggregated_payload_size += request_stream_sizes[i];
@ -506,7 +496,7 @@ bool InteropClient::DoRequestStreaming() {
}
bool InteropClient::DoResponseStreaming() {
gpr_log(GPR_DEBUG, "Receiving response streaming rpc ...");
VLOG(2) << "Receiving response streaming rpc ...";
ClientContext context;
StreamingOutputCallRequest request;
@ -528,10 +518,9 @@ bool InteropClient::DoResponseStreaming() {
if (i < response_stream_sizes.size()) {
// stream->Read() failed before reading all the expected messages. This is
// most likely due to connection failure.
gpr_log(GPR_ERROR,
"DoResponseStreaming(): Read fewer streams (%d) than "
"response_stream_sizes.size() (%" PRIuPTR ")",
i, response_stream_sizes.size());
LOG(ERROR) << "DoResponseStreaming(): Read fewer streams (" << i
<< ") than response_stream_sizes.size() ("
<< response_stream_sizes.size() << ")";
return TransientFailureOrAbort();
}
@ -540,7 +529,7 @@ bool InteropClient::DoResponseStreaming() {
return false;
}
gpr_log(GPR_DEBUG, "Response streaming done.");
VLOG(2) << "Response streaming done.";
return true;
}
@ -554,24 +543,23 @@ bool InteropClient::DoClientCompressedStreaming() {
probe_req.mutable_expect_compressed()->set_value(true); // lies!
probe_req.mutable_payload()->set_body(std::string(27182, '\0'));
gpr_log(GPR_DEBUG, "Sending probe for compressed streaming request.");
VLOG(2) << "Sending probe for compressed streaming request.";
std::unique_ptr<ClientWriter<StreamingInputCallRequest>> probe_stream(
serviceStub_.Get()->StreamingInputCall(&probe_context, &probe_res));
if (!probe_stream->Write(probe_req)) {
gpr_log(GPR_ERROR, "%s(): stream->Write() failed", __func__);
LOG(ERROR) << __func__ << "(): stream->Write() failed";
return TransientFailureOrAbort();
}
Status s = probe_stream->Finish();
if (s.error_code() != grpc::StatusCode::INVALID_ARGUMENT) {
// The server isn't able to evaluate incoming compression, making the rest
// of this test moot.
gpr_log(GPR_DEBUG, "Compressed streaming request probe failed");
VLOG(2) << "Compressed streaming request probe failed";
return false;
}
gpr_log(GPR_DEBUG,
"Compressed streaming request probe succeeded. Proceeding.");
VLOG(2) << "Compressed streaming request probe succeeded. Proceeding.";
ClientContext context;
StreamingInputCallRequest request;
@ -583,9 +571,9 @@ bool InteropClient::DoClientCompressedStreaming() {
request.mutable_payload()->set_body(std::string(27182, '\0'));
request.mutable_expect_compressed()->set_value(true);
gpr_log(GPR_DEBUG, "Sending streaming request with compression enabled");
VLOG(2) << "Sending streaming request with compression enabled";
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "%s(): stream->Write() failed", __func__);
LOG(ERROR) << __func__ << "(): stream->Write() failed.";
return TransientFailureOrAbort();
}
@ -593,9 +581,9 @@ bool InteropClient::DoClientCompressedStreaming() {
wopts.set_no_compression();
request.mutable_payload()->set_body(std::string(45904, '\0'));
request.mutable_expect_compressed()->set_value(false);
gpr_log(GPR_DEBUG, "Sending streaming request with compression disabled");
VLOG(2) << "Sending streaming request with compression disabled";
if (!stream->Write(request, wopts)) {
gpr_log(GPR_ERROR, "%s(): stream->Write() failed", __func__);
LOG(ERROR) << __func__ << "(): stream->Write() failed";
return TransientFailureOrAbort();
}
CHECK(stream->WritesDone());
@ -618,7 +606,7 @@ bool InteropClient::DoServerCompressedStreaming() {
absl::StrFormat("(compression=%s; size=%d)",
compressions[i] ? "true" : "false", sizes[i]);
gpr_log(GPR_DEBUG, "Sending request streaming rpc %s.", log_suffix.c_str());
VLOG(2) << "Sending request streaming rpc " << log_suffix.c_str();
ResponseParameters* const response_parameter =
request.add_response_parameters();
@ -650,10 +638,9 @@ bool InteropClient::DoServerCompressedStreaming() {
if (k < sizes.size()) {
// stream->Read() failed before reading all the expected messages. This
// is most likely due to a connection failure.
gpr_log(GPR_ERROR,
"%s(): Responses read (k=%" PRIuPTR
") is less than the expected number of messages (%" PRIuPTR ").",
__func__, k, sizes.size());
LOG(ERROR) << __func__ << "(): Responses read (k=" << k
<< ") is less than the expected number of messages ("
<< sizes.size() << ").";
return TransientFailureOrAbort();
}
@ -662,7 +649,7 @@ bool InteropClient::DoServerCompressedStreaming() {
}
bool InteropClient::DoResponseStreamingWithSlowConsumer() {
gpr_log(GPR_DEBUG, "Receiving response streaming rpc with slow consumer ...");
VLOG(2) << "Receiving response streaming rpc with slow consumer ...";
ClientContext context;
StreamingOutputCallRequest request;
@ -678,7 +665,7 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() {
int i = 0;
while (stream->Read(&response)) {
CHECK(response.payload().body() == std::string(kResponseMessageSize, '\0'));
gpr_log(GPR_DEBUG, "received message %d", i);
VLOG(2) << "received message " << i;
gpr_sleep_until(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(kReceiveDelayMilliSeconds, GPR_TIMESPAN)));
@ -686,10 +673,11 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() {
}
if (i < kNumResponseMessages) {
gpr_log(GPR_ERROR,
"DoResponseStreamingWithSlowConsumer(): Responses read (i=%d) is "
"less than the expected messages (i.e kNumResponseMessages = %d)",
i, kNumResponseMessages);
LOG(ERROR) << "DoResponseStreamingWithSlowConsumer(): Responses read (i="
<< i
<< ") is less than the expected messages (i.e "
"kNumResponseMessages = "
<< kNumResponseMessages << ").";
return TransientFailureOrAbort();
}
@ -699,12 +687,12 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() {
return false;
}
gpr_log(GPR_DEBUG, "Response streaming done.");
VLOG(2) << "Response streaming done.";
return true;
}
bool InteropClient::DoHalfDuplex() {
gpr_log(GPR_DEBUG, "Sending half-duplex streaming rpc ...");
VLOG(2) << "Sending half-duplex streaming rpc ...";
ClientContext context;
std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest,
@ -717,7 +705,7 @@ bool InteropClient::DoHalfDuplex() {
response_parameter->set_size(response_stream_sizes[i]);
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoHalfDuplex(): stream->Write() failed. i=%d", i);
LOG(ERROR) << "DoHalfDuplex(): stream->Write() failed. i=" << i;
return TransientFailureOrAbort();
}
}
@ -734,10 +722,10 @@ bool InteropClient::DoHalfDuplex() {
if (i < response_stream_sizes.size()) {
// stream->Read() failed before reading all the expected messages. This is
// most likely due to a connection failure
gpr_log(GPR_ERROR,
"DoHalfDuplex(): Responses read (i=%d) are less than the expected "
"number of messages response_stream_sizes.size() (%" PRIuPTR ")",
i, response_stream_sizes.size());
LOG(ERROR) << "DoHalfDuplex(): Responses read (i=" << i
<< ") are less than the expected number of messages "
"response_stream_sizes.size() ("
<< response_stream_sizes.size() << ").";
return TransientFailureOrAbort();
}
@ -746,12 +734,12 @@ bool InteropClient::DoHalfDuplex() {
return false;
}
gpr_log(GPR_DEBUG, "Half-duplex streaming rpc done.");
VLOG(2) << "Half-duplex streaming rpc done.";
return true;
}
bool InteropClient::DoPingPong() {
gpr_log(GPR_DEBUG, "Sending Ping Pong streaming rpc ...");
VLOG(2) << "Sending Ping Pong streaming rpc ...";
ClientContext context;
std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest,
@ -768,12 +756,12 @@ bool InteropClient::DoPingPong() {
payload->set_body(std::string(request_stream_sizes[i], '\0'));
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoPingPong(): stream->Write() failed. i: %d", i);
LOG(ERROR) << "DoPingPong(): stream->Write() failed. i: " << i;
return TransientFailureOrAbort();
}
if (!stream->Read(&response)) {
gpr_log(GPR_ERROR, "DoPingPong(): stream->Read() failed. i:%d", i);
LOG(ERROR) << "DoPingPong(): stream->Read() failed. i:" << i;
return TransientFailureOrAbort();
}
@ -790,12 +778,12 @@ bool InteropClient::DoPingPong() {
return false;
}
gpr_log(GPR_DEBUG, "Ping pong streaming done.");
VLOG(2) << "Ping pong streaming done.";
return true;
}
bool InteropClient::DoCancelAfterBegin() {
gpr_log(GPR_DEBUG, "Sending request streaming rpc ...");
VLOG(2) << "Sending request streaming rpc ...";
ClientContext context;
StreamingInputCallRequest request;
@ -804,7 +792,7 @@ bool InteropClient::DoCancelAfterBegin() {
std::unique_ptr<ClientWriter<StreamingInputCallRequest>> stream(
serviceStub_.Get()->StreamingInputCall(&context, &response));
gpr_log(GPR_DEBUG, "Trying to cancel...");
VLOG(2) << "Trying to cancel...";
context.TryCancel();
Status s = stream->Finish();
@ -813,12 +801,12 @@ bool InteropClient::DoCancelAfterBegin() {
return false;
}
gpr_log(GPR_DEBUG, "Canceling streaming done.");
VLOG(2) << "Canceling streaming done.";
return true;
}
bool InteropClient::DoCancelAfterFirstResponse() {
gpr_log(GPR_DEBUG, "Sending Ping Pong streaming rpc ...");
VLOG(2) << "Sending Ping Pong streaming rpc ...";
ClientContext context;
std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest,
@ -832,27 +820,26 @@ bool InteropClient::DoCancelAfterFirstResponse() {
StreamingOutputCallResponse response;
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoCancelAfterFirstResponse(): stream->Write() failed");
LOG(ERROR) << "DoCancelAfterFirstResponse(): stream->Write() failed";
return TransientFailureOrAbort();
}
if (!stream->Read(&response)) {
gpr_log(GPR_ERROR, "DoCancelAfterFirstResponse(): stream->Read failed");
LOG(ERROR) << "DoCancelAfterFirstResponse(): stream->Read failed";
return TransientFailureOrAbort();
}
CHECK(response.payload().body() == std::string(31415, '\0'));
gpr_log(GPR_DEBUG, "Trying to cancel...");
VLOG(2) << "Trying to cancel...";
context.TryCancel();
Status s = stream->Finish();
gpr_log(GPR_DEBUG, "Canceling pingpong streaming done.");
VLOG(2) << "Canceling pingpong streaming done.";
return true;
}
bool InteropClient::DoTimeoutOnSleepingServer() {
gpr_log(GPR_DEBUG,
"Sending Ping Pong streaming rpc with a short deadline...");
VLOG(2) << "Sending Ping Pong streaming rpc with a short deadline...";
ClientContext context;
std::chrono::system_clock::time_point deadline =
@ -872,12 +859,12 @@ bool InteropClient::DoTimeoutOnSleepingServer() {
return false;
}
gpr_log(GPR_DEBUG, "Pingpong streaming timeout done.");
VLOG(2) << "Pingpong streaming timeout done.";
return true;
}
bool InteropClient::DoEmptyStream() {
gpr_log(GPR_DEBUG, "Starting empty_stream.");
VLOG(2) << "Starting empty_stream.";
ClientContext context;
std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest,
@ -892,13 +879,12 @@ bool InteropClient::DoEmptyStream() {
return false;
}
gpr_log(GPR_DEBUG, "empty_stream done.");
VLOG(2) << "empty_stream done.";
return true;
}
bool InteropClient::DoStatusWithMessage() {
gpr_log(GPR_DEBUG,
"Sending RPC with a request for status code 2 and message");
VLOG(2) << "Sending RPC with a request for status code 2 and message";
const grpc::StatusCode test_code = grpc::StatusCode::UNKNOWN;
const std::string test_msg = "This is a test message";
@ -938,15 +924,14 @@ bool InteropClient::DoStatusWithMessage() {
}
CHECK(s.error_message() == test_msg);
gpr_log(GPR_DEBUG, "Done testing Status and Message");
VLOG(2) << "Done testing Status and Message";
return true;
}
bool InteropClient::DoSpecialStatusMessage() {
gpr_log(
GPR_DEBUG,
"Sending RPC with a request for status code 2 and message - \\t\\ntest "
"with whitespace\\r\\nand Unicode BMP ☺ and non-BMP 😈\\t\\n");
VLOG(2) << "Sending RPC with a request for status code 2 and message - "
"\\t\\ntest "
"with whitespace\\r\\nand Unicode BMP ☺ and non-BMP 😈\\t\\n";
const grpc::StatusCode test_code = grpc::StatusCode::UNKNOWN;
const std::string test_msg =
"\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n";
@ -962,7 +947,7 @@ bool InteropClient::DoSpecialStatusMessage() {
return false;
}
CHECK(s.error_message() == test_msg);
gpr_log(GPR_DEBUG, "Done testing Special Status Message");
VLOG(2) << "Done testing Special Status Message";
return true;
}
@ -983,19 +968,19 @@ bool InteropClient::DoPickFirstUnary() {
continue;
}
if (response.server_id() != server_id) {
gpr_log(GPR_ERROR, "#%d rpc hits server_id %s, expect server_id %s", i,
response.server_id().c_str(), server_id.c_str());
LOG(ERROR) << "#" << i << " rpc hits server_id " << response.server_id()
<< ", expect server_id " << server_id;
return false;
}
}
gpr_log(GPR_DEBUG, "pick first unary successfully finished");
VLOG(2) << "pick first unary successfully finished";
return true;
}
bool InteropClient::DoOrcaPerRpc() {
load_report_tracker_.ResetCollectedLoadReports();
grpc_core::CoreConfiguration::RegisterBuilder(RegisterBackendMetricsLbPolicy);
gpr_log(GPR_DEBUG, "testing orca per rpc");
VLOG(2) << "testing orca per rpc";
SimpleRequest request;
SimpleResponse response;
ClientContext context;
@ -1016,13 +1001,13 @@ bool InteropClient::DoOrcaPerRpc() {
gpr_assertion_failed(__FILE__, __LINE__, comparison_result->c_str());
}
CHECK(!load_report_tracker_.GetNextLoadReport().has_value());
gpr_log(GPR_DEBUG, "orca per rpc successfully finished");
VLOG(2) << "orca per rpc successfully finished";
return true;
}
bool InteropClient::DoOrcaOob() {
static constexpr auto kTimeout = absl::Seconds(10);
gpr_log(GPR_INFO, "testing orca oob");
LOG(INFO) << "testing orca oob";
load_report_tracker_.ResetCollectedLoadReports();
// Make the backup poller poll very frequently in order to pick up
// updates from all the subchannels's FDs.
@ -1047,11 +1032,11 @@ bool InteropClient::DoOrcaOob() {
orca_report->mutable_utilization()->emplace("util", 0.30499);
StreamingOutputCallResponse response;
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoOrcaOob(): stream->Write() failed");
LOG(ERROR) << "DoOrcaOob(): stream->Write() failed";
return TransientFailureOrAbort();
}
if (!stream->Read(&response)) {
gpr_log(GPR_ERROR, "DoOrcaOob(): stream->Read failed");
LOG(ERROR) << "DoOrcaOob(): stream->Read failed";
return TransientFailureOrAbort();
}
CHECK(load_report_tracker_
@ -1059,8 +1044,7 @@ bool InteropClient::DoOrcaOob() {
[orca_report](const auto& actual) {
auto value = OrcaLoadReportsDiff(*orca_report, actual);
if (value.has_value()) {
gpr_log(GPR_DEBUG, "Reports mismatch: %s",
value->c_str());
VLOG(2) << "Reports mismatch: " << value->c_str();
return false;
}
return true;
@ -1077,11 +1061,11 @@ bool InteropClient::DoOrcaOob() {
orca_report->mutable_utilization()->emplace("util", 0.2039);
StreamingOutputCallResponse response;
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoOrcaOob(): stream->Write() failed");
LOG(ERROR) << "DoOrcaOob(): stream->Write() failed";
return TransientFailureOrAbort();
}
if (!stream->Read(&response)) {
gpr_log(GPR_ERROR, "DoOrcaOob(): stream->Read failed");
LOG(ERROR) << "DoOrcaOob(): stream->Read failed";
return TransientFailureOrAbort();
}
CHECK(
@ -1093,7 +1077,7 @@ bool InteropClient::DoOrcaOob() {
kTimeout, 10)
.has_value());
}
gpr_log(GPR_INFO, "orca oob successfully finished");
LOG(INFO) << "orca oob successfully finished";
return true;
}
@ -1105,7 +1089,7 @@ bool InteropClient::DoCustomMetadata() {
const std::string kTrailingBinValue("\x0a\x0b\x0a\x0b\x0a\x0b");
{
gpr_log(GPR_DEBUG, "Sending RPC with custom metadata");
VLOG(2) << "Sending RPC with custom metadata";
ClientContext context;
context.AddMetadata(kEchoInitialMetadataKey, kInitialMetadataValue);
context.AddMetadata(kEchoTrailingBinMetadataKey, kTrailingBinValue);
@ -1130,11 +1114,11 @@ bool InteropClient::DoCustomMetadata() {
CHECK(std::string(iter->second.begin(), iter->second.end()) ==
kTrailingBinValue);
gpr_log(GPR_DEBUG, "Done testing RPC with custom metadata");
VLOG(2) << "Done testing RPC with custom metadata";
}
{
gpr_log(GPR_DEBUG, "Sending stream with custom metadata");
VLOG(2) << "Sending stream with custom metadata";
ClientContext context;
context.AddMetadata(kEchoInitialMetadataKey, kInitialMetadataValue);
context.AddMetadata(kEchoTrailingBinMetadataKey, kTrailingBinValue);
@ -1150,14 +1134,14 @@ bool InteropClient::DoCustomMetadata() {
StreamingOutputCallResponse response;
if (!stream->Write(request)) {
gpr_log(GPR_ERROR, "DoCustomMetadata(): stream->Write() failed");
LOG(ERROR) << "DoCustomMetadata(): stream->Write() failed";
return TransientFailureOrAbort();
}
stream->WritesDone();
if (!stream->Read(&response)) {
gpr_log(GPR_ERROR, "DoCustomMetadata(): stream->Read() failed");
LOG(ERROR) << "DoCustomMetadata(): stream->Read() failed";
return TransientFailureOrAbort();
}
@ -1180,7 +1164,7 @@ bool InteropClient::DoCustomMetadata() {
CHECK(std::string(iter->second.begin(), iter->second.end()) ==
kTrailingBinValue);
gpr_log(GPR_DEBUG, "Done testing stream with custom metadata");
VLOG(2) << "Done testing stream with custom metadata";
}
return true;
@ -1254,17 +1238,14 @@ void InteropClient::PerformSoakTest(
std::string peer = std::get<3>(result);
results.push_back(result);
if (!success) {
gpr_log(GPR_INFO,
"soak iteration: %d elapsed_ms: %d peer: %s server_uri: %s "
"failed: %s",
i, elapsed_ms, peer.c_str(), server_uri.c_str(),
debug_string.c_str());
LOG(INFO) << "soak iteration: " << i << " elapsed_ms: " << elapsed_ms
<< " peer: " << peer << " server_uri: " << server_uri
<< " failed: " << debug_string;
total_failures++;
} else {
gpr_log(
GPR_INFO,
"soak iteration: %d elapsed_ms: %d peer: %s server_uri: %s succeeded",
i, elapsed_ms, peer.c_str(), server_uri.c_str());
LOG(INFO) << "soak iteration: " << i << " elapsed_ms: " << elapsed_ms
<< " peer: " << peer << " server_uri: " << server_uri
<< " succeeded";
}
grpc_histogram_add(latencies_ms_histogram, std::get<1>(result));
iterations_ran++;
@ -1277,48 +1258,40 @@ void InteropClient::PerformSoakTest(
double latency_ms_worst = grpc_histogram_maximum(latencies_ms_histogram);
grpc_histogram_destroy(latencies_ms_histogram);
if (iterations_ran < soak_iterations) {
gpr_log(
GPR_ERROR,
"(server_uri: %s) soak test consumed all %d seconds of time and quit "
"early, only "
"having ran %d out of desired %d iterations. "
"total_failures: %d. "
"max_failures_threshold: %d. "
"median_soak_iteration_latency: %lf ms. "
"90th_soak_iteration_latency: %lf ms. "
"worst_soak_iteration_latency: %lf ms. "
"Some or all of the iterations that did run were unexpectedly slow. "
"See breakdown above for which iterations succeeded, failed, and "
"why for more info.",
server_uri.c_str(), overall_timeout_seconds, iterations_ran,
soak_iterations, total_failures, max_failures, latency_ms_median,
latency_ms_90th, latency_ms_worst);
LOG(ERROR) << "(server_uri: " << server_uri << ") soak test consumed all "
<< overall_timeout_seconds
<< " seconds of time and quit early, only having ran "
<< iterations_ran << " out of desired " << soak_iterations
<< " iterations. total_failures: " << total_failures
<< ". max_failures_threshold: " << max_failures
<< ". median_soak_iteration_latency: " << latency_ms_median
<< " ms. 90th_soak_iteration_latency: " << latency_ms_90th
<< " ms. worst_soak_iteration_latency: " << latency_ms_worst
<< " ms. Some or all of the iterations that did run were "
"unexpectedly slow. See breakdown above for which iterations "
"succeeded, failed, and why for more info.";
CHECK(0);
} else if (total_failures > max_failures) {
gpr_log(GPR_ERROR,
"(server_uri: %s) soak test ran: %d iterations. total_failures: %d "
"exceeds "
"max_failures_threshold: %d. "
"median_soak_iteration_latency: %lf ms. "
"90th_soak_iteration_latency: %lf ms. "
"worst_soak_iteration_latency: %lf ms. "
"See breakdown above for which iterations succeeded, failed, and "
"why for more info.",
server_uri.c_str(), soak_iterations, total_failures, max_failures,
latency_ms_median, latency_ms_90th, latency_ms_worst);
LOG(ERROR) << "(server_uri: " << server_uri
<< ") soak test ran: " << soak_iterations
<< " iterations. total_failures: " << total_failures
<< " exceeds max_failures_threshold: " << max_failures
<< ". median_soak_iteration_latency: " << latency_ms_median
<< " ms. 90th_soak_iteration_latency: " << latency_ms_90th
<< " ms. worst_soak_iteration_latency: " << latency_ms_worst
<< " ms. See breakdown above for which iterations succeeded, "
"failed, and why for more info.";
CHECK(0);
} else {
gpr_log(GPR_INFO,
"(server_uri: %s) soak test ran: %d iterations. total_failures: %d "
"is within "
"max_failures_threshold: %d. "
"median_soak_iteration_latency: %lf ms. "
"90th_soak_iteration_latency: %lf ms. "
"worst_soak_iteration_latency: %lf ms. "
"See breakdown above for which iterations succeeded, failed, and "
"why for more info.",
server_uri.c_str(), soak_iterations, total_failures, max_failures,
latency_ms_median, latency_ms_90th, latency_ms_worst);
LOG(INFO) << "(server_uri: " << server_uri
<< ") soak test ran: " << soak_iterations
<< " iterations. total_failures: " << total_failures
<< " is within max_failures_threshold: " << max_failures
<< ". median_soak_iteration_latency: " << latency_ms_median
<< " ms. 90th_soak_iteration_latency: " << latency_ms_90th
<< " ms. worst_soak_iteration_latency: " << latency_ms_worst
<< " ms. See breakdown above for which iterations succeeded, "
"failed, and why for more info.";
}
}
@ -1327,14 +1300,14 @@ bool InteropClient::DoRpcSoakTest(
int32_t max_failures, int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds,
int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
VLOG(2) << "Sending " << soak_iterations << " RPCs...";
CHECK_GT(soak_iterations, 0);
PerformSoakTest(server_uri, false /* reset channel per iteration */,
soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms,
soak_min_time_ms_between_rpcs, overall_timeout_seconds,
request_size, response_size);
gpr_log(GPR_DEBUG, "rpc_soak test done.");
VLOG(2) << "rpc_soak test done.";
return true;
}
@ -1343,30 +1316,30 @@ bool InteropClient::DoChannelSoakTest(
int32_t max_failures, int64_t max_acceptable_per_iteration_latency_ms,
int32_t soak_min_time_ms_between_rpcs, int32_t overall_timeout_seconds,
int32_t request_size, int32_t response_size) {
gpr_log(GPR_DEBUG, "Sending %d RPCs, tearing down the channel each time...",
soak_iterations);
VLOG(2) << "Sending " << soak_iterations
<< " RPCs, tearing down the channel each time...";
CHECK_GT(soak_iterations, 0);
PerformSoakTest(server_uri, true /* reset channel per iteration */,
soak_iterations, max_failures,
max_acceptable_per_iteration_latency_ms,
soak_min_time_ms_between_rpcs, overall_timeout_seconds,
request_size, response_size);
gpr_log(GPR_DEBUG, "channel_soak test done.");
VLOG(2) << "channel_soak test done.";
return true;
}
bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations,
int32_t iteration_interval) {
gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
VLOG(2) << "Sending " << soak_iterations << " RPCs...";
CHECK_GT(soak_iterations, 0);
CHECK_GT(iteration_interval, 0);
SimpleRequest request;
SimpleResponse response;
int num_failures = 0;
for (int i = 0; i < soak_iterations; ++i) {
gpr_log(GPR_DEBUG, "Sending RPC number %d...", i);
VLOG(2) << "Sending RPC number " << i << "...";
if (!PerformLargeUnary(&request, &response)) {
gpr_log(GPR_ERROR, "Iteration %d failed.", i);
LOG(ERROR) << "Iteration " << i << " failed.";
num_failures++;
}
gpr_sleep_until(
@ -1374,17 +1347,17 @@ bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations,
gpr_time_from_seconds(iteration_interval, GPR_TIMESPAN)));
}
if (num_failures == 0) {
gpr_log(GPR_DEBUG, "long_lived_channel test done.");
VLOG(2) << "long_lived_channel test done.";
return true;
} else {
gpr_log(GPR_DEBUG, "long_lived_channel test failed with %d rpc failures.",
num_failures);
VLOG(2) << "long_lived_channel test failed with " << num_failures
<< " rpc failures.";
return false;
}
}
bool InteropClient::DoUnimplementedService() {
gpr_log(GPR_DEBUG, "Sending a request for an unimplemented service...");
VLOG(2) << "Sending a request for an unimplemented service...";
Empty request;
Empty response;
@ -1399,12 +1372,12 @@ bool InteropClient::DoUnimplementedService() {
return false;
}
gpr_log(GPR_DEBUG, "unimplemented service done.");
VLOG(2) << "unimplemented service done.";
return true;
}
bool InteropClient::DoUnimplementedMethod() {
gpr_log(GPR_DEBUG, "Sending a request for an unimplemented rpc...");
VLOG(2) << "Sending a request for an unimplemented rpc...";
Empty request;
Empty response;
@ -1418,7 +1391,7 @@ bool InteropClient::DoUnimplementedMethod() {
return false;
}
gpr_log(GPR_DEBUG, "unimplemented rpc done.");
VLOG(2) << "unimplemented rpc done.";
return true;
}

Loading…
Cancel
Save