[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36407)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK

These changes have been made using string replacement and regex.

Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced.

Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36407

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36407 from tanvi-jagtap:tjagtap_end2end_fixtures e98c97245b
PiperOrigin-RevId: 626522240
pull/36415/head
Tanvi Jagtap 7 months ago committed by Copybara-Service
parent 91f0eadd22
commit e9d1397fe1
  1. 3
      test/core/end2end/BUILD
  2. 10
      test/core/end2end/fixtures/h2_oauth2_common.h
  3. 4
      test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h
  4. 4
      test/core/end2end/fixtures/h2_ssl_tls_common.h
  5. 3
      test/core/end2end/fixtures/h2_tls_common.h
  6. 9
      test/core/end2end/fixtures/http_proxy_fixture.cc
  7. 9
      test/core/end2end/fixtures/local_util.cc
  8. 36
      test/core/end2end/fixtures/proxy.cc
  9. 5
      test/core/end2end/fixtures/secure_fixture.h
  10. 3
      test/core/end2end/fixtures/sockpair_fixture.h

@ -62,6 +62,7 @@ grpc_cc_library(
srcs = ["fixtures/http_proxy_fixture.cc"],
hdrs = ["fixtures/http_proxy_fixture.h"],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -94,6 +95,7 @@ grpc_cc_library(
name = "proxy",
srcs = ["fixtures/proxy.cc"],
hdrs = ["fixtures/proxy.h"],
external_deps = ["absl/log:check"],
language = "C++",
deps = [
"//:channel_arg_names",
@ -159,6 +161,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",

@ -17,6 +17,8 @@
#include <string.h>
#include "absl/log/check.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@ -73,7 +75,7 @@ class Oauth2Fixture : public SecureFixture {
void* user_data) {
const grpc_metadata* oauth2 =
find_metadata(md, md_count, "authorization", oauth2_md());
GPR_ASSERT(oauth2 != nullptr);
CHECK_NE(oauth2, nullptr);
cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_OK, nullptr);
}
@ -83,8 +85,8 @@ class Oauth2Fixture : public SecureFixture {
void* user_data) {
const grpc_metadata* oauth2 =
find_metadata(md, md_count, "authorization", oauth2_md());
GPR_ASSERT(state != nullptr);
GPR_ASSERT(oauth2 != nullptr);
CHECK_NE(state, nullptr);
CHECK_NE(oauth2, nullptr);
cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
@ -159,7 +161,7 @@ class Oauth2Fixture : public SecureFixture {
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
CHECK_EQ(state, nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}

@ -17,6 +17,8 @@
#include <stddef.h>
#include "absl/log/check.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@ -91,7 +93,7 @@ class SslCredReloadFixture : public SecureFixture {
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
CHECK_EQ(state, nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}

@ -17,6 +17,8 @@
#include <string.h>
#include "absl/log/check.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@ -96,7 +98,7 @@ class SslTlsFixture : public SecureFixture {
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
CHECK_EQ(state, nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}

@ -24,6 +24,7 @@
#include <string>
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
@ -63,7 +64,7 @@ inline void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
CHECK_EQ(state, nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}

@ -26,6 +26,7 @@
#include <string>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/escaping.h"
@ -575,7 +576,7 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error) {
proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy DNS lookup", error);
return;
}
GPR_ASSERT(!addresses_or->empty());
CHECK(!addresses_or->empty());
// Connect to requested address.
// The connection callback inherits our reference to conn.
const grpc_core::Timestamp deadline =
@ -679,7 +680,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
nullptr,
grpc_event_engine::experimental::ChannelArgsEndpointConfig(channel_args),
on_accept, proxy, &proxy->server);
GPR_ASSERT(error.ok());
CHECK_OK(error);
// Bind to port.
grpc_resolved_address resolved_addr;
grpc_sockaddr_in* addr =
@ -690,8 +691,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_sockaddr_set_port(&resolved_addr, proxy_port);
int port;
error = grpc_tcp_server_add_port(proxy->server, &resolved_addr, &port);
GPR_ASSERT(error.ok());
GPR_ASSERT(port == proxy_port);
CHECK_OK(error);
CHECK(port == proxy_port);
// Start server.
auto* pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &proxy->mu);

@ -22,6 +22,8 @@
#include <utility>
#include "absl/log/check.h"
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/status.h>
@ -32,7 +34,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
CHECK_EQ(state, nullptr);
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
@ -53,8 +55,7 @@ grpc_server* LocalTestFixture::MakeServer(
grpc_server_credentials_set_auth_metadata_processor(server_creds,
processor);
}
GPR_ASSERT(
grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds));
CHECK(grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds));
grpc_server_credentials_release(server_creds);
pre_server_start(server);
grpc_server_start(server);
@ -66,7 +67,7 @@ grpc_channel* LocalTestFixture::MakeClient(const grpc_core::ChannelArgs& args,
grpc_channel_credentials* creds = grpc_local_credentials_create(type_);
auto* client =
grpc_channel_create(localaddr_.c_str(), creds, args.ToC().get());
GPR_ASSERT(client != nullptr);
CHECK_NE(client, nullptr);
grpc_channel_credentials_release(creds);
return client;
}

