diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 995182da249..39d3b1d5eeb 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channelz.h" @@ -33,7 +34,6 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/json/json.h" #include "src/core/lib/surface/channel.h" - #include "test/core/util/test_config.h" #include @@ -51,9 +51,13 @@ class ChannelzRegistryTest : public ::testing::Test { void TearDown() override { ChannelzRegistry::Shutdown(); } }; +static RefCountedPtr CreateTestNode() { + return MakeRefCounted(UniquePtr(gpr_strdup("test")), + UniquePtr(gpr_strdup("test"))); +} + TEST_F(ChannelzRegistryTest, UuidStartsAboveZeroTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); intptr_t uuid = channelz_channel->uuid(); EXPECT_GT(uuid, 0) << "First uuid chose must be greater than zero. Zero if " "reserved according to " @@ -65,8 +69,7 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { std::vector> channelz_channels; channelz_channels.reserve(10); for (int i = 0; i < 10; ++i) { - channelz_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + channelz_channels.push_back(CreateTestNode()); } for (size_t i = 1; i < channelz_channels.size(); ++i) { EXPECT_LT(channelz_channels[i - 1]->uuid(), channelz_channels[i]->uuid()) @@ -75,8 +78,7 @@ TEST_F(ChannelzRegistryTest, UuidsAreIncreasing) { } TEST_F(ChannelzRegistryTest, RegisterGetTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channel->uuid()); EXPECT_EQ(channelz_channel, retrieved); @@ -85,8 +87,7 @@ TEST_F(ChannelzRegistryTest, RegisterGetTest) { TEST_F(ChannelzRegistryTest, RegisterManyItems) { std::vector> channelz_channels; for (int i = 0; i < 100; i++) { - channelz_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + channelz_channels.push_back(CreateTestNode()); RefCountedPtr retrieved = ChannelzRegistry::Get(channelz_channels[i]->uuid()); EXPECT_EQ(channelz_channels[i], retrieved); @@ -94,8 +95,7 @@ TEST_F(ChannelzRegistryTest, RegisterManyItems) { } TEST_F(ChannelzRegistryTest, NullIfNotPresentTest) { - RefCountedPtr channelz_channel = - MakeRefCounted(BaseNode::EntityType::kTopLevelChannel, nullptr); + RefCountedPtr channelz_channel = CreateTestNode(); // try to pull out a uuid that does not exist. RefCountedPtr nonexistant = ChannelzRegistry::Get(channelz_channel->uuid() + 1); @@ -117,10 +117,8 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> odd_channels; odd_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - even_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); - odd_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + even_channels.push_back(CreateTestNode()); + odd_channels.push_back(CreateTestNode()); odd_uuids.push_back(odd_channels[i]->uuid()); } } @@ -137,8 +135,7 @@ TEST_F(ChannelzRegistryTest, TestUnregistration) { std::vector> more_channels; more_channels.reserve(kLoopIterations); for (int i = 0; i < kLoopIterations; i++) { - more_channels.push_back(MakeRefCounted( - BaseNode::EntityType::kTopLevelChannel, nullptr)); + more_channels.push_back(CreateTestNode()); RefCountedPtr retrieved = ChannelzRegistry::Get(more_channels[i]->uuid()); EXPECT_EQ(more_channels[i], retrieved); diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 129866b7d7f..ce44fd51b82 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -24,11 +24,23 @@ #include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #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 "test/core/util/test_config.h" static grpc_combiner* g_combiner; +class TestResultHandler : public grpc_core::Resolver::ResultHandler { + void ReturnResult(grpc_core::Resolver::Result result) override {} + void ReturnError(grpc_error* error) override {} +}; + +static grpc_core::UniquePtr +create_test_result_handler() { + return grpc_core::UniquePtr( + grpc_core::New()); +} + static void test_succeeds(grpc_core::ResolverFactory* factory, const char* string) { gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, @@ -39,8 +51,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory, grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - args.result_handler = - grpc_core::MakeUnique(); + args.result_handler = create_test_result_handler(); grpc_core::OrphanablePtr resolver = factory->CreateResolver(std::move(args)); GPR_ASSERT(resolver != nullptr); @@ -57,8 +68,7 @@ static void test_fails(grpc_core::ResolverFactory* factory, grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - args.result_handler = - grpc_core::MakeUnique(); + args.result_handler = create_test_result_handler(); grpc_core::OrphanablePtr resolver = factory->CreateResolver(std::move(args)); GPR_ASSERT(resolver == nullptr); diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index 5ee2f5fe049..77e186c6d49 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -233,6 +233,11 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory { return kInterceptRecvTrailingMetadataLbPolicyName; } + RefCountedPtr ParseLoadBalancingConfig( + const grpc_json* json, grpc_error** error) const override { + return nullptr; + } + private: InterceptRecvTrailingMetadataCallback cb_; void* user_data_;