Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local_info.node() instead of bootstrap.node() whenever possible #4120

Merged
merged 7 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions source/common/config/grpc_mux_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
namespace Envoy {
namespace Config {

GrpcMuxImpl::GrpcMuxImpl(const envoy::api::v2::core::Node& node, Grpc::AsyncClientPtr async_client,
GrpcMuxImpl::GrpcMuxImpl(const LocalInfo::LocalInfo& local_info, Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher,
const Protobuf::MethodDescriptor& service_method,
Runtime::RandomGenerator& random, MonotonicTimeSource& time_source)
: node_(node), async_client_(std::move(async_client)), service_method_(service_method),
random_(random), time_source_(time_source) {
: local_info_(local_info), async_client_(std::move(async_client)),
service_method_(service_method), random_(random), time_source_(time_source) {
Config::Utility::checkLocalInfo("ads", local_info);
retry_timer_ = dispatcher.createTimer([this]() -> void { establishNewStream(); });
backoff_strategy_ = std::make_unique<JitteredBackOffStrategy>(RETRY_INITIAL_DELAY_MS,
RETRY_MAX_DELAY_MS, random_);
Expand Down Expand Up @@ -114,7 +115,7 @@ GrpcMuxWatchPtr GrpcMuxImpl::subscribe(const std::string& type_url,
// Bucket contains 1 token maximum and refills 1 token on every ~5 seconds.
api_state_[type_url].limit_log_ = std::make_unique<TokenBucketImpl>(1, 0.2, time_source_);
api_state_[type_url].request_.set_type_url(type_url);
api_state_[type_url].request_.mutable_node()->MergeFrom(node_);
api_state_[type_url].request_.mutable_node()->MergeFrom(local_info_.node());
api_state_[type_url].subscribed_ = true;
subscriptions_.emplace_back(type_url);
}
Expand Down
4 changes: 2 additions & 2 deletions source/common/config/grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GrpcMuxImpl : public GrpcMux,
Grpc::TypedAsyncStreamCallbacks<envoy::api::v2::DiscoveryResponse>,
Logger::Loggable<Logger::Id::upstream> {
public:
GrpcMuxImpl(const envoy::api::v2::core::Node& node, Grpc::AsyncClientPtr async_client,
GrpcMuxImpl(const LocalInfo::LocalInfo& local_info, Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method,
Runtime::RandomGenerator& random,
MonotonicTimeSource& time_source = ProdMonotonicTimeSource::instance_);
Expand Down Expand Up @@ -95,7 +95,7 @@ class GrpcMuxImpl : public GrpcMux,
TokenBucketPtr limit_log_;
};

envoy::api::v2::core::Node node_;
const LocalInfo::LocalInfo& local_info_;
Grpc::AsyncClientPtr async_client_;
Grpc::AsyncStream* stream_{};
const Protobuf::MethodDescriptor& service_method_;
Expand Down
4 changes: 2 additions & 2 deletions source/common/config/grpc_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace Config {
template <class ResourceType>
class GrpcSubscriptionImpl : public Config::Subscription<ResourceType> {
public:
GrpcSubscriptionImpl(const envoy::api::v2::core::Node& node, Grpc::AsyncClientPtr async_client,
GrpcSubscriptionImpl(const LocalInfo::LocalInfo& local_info, Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random,
const Protobuf::MethodDescriptor& service_method, SubscriptionStats stats)
: grpc_mux_(node, std::move(async_client), dispatcher, service_method, random),
: grpc_mux_(local_info, std::move(async_client), dispatcher, service_method, random),
grpc_mux_subscription_(grpc_mux_, stats) {}

// Config::Subscription
Expand Down
4 changes: 2 additions & 2 deletions source/common/config/http_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher,
public Config::Subscription<ResourceType>,
Logger::Loggable<Logger::Id::config> {
public:
HttpSubscriptionImpl(const envoy::api::v2::core::Node& node, Upstream::ClusterManager& cm,
HttpSubscriptionImpl(const LocalInfo::LocalInfo& local_info, Upstream::ClusterManager& cm,
const std::string& remote_cluster_name, Event::Dispatcher& dispatcher,
Runtime::RandomGenerator& random, std::chrono::milliseconds refresh_interval,
std::chrono::milliseconds request_timeout,
const Protobuf::MethodDescriptor& service_method, SubscriptionStats stats)
: Http::RestApiFetcher(cm, remote_cluster_name, dispatcher, random, refresh_interval,
request_timeout),
stats_(stats) {
request_.mutable_node()->CopyFrom(node);
request_.mutable_node()->CopyFrom(local_info.node());
ASSERT(service_method.options().HasExtension(google::api::http));
const auto& http_rule = service_method.options().GetExtension(google::api::http);
path_ = http_rule.post();
Expand Down
8 changes: 4 additions & 4 deletions source/common/config/subscription_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SubscriptionFactory {
/**
* Subscription factory.
* @param config envoy::api::v2::core::ConfigSource to construct from.
* @param node envoy::api::v2::core::Node identifier.
* @param local_info LocalInfo::LocalInfo local info.
* @param dispatcher event dispatcher.
* @param cm cluster manager for async clients (when REST/gRPC).
* @param random random generator for jittering polling delays (when REST).
Expand All @@ -37,7 +37,7 @@ class SubscriptionFactory {
*/
template <class ResourceType>
static std::unique_ptr<Subscription<ResourceType>> subscriptionFromConfigSource(
const envoy::api::v2::core::ConfigSource& config, const envoy::api::v2::core::Node& node,
const envoy::api::v2::core::ConfigSource& config, const LocalInfo::LocalInfo& local_info,
Event::Dispatcher& dispatcher, Upstream::ClusterManager& cm, Runtime::RandomGenerator& random,
Stats::Scope& scope, std::function<Subscription<ResourceType>*()> rest_legacy_constructor,
const std::string& rest_method, const std::string& grpc_method) {
Expand All @@ -59,14 +59,14 @@ class SubscriptionFactory {
break;
case envoy::api::v2::core::ApiConfigSource::REST:
result.reset(new HttpSubscriptionImpl<ResourceType>(
node, cm, api_config_source.cluster_names()[0], dispatcher, random,
local_info, cm, api_config_source.cluster_names()[0], dispatcher, random,
Utility::apiConfigSourceRefreshDelay(api_config_source),
Utility::apiConfigSourceRequestTimeout(api_config_source),
*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(rest_method), stats));
break;
case envoy::api::v2::core::ApiConfigSource::GRPC: {
result.reset(new GrpcSubscriptionImpl<ResourceType>(
node,
local_info,
Config::Utility::factoryForGrpcApiConfigSource(cm.grpcAsyncClientManager(),
config.api_config_source(), scope)
->create(),
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/rds_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RdsRouteConfigSubscription::RdsRouteConfigSubscription(

subscription_ = Envoy::Config::SubscriptionFactory::subscriptionFromConfigSource<
envoy::api::v2::RouteConfiguration>(
rds.config_source(), factory_context.localInfo().node(), factory_context.dispatcher(),
rds.config_source(), factory_context.localInfo(), factory_context.dispatcher(),
factory_context.clusterManager(), factory_context.random(), *scope_,
[this, &rds,
&factory_context]() -> Envoy::Config::Subscription<envoy::api::v2::RouteConfiguration>* {
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/cds_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CdsApiImpl::CdsApiImpl(const envoy::api::v2::core::ConfigSource& cds_config,

subscription_ =
Config::SubscriptionFactory::subscriptionFromConfigSource<envoy::api::v2::Cluster>(
cds_config, local_info.node(), dispatcher, cm, random, *scope_,
cds_config, local_info, dispatcher, cm, random, *scope_,
[this, &cds_config, &eds_config, &cm, &dispatcher, &random, &local_info,
&scope]() -> Config::Subscription<envoy::api::v2::Cluster>* {
return new CdsSubscription(Config::Utility::generateStats(*scope_), cds_config,
Expand Down
4 changes: 2 additions & 2 deletions source/common/upstream/cluster_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ClusterManagerImpl::ClusterManagerImpl(const envoy::config::bootstrap::v2::Boots
// Now setup ADS if needed, this might rely on a primary cluster.
if (bootstrap.dynamic_resources().has_ads_config()) {
ads_mux_.reset(new Config::GrpcMuxImpl(
bootstrap.node(),
local_info,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed opinions on this change. On the one hand, we make it more full proof, by forcing the LocalInfo type. On the other, we are now passing a strict superset of what we were passing before, and the new information is not used. My main thoughts on making LocalInfo canonical would be to just delete the node info from bootstrap very early in server init. But, this approach also works..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting POV, will try to explore that too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessarily the correct PoV; just sharing where my thinking was originally :)

Config::Utility::factoryForGrpcApiConfigSource(
*async_client_manager_, bootstrap.dynamic_resources().ads_config(), stats)
->create(),
Expand Down Expand Up @@ -301,7 +301,7 @@ ClusterManagerImpl::ClusterManagerImpl(const envoy::config::bootstrap::v2::Boots
if (cm_config.has_load_stats_config()) {
const auto& load_stats_config = cm_config.load_stats_config();
load_stats_reporter_.reset(
new LoadStatsReporter(bootstrap.node(), *this, stats,
new LoadStatsReporter(local_info, *this, stats,
Config::Utility::factoryForGrpcApiConfigSource(
*async_client_manager_, load_stats_config, stats)
->create(),
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/eds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ EdsClusterImpl::EdsClusterImpl(
Upstream::ClusterManager& cm = factory_context.clusterManager();
subscription_ = Config::SubscriptionFactory::subscriptionFromConfigSource<
envoy::api::v2::ClusterLoadAssignment>(
eds_config, local_info_.node(), dispatcher, cm, random, info_->statsScope(),
eds_config, local_info_, dispatcher, cm, random, info_->statsScope(),
[this, &eds_config, &cm, &dispatcher,
&random]() -> Config::Subscription<envoy::api::v2::ClusterLoadAssignment>* {
return new SdsSubscription(info_->stats(), eds_config, cm, dispatcher, random);
Expand Down
4 changes: 2 additions & 2 deletions source/common/upstream/load_stats_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Envoy {
namespace Upstream {

LoadStatsReporter::LoadStatsReporter(const envoy::api::v2::core::Node& node,
LoadStatsReporter::LoadStatsReporter(const LocalInfo::LocalInfo& local_info,
ClusterManager& cluster_manager, Stats::Scope& scope,
Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher,
Expand All @@ -18,7 +18,7 @@ LoadStatsReporter::LoadStatsReporter(const envoy::api::v2::core::Node& node,
service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.load_stats.v2.LoadReportingService.StreamLoadStats")),
time_source_(time_source) {
request_.mutable_node()->MergeFrom(node);
request_.mutable_node()->MergeFrom(local_info.node());
retry_timer_ = dispatcher.createTimer([this]() -> void { establishNewStream(); });
response_timer_ = dispatcher.createTimer([this]() -> void { sendLoadStatsRequest(); });
establishNewStream();
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/load_stats_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LoadStatsReporter
: Grpc::TypedAsyncStreamCallbacks<envoy::service::load_stats::v2::LoadStatsResponse>,
Logger::Loggable<Logger::Id::upstream> {
public:
LoadStatsReporter(const envoy::api::v2::core::Node& node, ClusterManager& cluster_manager,
LoadStatsReporter(const LocalInfo::LocalInfo& local_info, ClusterManager& cluster_manager,
Stats::Scope& scope, Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher, MonotonicTimeSource& time_source);

Expand Down
2 changes: 1 addition & 1 deletion source/server/lds_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LdsApiImpl::LdsApiImpl(const envoy::api::v2::core::ConfigSource& lds_config,
: listener_manager_(lm), scope_(scope.createScope("listener_manager.lds.")), cm_(cm) {
subscription_ =
Envoy::Config::SubscriptionFactory::subscriptionFromConfigSource<envoy::api::v2::Listener>(
lds_config, local_info.node(), dispatcher, cm, random, *scope_,
lds_config, local_info, dispatcher, cm, random, *scope_,
[this, &lds_config, &cm, &dispatcher, &random, &local_info,
&scope]() -> Config::Subscription<envoy::api::v2::Listener>* {
return new LdsSubscription(Config::Utility::generateStats(*scope_), lds_config, cm,
Expand Down
4 changes: 4 additions & 0 deletions test/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ envoy_cc_test(
"//test/mocks/config:config_mocks",
"//test/mocks/event:event_mocks",
"//test/mocks/grpc:grpc_mocks",
"//test/mocks/local_info:local_info_mocks",
"//test/mocks/runtime:runtime_mocks",
"//test/test_common:logging_lib",
"//test/test_common:utility_lib",
Expand Down Expand Up @@ -75,6 +76,7 @@ envoy_cc_test_library(
"//test/mocks/config:config_mocks",
"//test/mocks/event:event_mocks",
"//test/mocks/grpc:grpc_mocks",
"//test/mocks/local_info:local_info_mocks",
"//test/mocks/upstream:upstream_mocks",
"//test/test_common:utility_lib",
"@envoy_api//envoy/api/v2:eds_cc",
Expand All @@ -101,6 +103,7 @@ envoy_cc_test_library(
"//source/common/http:message_lib",
"//test/mocks/config:config_mocks",
"//test/mocks/event:event_mocks",
"//test/mocks/local_info:local_info_mocks",
"//test/mocks/runtime:runtime_mocks",
"//test/mocks/upstream:upstream_mocks",
"//test/test_common:utility_lib",
Expand All @@ -116,6 +119,7 @@ envoy_cc_test(
"//test/mocks/config:config_mocks",
"//test/mocks/event:event_mocks",
"//test/mocks/filesystem:filesystem_mocks",
"//test/mocks/local_info:local_info_mocks",
"//test/mocks/runtime:runtime_mocks",
"//test/mocks/stats:stats_mocks",
"//test/mocks/upstream:upstream_mocks",
Expand Down
50 changes: 44 additions & 6 deletions test/common/config/grpc_mux_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "test/mocks/config/mocks.h"
#include "test/mocks/event/mocks.h"
#include "test/mocks/grpc/mocks.h"
#include "test/mocks/local_info/mocks.h"
#include "test/mocks/runtime/mocks.h"
#include "test/test_common/logging.h"
#include "test/test_common/utility.h"
Expand All @@ -33,16 +34,17 @@ namespace {
// is provided in [grpc_]subscription_impl_test.cc.
class GrpcMuxImplTest : public testing::Test {
public:
GrpcMuxImplTest()
: async_client_(new Grpc::MockAsyncClient()), timer_(new Event::MockTimer()), time_source_{} {
GrpcMuxImplTest() : async_client_(new Grpc::MockAsyncClient()), time_source_{} {}

void setup() {
EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([this](Event::TimerCb timer_cb) {
timer_cb_ = timer_cb;
timer_ = new Event::MockTimer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change?

Copy link
Member Author

@dio dio Aug 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the newly introduced tests do not call setup(), and timer_ was previously initialized as new Event::MockTimer() at constructor, this makes sure no leak. Caught by LeakSanitizer in this build: https://circleci.com/gh/envoyproxy/envoy/84216.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah if we go with the other direction it will be reverted.

return timer_;
}));

grpc_mux_.reset(new GrpcMuxImpl(
envoy::api::v2::core::Node(), std::unique_ptr<Grpc::MockAsyncClient>(async_client_),
dispatcher_,
local_info_, std::unique_ptr<Grpc::MockAsyncClient>(async_client_), dispatcher_,
*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.discovery.v2.AggregatedDiscoveryService.StreamAggregatedResources"),
random_, time_source_));
Expand All @@ -54,7 +56,7 @@ class GrpcMuxImplTest : public testing::Test {
const Protobuf::int32 error_code = Grpc::Status::GrpcStatus::Ok,
const std::string& error_message = "") {
envoy::api::v2::DiscoveryRequest expected_request;
expected_request.mutable_node()->CopyFrom(node_);
expected_request.mutable_node()->CopyFrom(local_info_.node());
for (const auto& resource : resource_names) {
expected_request.add_resource_names(resource);
}
Expand All @@ -71,7 +73,6 @@ class GrpcMuxImplTest : public testing::Test {
EXPECT_CALL(async_stream_, sendMessage(ProtoEq(expected_request), false));
}

envoy::api::v2::core::Node node_;
NiceMock<Event::MockDispatcher> dispatcher_;
Runtime::MockRandomGenerator random_;
Grpc::MockAsyncClient* async_client_;
Expand All @@ -81,11 +82,13 @@ class GrpcMuxImplTest : public testing::Test {
std::unique_ptr<GrpcMuxImpl> grpc_mux_;
NiceMock<MockGrpcMuxCallbacks> callbacks_;
NiceMock<MockMonotonicTimeSource> time_source_;
NiceMock<LocalInfo::MockLocalInfo> local_info_;
};

// Validate behavior when multiple type URL watches are maintained, watches are created/destroyed
// (via RAII).
TEST_F(GrpcMuxImplTest, MultipleTypeUrlStreams) {
setup();
InSequence s;
auto foo_sub = grpc_mux_->subscribe("foo", {"x", "y"}, callbacks_);
auto bar_sub = grpc_mux_->subscribe("bar", {}, callbacks_);
Expand All @@ -104,6 +107,7 @@ TEST_F(GrpcMuxImplTest, MultipleTypeUrlStreams) {

// Validate behavior when multiple type URL watches are maintained and the stream is reset.
TEST_F(GrpcMuxImplTest, ResetStream) {
setup();
InSequence s;
auto foo_sub = grpc_mux_->subscribe("foo", {"x", "y"}, callbacks_);
auto bar_sub = grpc_mux_->subscribe("bar", {}, callbacks_);
Expand All @@ -129,6 +133,7 @@ TEST_F(GrpcMuxImplTest, ResetStream) {

// Validate pause-resume behavior.
TEST_F(GrpcMuxImplTest, PauseResume) {
setup();
InSequence s;
auto foo_sub = grpc_mux_->subscribe("foo", {"x", "y"}, callbacks_);
grpc_mux_->pause("foo");
Expand All @@ -149,6 +154,7 @@ TEST_F(GrpcMuxImplTest, PauseResume) {

// Validate behavior when type URL mismatches occur.
TEST_F(GrpcMuxImplTest, TypeUrlMismatch) {
setup();

std::unique_ptr<envoy::api::v2::DiscoveryResponse> invalid_response(
new envoy::api::v2::DiscoveryResponse());
Expand Down Expand Up @@ -184,6 +190,8 @@ TEST_F(GrpcMuxImplTest, TypeUrlMismatch) {

// Validate behavior when watches has an unknown resource name.
TEST_F(GrpcMuxImplTest, WildcardWatch) {
setup();

InSequence s;
const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
auto foo_sub = grpc_mux_->subscribe(type_url, {}, callbacks_);
Expand Down Expand Up @@ -215,6 +223,8 @@ TEST_F(GrpcMuxImplTest, WildcardWatch) {

// Validate behavior when watches specify resources (potentially overlapping).
TEST_F(GrpcMuxImplTest, WatchDemux) {
setup();

InSequence s;
const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
NiceMock<MockGrpcMuxCallbacks> foo_callbacks;
Expand Down Expand Up @@ -296,6 +306,8 @@ TEST_F(GrpcMuxImplTest, WatchDemux) {

// Verifies that warning messages get logged when Envoy detects too many requests.
TEST_F(GrpcMuxImplTest, TooManyRequests) {
setup();

EXPECT_CALL(async_stream_, sendMessage(_, false)).Times(AtLeast(100));
EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
EXPECT_CALL(time_source_, currentTime())
Expand Down Expand Up @@ -342,6 +354,8 @@ TEST_F(GrpcMuxImplTest, TooManyRequests) {

// Verifies that a messsage with no resources is accepted.
TEST_F(GrpcMuxImplTest, UnwatchedTypeAcceptsEmptyResources) {
setup();

EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));

const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
Expand Down Expand Up @@ -374,6 +388,8 @@ TEST_F(GrpcMuxImplTest, UnwatchedTypeAcceptsEmptyResources) {

// Verifies that a messsage with some resources is rejected when there are no watches.
TEST_F(GrpcMuxImplTest, UnwatchedTypeRejectsResources) {
setup();

EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));

const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
Expand Down Expand Up @@ -402,6 +418,28 @@ TEST_F(GrpcMuxImplTest, UnwatchedTypeRejectsResources) {
grpc_mux_->onReceiveMessage(std::move(response)));
}

TEST_F(GrpcMuxImplTest, BadLocalInfoEmptyClusterName) {
EXPECT_CALL(local_info_, clusterName()).WillOnce(Return(""));
EXPECT_THROW_WITH_MESSAGE(
GrpcMuxImpl(
local_info_, std::unique_ptr<Grpc::MockAsyncClient>(async_client_), dispatcher_,
*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.discovery.v2.AggregatedDiscoveryService.StreamAggregatedResources"),
random_, time_source_),
EnvoyException, "ads: setting --service-cluster and --service-node is required");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: these error messages are misleading nowadays, since you can specify this same information in the bootstrap.

Copy link
Member Author

@dio dio Aug 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some difficulties with crafting related test before, so I guess I need to read more on bootstrap initialization steps (server init).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should revisit the thrown error message from Config::Utility::checkLocalInfo(_, _);.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the message, not sure about its clarity and correctness.

}

TEST_F(GrpcMuxImplTest, BadLocalInfoEmptyNodeName) {
EXPECT_CALL(local_info_, nodeName()).WillOnce(Return(""));
EXPECT_THROW_WITH_MESSAGE(
GrpcMuxImpl(
local_info_, std::unique_ptr<Grpc::MockAsyncClient>(async_client_), dispatcher_,
*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.discovery.v2.AggregatedDiscoveryService.StreamAggregatedResources"),
random_, time_source_),
EnvoyException, "ads: setting --service-cluster and --service-node is required");
}

} // namespace
} // namespace Config
} // namespace Envoy
Loading