@ -23,6 +23,8 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include <grpc/byte_buffer.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/propagation_bits.h>
@ -193,7 +195,7 @@ static void on_p2s_recv_initial_metadata(void* arg, int /*success*/) {
err = grpc_call_start_batch(pc->c2p, &op, 1,
new_closure(on_c2p_sent_initial_metadata, pc),
nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_recv_initial_metadata");
@ -220,7 +222,7 @@ static void on_p2s_sent_message(void* arg, int success) {
refpc(pc, "on_c2p_recv_msg");
err = grpc_call_start_batch(pc->c2p, &op, 1,
new_closure(on_c2p_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_sent_message");
@ -245,7 +247,7 @@ static void on_c2p_recv_msg(void* arg, int success) {
refpc(pc, "on_p2s_sent_message");
err = grpc_call_start_batch(
pc->p2s, &op, 1, new_closure(on_p2s_sent_message, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
} else {
op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op.flags = 0;
@ -253,7 +255,7 @@ static void on_c2p_recv_msg(void* arg, int success) {
refpc(pc, "on_p2s_sent_close");
err = grpc_call_start_batch(pc->p2s, &op, 1,
new_closure(on_p2s_sent_close, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
}
} else {
if (pc->c2p_msg != nullptr) {
@ -280,7 +282,7 @@ static void on_c2p_sent_message(void* arg, int success) {
refpc(pc, "on_p2s_recv_msg");
err = grpc_call_start_batch(pc->p2s, &op, 1,
new_closure(on_p2s_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
}
unrefpc(pc, "on_c2p_sent_message");
@ -299,7 +301,7 @@ static void on_p2s_recv_msg(void* arg, int success) {
refpc(pc, "on_c2p_sent_message");
err = grpc_call_start_batch(pc->c2p, &op, 1,
new_closure(on_c2p_sent_message, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
} else {
grpc_byte_buffer_destroy(pc->p2s_msg);
}
@ -319,7 +321,7 @@ static void on_p2s_status(void* arg, int success) {
memset(op, 0, sizeof(op));
if (!pc->proxy->shutdown) {
GPR_ASSERT(success);
CHECK(success);
int op_count = 0;
if (grpc_call_is_trailers_only(pc->p2s)) {
@ -341,7 +343,7 @@ static void on_p2s_status(void* arg, int success) {
refpc(pc, "on_c2p_sent_status");
err = grpc_call_start_batch(pc->c2p, op, op_count,
new_closure(on_c2p_sent_status, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
}
unrefpc(pc, "on_p2s_status");
@ -380,7 +382,7 @@ static void on_new_call(void* arg, int success) {
err = grpc_call_start_batch(pc->p2s, &op, 1,
new_closure(on_p2s_recv_initial_metadata, pc),
nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
op.op = GRPC_OP_SEND_INITIAL_METADATA;
op.flags = 0;
@ -390,7 +392,7 @@ static void on_new_call(void* arg, int success) {
err = grpc_call_start_batch(pc->p2s, &op, 1,
new_closure(on_p2s_sent_initial_metadata, pc),
nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
op.op = GRPC_OP_RECV_MESSAGE;
op.flags = 0;
@ -398,7 +400,7 @@ static void on_new_call(void* arg, int success) {
refpc(pc, "on_c2p_recv_msg");
err = grpc_call_start_batch(pc->c2p, &op, 1,
new_closure(on_c2p_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
op.op = GRPC_OP_RECV_MESSAGE;
op.flags = 0;
@ -406,7 +408,7 @@ static void on_new_call(void* arg, int success) {
refpc(pc, "on_p2s_recv_msg");
err = grpc_call_start_batch(pc->p2s, &op, 1,
new_closure(on_p2s_recv_msg, pc), nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
op.op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op.flags = 0;
@ -417,7 +419,7 @@ static void on_new_call(void* arg, int success) {
refpc(pc, "on_p2s_status");
err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc),
nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
op.op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op.flags = 0;
@ -425,7 +427,7 @@ static void on_new_call(void* arg, int success) {
refpc(pc, "on_c2p_closed");
err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc),
nullptr);
GPR_ASSERT(err == GRPC_CALL_OK);
CHECK_EQ(err, GRPC_CALL_OK);
request_call(proxy);
@ -434,14 +436,14 @@ static void on_new_call(void* arg, int success) {
unrefpc(pc, "init");
} else {
GPR_ASSERT(proxy->new_call == nullptr);
CHECK_EQ(proxy->new_call, nullptr);
}
}
static void request_call(grpc_end2end_proxy* proxy) {
proxy->new_call = nullptr;
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
proxy->server, &proxy->new_call,
CHECK(GRPC_CALL_OK ==
grpc_server_request_call(proxy->server, &proxy->new_call,
&proxy->new_call_details,
&proxy->new_call_metadata, proxy->cq,
proxy->cq, new_closure(on_new_call, proxy)));

@ -19,6 +19,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
@ -59,7 +60,7 @@ class SecureFixture : public grpc_core::CoreTestFixture {
auto* creds = MakeServerCreds(args);
auto* server = grpc_server_create(args.ToC().get(), nullptr);
grpc_server_register_completion_queue(server, cq, nullptr);
GPR_ASSERT(grpc_server_add_http2_port(server, localaddr_.c_str(), creds));
CHECK(grpc_server_add_http2_port(server, localaddr_.c_str(), creds));
grpc_server_credentials_release(creds);
pre_server_start(server);
grpc_server_start(server);
@ -71,7 +72,7 @@ class SecureFixture : public grpc_core::CoreTestFixture {
auto* creds = MakeClientCreds(args);
auto* client =
grpc_channel_create(localaddr_.c_str(), creds, args.ToC().get());
GPR_ASSERT(client != nullptr);
CHECK_NE(client, nullptr);
grpc_channel_credentials_release(creds);
return client;
}

@ -18,6 +18,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "gtest/gtest.h"
@ -121,7 +122,7 @@ class SockpairFixture : public CoreTestFixture {
"lame channel");
transport->Orphan();
}
GPR_ASSERT(client);
CHECK(client);
return client;
}

Loading…
Cancel
Save