diff options
Diffstat (limited to 'test')
17 files changed, 204 insertions, 228 deletions
diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl index f2eab54904..3cf7fd7b4e 100755 --- a/test/core/bad_ssl/generate_tests.bzl +++ b/test/core/bad_ssl/generate_tests.bzl @@ -39,9 +39,10 @@ def grpc_bad_ssl_tests(): native.cc_test( name = 'bad_ssl_%s_test' % t, srcs = ['bad_ssl_test.cc'], - data = [':bad_ssl_%s_server' % t], + data = [':bad_ssl_%s_server' % t, + '//src/core/tsi/test_creds:badserver.key', + '//src/core/tsi/test_creds:badserver.pem',], deps = ['//test/core/util:grpc_test_util', '//:gpr', '//test/core/end2end:cq_verifier'], ) - diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc index 18a795fbcb..8cafadf05a 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -79,17 +79,17 @@ static grpc_ares_request* my_dns_lookup_ares( return nullptr; } -static grpc_resolver* create_resolver(const char* name) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); +static grpc_core::OrphanablePtr<grpc_core::Resolver> create_resolver( + const char* name) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(name, 0); GPR_ASSERT(uri); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); grpc_uri_destroy(uri); return resolver; } @@ -112,7 +112,7 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) { } typedef struct next_args { - grpc_resolver* resolver; + grpc_core::Resolver* resolver; grpc_channel_args** result; grpc_closure* on_complete; } next_args; @@ -120,21 +120,21 @@ typedef struct next_args { static void call_resolver_next_now_lock_taken(void* arg, grpc_error* error_unused) { next_args* a = static_cast<next_args*>(arg); - grpc_resolver_next_locked(a->resolver, a->result, a->on_complete); + a->resolver->NextLocked(a->result, a->on_complete); gpr_free(a); } -static void call_resolver_next_after_locking(grpc_resolver* resolver, +static void call_resolver_next_after_locking(grpc_core::Resolver* resolver, grpc_channel_args** result, - grpc_closure* on_complete) { + grpc_closure* on_complete, + grpc_combiner* combiner) { next_args* a = static_cast<next_args*>(gpr_malloc(sizeof(*a))); a->resolver = resolver; a->result = result; a->on_complete = on_complete; - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, - grpc_combiner_scheduler(resolver->combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, + grpc_combiner_scheduler(combiner)), + GRPC_ERROR_NONE); } int main(int argc, char** argv) { @@ -149,12 +149,14 @@ int main(int argc, char** argv) { { grpc_core::ExecCtx exec_ctx; - grpc_resolver* resolver = create_resolver("dns:test"); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + create_resolver("dns:test"); gpr_event ev1; gpr_event_init(&ev1); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(5, &ev1)); GPR_ASSERT(result == nullptr); @@ -162,14 +164,14 @@ int main(int argc, char** argv) { gpr_event ev2; gpr_event_init(&ev2); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(30, &ev2)); GPR_ASSERT(result != nullptr); grpc_channel_args_destroy(result); - GRPC_RESOLVER_UNREF(resolver, "test"); GRPC_COMBINER_UNREF(g_combiner, "test"); } diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 64342b48c8..9402a605b3 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -23,6 +23,7 @@ #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "test/core/util/test_config.h" @@ -131,13 +132,13 @@ static void poll_pollset_until_request_done(iomgr_args* args) { gpr_event_set(&args->ev, (void*)1); } -typedef struct on_resolution_cb_arg { - const char* uri_str; - grpc_resolver* resolver; - grpc_channel_args* result; - grpc_millis delay_before_second_resolution; - bool using_cares; -} on_resolution_cb_arg; +struct OnResolutionCallbackArg { + const char* uri_str = nullptr; + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver; + grpc_channel_args* result = nullptr; + grpc_millis delay_before_second_resolution = 0; + bool using_cares = false; +}; // Counter for the number of times a resolution notification callback has been // invoked. @@ -147,7 +148,7 @@ static int g_on_resolution_invocations_count; bool g_all_callbacks_invoked; void on_third_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast<on_resolution_cb_arg*>(arg); + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); GPR_ASSERT(error == GRPC_ERROR_NONE); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); @@ -159,8 +160,7 @@ void on_third_resolution(void* arg, grpc_error* error) { // period. GPR_ASSERT(g_on_resolution_invocations_count == 3); GPR_ASSERT(g_resolution_count == 2); - grpc_resolver_shutdown_locked(cb_arg->resolver); - GRPC_RESOLVER_UNREF(cb_arg->resolver, "on_third_resolution"); + cb_arg->resolver.reset(); if (cb_arg->using_cares) { gpr_atm_rel_store(&g_iomgr_args.done_atm, 1); gpr_mu_lock(g_iomgr_args.mu); @@ -168,12 +168,12 @@ void on_third_resolution(void* arg, grpc_error* error) { grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); gpr_mu_unlock(g_iomgr_args.mu); } - gpr_free(cb_arg); + grpc_core::Delete(cb_arg); g_all_callbacks_invoked = true; } void on_second_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast<on_resolution_cb_arg*>(arg); + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); @@ -187,11 +187,11 @@ void on_second_resolution(void* arg, grpc_error* error) { GPR_ASSERT(g_resolution_count == 1); grpc_core::ExecCtx::Get()->TestOnlySetNow( cb_arg->delay_before_second_resolution * 2); - grpc_resolver_next_locked( - cb_arg->resolver, &cb_arg->result, + cb_arg->resolver->NextLocked( + &cb_arg->result, GRPC_CLOSURE_CREATE(on_third_resolution, arg, grpc_combiner_scheduler(g_combiner))); - grpc_resolver_channel_saw_error_locked(cb_arg->resolver); + cb_arg->resolver->RequestReresolutionLocked(); if (cb_arg->using_cares) { gpr_mu_lock(g_iomgr_args.mu); GRPC_LOG_IF_ERROR("pollset_kick", @@ -201,14 +201,14 @@ void on_second_resolution(void* arg, grpc_error* error) { } void on_first_resolution(void* arg, grpc_error* error) { - on_resolution_cb_arg* cb_arg = static_cast<on_resolution_cb_arg*>(arg); + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); ++g_on_resolution_invocations_count; grpc_channel_args_destroy(cb_arg->result); - grpc_resolver_next_locked( - cb_arg->resolver, &cb_arg->result, + cb_arg->resolver->NextLocked( + &cb_arg->result, GRPC_CLOSURE_CREATE(on_second_resolution, arg, grpc_combiner_scheduler(g_combiner))); - grpc_resolver_channel_saw_error_locked(cb_arg->resolver); + cb_arg->resolver->RequestReresolutionLocked(); gpr_log(GPR_INFO, "1st: g_on_resolution_invocations_count: %d, g_resolution_count: %d", g_on_resolution_invocations_count, g_resolution_count); @@ -225,15 +225,16 @@ void on_first_resolution(void* arg, grpc_error* error) { } static void start_test_under_combiner(void* arg, grpc_error* error) { - on_resolution_cb_arg* res_cb_arg = static_cast<on_resolution_cb_arg*>(arg); - grpc_resolver* resolver; - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); + OnResolutionCallbackArg* res_cb_arg = + static_cast<OnResolutionCallbackArg*>(arg); + + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0); - grpc_resolver_args args; gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", res_cb_arg->uri_str, - factory->vtable->scheme); - GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + factory->scheme()); + GPR_ASSERT(uri != nullptr); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; g_on_resolution_invocations_count = 0; @@ -248,25 +249,23 @@ static void start_test_under_combiner(void* arg, grpc_error* error) { auto* cooldown_channel_args = grpc_channel_args_copy_and_add(nullptr, &cooldown_arg, 1); args.args = cooldown_channel_args; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + res_cb_arg->resolver = factory->CreateResolver(args); grpc_channel_args_destroy(cooldown_channel_args); - GPR_ASSERT(resolver != nullptr); - res_cb_arg->resolver = resolver; + GPR_ASSERT(res_cb_arg->resolver != nullptr); res_cb_arg->delay_before_second_resolution = kMinResolutionPeriodMs; // First resolution, would incur in system-level resolution. - grpc_resolver_next_locked( - resolver, &res_cb_arg->result, + res_cb_arg->resolver->NextLocked( + &res_cb_arg->result, GRPC_CLOSURE_CREATE(on_first_resolution, res_cb_arg, grpc_combiner_scheduler(g_combiner))); grpc_uri_destroy(uri); - grpc_resolver_factory_unref(factory); } static void test_cooldown(bool using_cares) { grpc_core::ExecCtx exec_ctx; if (using_cares) iomgr_args_init(&g_iomgr_args); - on_resolution_cb_arg* res_cb_arg = - static_cast<on_resolution_cb_arg*>(gpr_zalloc(sizeof(*res_cb_arg))); + OnResolutionCallbackArg* res_cb_arg = + grpc_core::New<OnResolutionCallbackArg>(); res_cb_arg->uri_str = "dns:127.0.0.1"; res_cb_arg->using_cares = using_cares; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 80667908ef..e3fba2838c 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -27,47 +27,46 @@ static grpc_combiner* g_combiner; -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); grpc_uri_destroy(uri); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory* dns; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - dns = grpc_resolver_factory_lookup("dns"); + grpc_core::ResolverFactory* dns = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); test_succeeds(dns, "dns:10.2.1.1"); test_succeeds(dns, "dns:10.2.1.1:1234"); @@ -78,7 +77,6 @@ int main(int argc, char** argv) { test_fails(dns, "ipv4://8.8.8.8/8.8.8.8:8888"); } - grpc_resolver_factory_unref(dns); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index 9c11c01021..03af8954e1 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -27,25 +27,26 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/test_config.h" -static grpc_resolver* build_fake_resolver( +static grpc_core::OrphanablePtr<grpc_core::Resolver> build_fake_resolver( grpc_combiner* combiner, - grpc_fake_resolver_response_generator* response_generator) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake"); + grpc_core::FakeResolverResponseGenerator* response_generator) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("fake"); grpc_arg generator_arg = - grpc_fake_resolver_response_generator_arg(response_generator); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator); grpc_channel_args channel_args = {1, &generator_arg}; + grpc_core::ResolverArgs args; args.args = &channel_args; args.combiner = combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); return resolver; } @@ -57,10 +58,11 @@ typedef struct on_resolution_arg { // Callback to check the resolution result is as expected. void on_resolution_cb(void* arg, grpc_error* error) { + if (error != GRPC_ERROR_NONE) return; on_resolution_arg* res = static_cast<on_resolution_arg*>(arg); // We only check the addresses channel arg because that's the only one // explicitly set by the test via - // grpc_fake_resolver_response_generator_set_response. + // FakeResolverResponseGenerator::SetResponse(). const grpc_lb_addresses* actual_lb_addresses = grpc_lb_addresses_find_channel_arg(res->resolver_result); const grpc_lb_addresses* expected_lb_addresses = @@ -115,27 +117,27 @@ static void test_fake_resolver() { grpc_core::ExecCtx exec_ctx; grpc_combiner* combiner = grpc_combiner_create(); // Create resolver. - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); - grpc_resolver* resolver = build_fake_resolver(combiner, response_generator); - GPR_ASSERT(resolver != nullptr); + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + build_fake_resolver(combiner, response_generator.get()); + GPR_ASSERT(resolver.get() != nullptr); // Test 1: normal resolution. - // next_results != NULL, results_upon_error == NULL, last_used_results == + // next_results != NULL, reresolution_results == NULL, last_used_results == // NULL. Expected response is next_results. grpc_channel_args* results = create_new_resolver_result(); on_resolution_arg on_res_arg = create_on_resolution_arg(results); grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 2: update resolution. - // next_results != NULL, results_upon_error == NULL, last_used_results != + // next_results != NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is next_results. results = create_new_resolver_result(); grpc_channel_args* last_used_results = grpc_channel_args_copy(results); @@ -143,61 +145,55 @@ static void test_fake_resolver() { on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 3: fallback re-resolution. - // next_results == NULL, results_upon_error == NULL, last_used_results != + // next_results == NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is last_used_results. on_res_arg = create_on_resolution_arg(last_used_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 4: normal re-resolution. - // next_results == NULL, results_upon_error != NULL, last_used_results != - // NULL. Expected response is results_upon_error. - grpc_channel_args* results_upon_error = create_new_resolver_result(); + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + grpc_channel_args* reresolution_results = create_new_resolver_result(); on_res_arg = - create_on_resolution_arg(grpc_channel_args_copy(results_upon_error)); + create_on_resolution_arg(grpc_channel_args_copy(reresolution_results)); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - // Set results_upon_error. - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator, results_upon_error); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Set reresolution_results. + response_generator->SetReresolutionResponse(reresolution_results); // Flush here to guarantee that the response has been set. grpc_core::ExecCtx::Get()->Flush(); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 5: repeat re-resolution. - // next_results == NULL, results_upon_error != NULL, last_used_results != - // NULL. Expected response is results_upon_error. - on_res_arg = create_on_resolution_arg(results_upon_error); + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + on_res_arg = create_on_resolution_arg(reresolution_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 6: normal resolution. - // next_results != NULL, results_upon_error != NULL, last_used_results != + // next_results != NULL, reresolution_results != NULL, last_used_results != // NULL. Expected response is next_results. results = create_new_resolver_result(); last_used_results = grpc_channel_args_copy(results); @@ -205,28 +201,24 @@ static void test_fake_resolver() { on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Resolution won't be triggered until next_results is set. - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - grpc_fake_resolver_response_generator_set_response(response_generator, - results); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); // Test 7: fallback re-resolution. - // next_results == NULL, results_upon_error == NULL, last_used_results != + // next_results == NULL, reresolution_results == NULL, last_used_results != // NULL. Expected response is last_used_results. on_res_arg = create_on_resolution_arg(last_used_results); on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - // Reset results_upon_error. - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator, nullptr); - // Flush here to guarantee that results_upon_error has been reset. + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Reset reresolution_results. + response_generator->SetReresolutionResponse(nullptr); + // Flush here to guarantee that reresolution_results has been reset. grpc_core::ExecCtx::Get()->Flush(); // Trigger a re-resolution. - grpc_resolver_channel_saw_error_locked(resolver); + resolver->RequestReresolutionLocked(); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); @@ -234,16 +226,15 @@ static void test_fake_resolver() { // Requesting a new resolution without setting the response shouldn't trigger // the resolution callback. memset(&on_res_arg, 0, sizeof(on_res_arg)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr); // Clean up. GRPC_COMBINER_UNREF(combiner, "test_fake_resolver"); - GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver"); - grpc_fake_resolver_response_generator_unref(response_generator); } int main(int argc, char** argv) { diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc index 07ee133ee3..b9287c2468 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc @@ -40,18 +40,18 @@ void on_resolution_cb(void* arg, grpc_error* error) { grpc_channel_args_destroy(res->resolver_result); } -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); on_resolution_arg on_res_arg; @@ -60,40 +60,39 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) { grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_uri_destroy(uri); /* Flush ExecCtx to avoid stack-use-after-scope on on_res_arg which is * accessed in the closure on_resolution_cb */ grpc_core::ExecCtx::Get()->Flush(); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory *ipv4, *ipv6; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - ipv4 = grpc_resolver_factory_lookup("ipv4"); - ipv6 = grpc_resolver_factory_lookup("ipv6"); + grpc_core::ResolverFactory* ipv4 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv4"); + grpc_core::ResolverFactory* ipv6 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv6"); test_fails(ipv4, "ipv4:10.2.1.1"); test_succeeds(ipv4, "ipv4:10.2.1.1:1234"); @@ -109,9 +108,6 @@ int main(int argc, char** argv) { test_fails(ipv6, "ipv6:[::]:123456"); test_fails(ipv6, "ipv6:www.google.com"); - grpc_resolver_factory_unref(ipv4); - grpc_resolver_factory_unref(ipv6); - { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba b/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba Binary files differnew file mode 100644 index 0000000000..89e28bbe37 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba diff --git a/test/core/gpr/tls_test.cc b/test/core/gpr/tls_test.cc index 743b10f090..1ef253ed6f 100644 --- a/test/core/gpr/tls_test.cc +++ b/test/core/gpr/tls_test.cc @@ -21,9 +21,10 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/tls.h> #include <stdio.h> #include <stdlib.h> + +#include "src/core/lib/gpr/tls.h" #include "test/core/util/test_config.h" #define NUM_THREADS 100 diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc index 37247f89d0..56f4f602e8 100644 --- a/test/core/surface/channel_create_test.cc +++ b/test/core/surface/channel_create_test.cc @@ -29,8 +29,8 @@ void test_unknown_scheme_target(void) { grpc_channel* chan; /* avoid default prefix */ - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr); GPR_ASSERT(chan != nullptr); diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index 2dd6dc86a0..14267c1214 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -55,7 +55,6 @@ #include <grpc/support/sync_generic.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/tls.h> #include <grpc/support/workaround_list.h> #include <stdio.h> diff --git a/test/core/surface/secure_channel_create_test.cc b/test/core/surface/secure_channel_create_test.cc index fa22cd6873..c10d6796a7 100644 --- a/test/core/surface/secure_channel_create_test.cc +++ b/test/core/surface/secure_channel_create_test.cc @@ -28,8 +28,8 @@ #include "test/core/util/test_config.h" void test_unknown_scheme_target(void) { - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); grpc_channel_credentials* creds = grpc_fake_transport_security_credentials_create(); grpc_channel* chan = diff --git a/test/cpp/client/client_channel_stress_test.cc b/test/cpp/client/client_channel_stress_test.cc index 80d1583333..bb8553f56a 100644 --- a/test/cpp/client/client_channel_stress_test.cc +++ b/test/cpp/client/client_channel_stress_test.cc @@ -36,6 +36,7 @@ #include <grpc/support/time.h> #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -230,8 +231,7 @@ class ClientChannelStressTest { } grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -253,9 +253,10 @@ class ClientChannelStressTest { void CreateStub() { ChannelArguments args; - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -298,7 +299,6 @@ class ClientChannelStressTest { for (size_t i = 0; i < backends_.size(); ++i) { backend_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } std::atomic_bool shutdown_{false}; @@ -310,7 +310,8 @@ class ClientChannelStressTest { std::vector<std::unique_ptr<BalancerServiceImpl>> balancers_; std::vector<ServerThread<BackendServiceImpl>> backend_servers_; std::vector<ServerThread<BalancerServiceImpl>> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; std::vector<std::thread> client_threads_; }; diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 44cd81a6a4..482f0cb24f 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -32,9 +32,9 @@ #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/tls.h> #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index ee5adbc6fa..386d18e95d 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -40,6 +40,7 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -119,11 +120,11 @@ class ClientLbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); } void TearDown() override { - grpc_fake_resolver_response_generator_unref(response_generator_); for (size_t i = 0; i < servers_.size(); ++i) { servers_[i]->Shutdown(); } @@ -153,13 +154,9 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } - const grpc_arg fake_addresses = - grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); - grpc_fake_resolver_response_generator_set_response(response_generator_, - fake_result); - grpc_channel_args_destroy(fake_result); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -178,13 +175,9 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } - const grpc_arg fake_addresses = - grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator_, fake_result); - grpc_channel_args_destroy(fake_result); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -206,7 +199,7 @@ class ClientLbEnd2endTest : public ::testing::Test { args.SetLoadBalancingPolicyName(lb_policy_name); } // else, default to pick first args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); return CreateCustomChannel("fake:///", InsecureChannelCredentials(), args); } @@ -323,7 +316,8 @@ class ClientLbEnd2endTest : public ::testing::Test { const grpc::string server_host_; std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; std::vector<std::unique_ptr<ServerData>> servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; const grpc::string kRequestMessage_; }; diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 5591acf880..89c9c2bf76 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -35,6 +35,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -339,7 +340,8 @@ class GrpclbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); // Start the backends. for (size_t i = 0; i < num_backends_; ++i) { backends_.emplace_back(new BackendServiceImpl()); @@ -363,7 +365,6 @@ class GrpclbEnd2endTest : public ::testing::Test { for (size_t i = 0; i < balancers_.size(); ++i) { if (balancers_[i]->Shutdown()) balancer_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } void SetNextResolutionAllBalancers() { @@ -378,7 +379,7 @@ class GrpclbEnd2endTest : public ::testing::Test { ChannelArguments args; args.SetGrpclbFallbackTimeout(fallback_timeout); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -478,20 +479,18 @@ class GrpclbEnd2endTest : public ::testing::Test { CreateLbAddressesFromAddressDataList(address_data); grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } - void SetNextResolutionUponError( + void SetNextReresolutionResponse( const std::vector<AddressData>& address_data) { grpc_core::ExecCtx exec_ctx; grpc_lb_addresses* addresses = CreateLbAddressesFromAddressDataList(address_data); grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response_upon_error( - response_generator_, &fake_result); + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -593,7 +592,8 @@ class GrpclbEnd2endTest : public ::testing::Test { std::vector<std::unique_ptr<BalancerServiceImpl>> balancers_; std::vector<ServerThread<BackendService>> backend_servers_; std::vector<ServerThread<BalancerService>> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; const grpc::string kRequestMessage_ = "Live long and prosper."; }; diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 4a9fd7ce76..06ab8c3ff8 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -43,6 +43,7 @@ #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/lib/surface/channel.h" @@ -558,8 +559,8 @@ static void setup_client(const server_fixture* lb_server, const char* backends_name = lb_server->servers_hostport; gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); + auto response_generator = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr); char* lb_uri_str; @@ -578,25 +579,22 @@ static void setup_client(const server_fixture* lb_server, grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); grpc_lb_addresses_destroy(addresses); - const grpc_arg new_args[] = { + grpc_arg new_args[] = { grpc_fake_transport_expected_targets_arg(expected_target_names), - grpc_fake_resolver_response_generator_arg(response_generator)}; + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator.get())}; - grpc_channel_args* args = grpc_channel_args_copy_and_add( - nullptr, new_args, GPR_ARRAY_SIZE(new_args)); - gpr_free(expected_target_names); + grpc_channel_args args = {GPR_ARRAY_SIZE(new_args), new_args}; cf->cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel_credentials* fake_creds = grpc_fake_transport_security_credentials_create(); cf->client = - grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr); - grpc_fake_resolver_response_generator_set_response(response_generator, - fake_result); + grpc_secure_channel_create(fake_creds, cf->server_uri, &args, nullptr); + response_generator->SetResponse(fake_result); grpc_channel_args_destroy(fake_result); grpc_channel_credentials_unref(fake_creds); - grpc_channel_args_destroy(args); - grpc_fake_resolver_response_generator_unref(response_generator); + gpr_free(expected_target_names); } static void teardown_client(client_fixture* cf) { diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index aad2fa5f75..f4be064305 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -39,6 +39,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -61,11 +62,9 @@ using namespace gflags; DEFINE_string(target_name, "", "Target name to resolve."); DEFINE_string(expected_addrs, "", - "Comma-separated list of expected " - "'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...' " - "addresses of " - "backend and/or balancers. 'is_balancer' should be bool, i.e. " - "true or false."); + "List of expected backend or balancer addresses in the form " + "'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...'. " + "'is_balancer' should be bool, i.e. true or false."); DEFINE_string(expected_chosen_service_config, "", "Expected service config json string that gets chosen (no " "whitespace). Empty for none."); @@ -102,12 +101,10 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { // get the next <ip>,<port> (v4 or v6) size_t next_comma = expected_addrs.find(","); if (next_comma == std::string::npos) { - gpr_log( - GPR_ERROR, - "Missing ','. Expected_addrs arg should be a semi-colon-separated " - "list of " - "<ip-port>,<bool> pairs. Left-to-be-parsed arg is |%s|", - expected_addrs.c_str()); + gpr_log(GPR_ERROR, + "Missing ','. Expected_addrs arg should be a semicolon-separated " + "list of <ip-port>,<bool> pairs. Left-to-be-parsed arg is |%s|", + expected_addrs.c_str()); abort(); } std::string next_addr = expected_addrs.substr(0, next_comma); @@ -125,7 +122,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { } if (out.size() == 0) { gpr_log(GPR_ERROR, - "expected_addrs arg should be a comma-separated list of " + "expected_addrs arg should be a semicolon-separated list of " "<ip-port>,<bool> pairs"); abort(); } @@ -287,17 +284,16 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { FLAGS_local_dns_server_address.c_str(), FLAGS_target_name.c_str())); // create resolver and resolve - grpc_resolver* resolver = - grpc_resolver_create(whole_uri, nullptr, args.pollset_set, args.lock); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + grpc_core::ResolverRegistry::CreateResolver(whole_uri, nullptr, + args.pollset_set, args.lock); gpr_free(whole_uri); grpc_closure on_resolver_result_changed; GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked, (void*)&args, grpc_combiner_scheduler(args.lock)); - grpc_resolver_next_locked(resolver, &args.channel_args, - &on_resolver_result_changed); + resolver->NextLocked(&args.channel_args, &on_resolver_result_changed); grpc_core::ExecCtx::Get()->Flush(); PollPollsetUntilRequestDone(&args); - GRPC_RESOLVER_UNREF(resolver, nullptr); ArgsFinish(&args); } |