s/combiner/logical_thread

reviewable/pr21361/r3
Yash Tibrewal 5 years ago
parent c613162e1d
commit 4ffec8c53e
  1. 10
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
  2. 20
      test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
  3. 13
      test/core/client_channel/resolvers/dns_resolver_test.cc
  4. 8
      test/core/client_channel/resolvers/fake_resolver_test.cc
  5. 10
      test/core/client_channel/resolvers/sockaddr_resolver_test.cc

@ -33,7 +33,7 @@
static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_combiner;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_logical_thread;
static void my_resolve_address(const char* addr, const char* /*default_port*/,
grpc_pollset_set* /*interested_parties*/,
@ -66,7 +66,7 @@ static grpc_ares_request* my_dns_lookup_ares_locked(
std::unique_ptr<grpc_core::ServerAddressList>* addresses,
bool /*check_grpclb*/, char** /*service_config_json*/,
int /*query_timeout_ms*/,
grpc_core::RefCountedPtr<grpc_core::LogicalThread> /*combiner*/) {
grpc_core::RefCountedPtr<grpc_core::LogicalThread> /*logical_thread*/) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", addr));
grpc_error* error = GRPC_ERROR_NONE;
@ -99,7 +99,7 @@ static grpc_core::OrphanablePtr<grpc_core::Resolver> create_resolver(
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = std::move(result_handler);
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -163,8 +163,8 @@ int main(int argc, char** argv) {
gpr_mu_init(&g_mu);
{
grpc_core::ExecCtx exec_ctx;
auto combiner = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_combiner = &combiner;
auto logical_thread = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_logical_thread = &logical_thread;
grpc_set_resolver_impl(&test_resolver);
grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked;
grpc_cancel_ares_request_locked = my_cancel_ares_request_locked;

@ -37,14 +37,14 @@ constexpr int kMinResolutionPeriodForCheckMs = 900;
extern grpc_address_resolver_vtable* grpc_resolve_address_impl;
static grpc_address_resolver_vtable* default_resolve_address;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_combiner;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_logical_thread;
static grpc_ares_request* (*g_default_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
std::unique_ptr<grpc_core::ServerAddressList>* addresses, bool check_grpclb,
char** service_config_json, int query_timeout_ms,
grpc_core::RefCountedPtr<grpc_core::LogicalThread> combiner);
grpc_core::RefCountedPtr<grpc_core::LogicalThread> logical_thread);
// Counter incremented by test_resolve_address_impl indicating the number of
// times a system-level resolution has happened.
@ -95,11 +95,11 @@ static grpc_ares_request* test_dns_lookup_ares_locked(
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
std::unique_ptr<grpc_core::ServerAddressList>* addresses, bool check_grpclb,
char** service_config_json, int query_timeout_ms,
grpc_core::RefCountedPtr<grpc_core::LogicalThread> combiner) {
grpc_core::RefCountedPtr<grpc_core::LogicalThread> logical_thread) {
grpc_ares_request* result = g_default_dns_lookup_ares_locked(
dns_server, name, default_port, g_iomgr_args.pollset_set, on_done,
addresses, check_grpclb, service_config_json, query_timeout_ms,
std::move(combiner));
std::move(logical_thread));
++g_resolution_count;
static grpc_millis last_resolution_time = 0;
grpc_millis now =
@ -272,7 +272,7 @@ static void on_first_resolution(OnResolutionCallbackArg* cb_arg) {
gpr_mu_unlock(g_iomgr_args.mu);
}
static void start_test_under_combiner(void* arg) {
static void start_test_under_logical_thread(void* arg) {
OnResolutionCallbackArg* res_cb_arg =
static_cast<OnResolutionCallbackArg*>(arg);
res_cb_arg->result_handler = new ResultHandler();
@ -284,7 +284,7 @@ static void start_test_under_combiner(void* arg) {
GPR_ASSERT(uri != nullptr);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = std::unique_ptr<grpc_core::Resolver::ResultHandler>(
res_cb_arg->result_handler);
g_resolution_count = 0;
@ -308,8 +308,8 @@ static void test_cooldown() {
OnResolutionCallbackArg* res_cb_arg = new OnResolutionCallbackArg();
res_cb_arg->uri_str = "dns:127.0.0.1";
(*g_combiner)
->Run([res_cb_arg]() { start_test_under_combiner(res_cb_arg); },
(*g_logical_thread)
->Run([res_cb_arg]() { start_test_under_logical_thread(res_cb_arg); },
DEBUG_LOCATION);
grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&g_iomgr_args);
@ -322,8 +322,8 @@ int main(int argc, char** argv) {
{
grpc_core::ExecCtx exec_ctx;
auto combiner = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_combiner = &combiner;
auto logical_thread = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_logical_thread = &logical_thread;
g_default_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked;
grpc_dns_lookup_ares_locked = test_dns_lookup_ares_locked;

@ -25,10 +25,10 @@
#include "src/core/ext/filters/client_channel/resolver_registry.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/logical_thread.h"
#include "test/core/util/test_config.h"
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_combiner;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_logical_thread;
class TestResultHandler : public grpc_core::Resolver::ResultHandler {
void ReturnResult(grpc_core::Resolver::Result /*result*/) override {}
@ -44,7 +44,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -61,7 +61,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -75,8 +75,9 @@ int main(int argc, char** argv) {
{
grpc_core::ExecCtx exec_ctx;
{
auto combiner = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_combiner = &combiner;
auto logical_thread =
grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_logical_thread = &logical_thread;
grpc_core::ResolverFactory* dns =
grpc_core::ResolverRegistry::LookupResolverFactory("dns");

@ -63,7 +63,7 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler {
};
static grpc_core::OrphanablePtr<grpc_core::Resolver> build_fake_resolver(
grpc_core::RefCountedPtr<grpc_core::LogicalThread> combiner,
grpc_core::RefCountedPtr<grpc_core::LogicalThread> logical_thread,
grpc_core::FakeResolverResponseGenerator* response_generator,
std::unique_ptr<grpc_core::Resolver::ResultHandler> result_handler) {
grpc_core::ResolverFactory* factory =
@ -74,7 +74,7 @@ static grpc_core::OrphanablePtr<grpc_core::Resolver> build_fake_resolver(
grpc_channel_args channel_args = {1, &generator_arg};
grpc_core::ResolverArgs args;
args.args = &channel_args;
args.combiner = std::move(combiner);
args.logical_thread = std::move(logical_thread);
args.result_handler = std::move(result_handler);
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -118,7 +118,7 @@ static grpc_core::Resolver::Result create_new_resolver_result() {
static void test_fake_resolver() {
grpc_core::ExecCtx exec_ctx;
grpc_core::RefCountedPtr<grpc_core::LogicalThread> combiner =
grpc_core::RefCountedPtr<grpc_core::LogicalThread> logical_thread =
grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
// Create resolver.
ResultHandler* result_handler = new ResultHandler();
@ -126,7 +126,7 @@ static void test_fake_resolver() {
response_generator =
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = build_fake_resolver(
combiner, response_generator.get(),
logical_thread, response_generator.get(),
std::unique_ptr<grpc_core::Resolver::ResultHandler>(result_handler));
GPR_ASSERT(resolver.get() != nullptr);
resolver->StartLocked();

@ -28,7 +28,7 @@
#include "test/core/util/test_config.h"
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_combiner;
static grpc_core::RefCountedPtr<grpc_core::LogicalThread>* g_logical_thread;
class ResultHandler : public grpc_core::Resolver::ResultHandler {
public:
@ -46,7 +46,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -67,7 +67,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
GPR_ASSERT(uri);
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = *g_combiner;
args.logical_thread = *g_logical_thread;
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
@ -80,8 +80,8 @@ int main(int argc, char** argv) {
grpc_init();
{
grpc_core::ExecCtx exec_ctx;
auto combiner = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_combiner = &combiner;
auto logical_thread = grpc_core::MakeRefCounted<grpc_core::LogicalThread>();
g_logical_thread = &logical_thread;
grpc_core::ResolverFactory* ipv4 =
grpc_core::ResolverRegistry::LookupResolverFactory("ipv4");

Loading…
Cancel
Save