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

[test host utils] use make_shared to avoid memory leaks #14042

Merged
merged 3 commits into from
Nov 16, 2020
Merged
Changes from all 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
40 changes: 20 additions & 20 deletions test/common/upstream/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,48 +79,48 @@ inline envoy::config::cluster::v3::Cluster defaultStaticCluster(const std::strin

inline HostSharedPtr makeTestHost(ClusterInfoConstSharedPtr cluster, const std::string& hostname,
const std::string& url, uint32_t weight = 1) {
return HostSharedPtr{
new HostImpl(cluster, hostname, Network::Utility::resolveUrl(url), nullptr, weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0,
envoy::config::core::v3::UNKNOWN)};
return std::make_shared<HostImpl>(
cluster, hostname, Network::Utility::resolveUrl(url), nullptr, weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0,
envoy::config::core::v3::UNKNOWN);
}

inline HostSharedPtr makeTestHost(ClusterInfoConstSharedPtr cluster, const std::string& url,
uint32_t weight = 1, uint32_t priority = 0) {
return HostSharedPtr{
new HostImpl(cluster, "", Network::Utility::resolveUrl(url), nullptr, weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(),
priority, envoy::config::core::v3::UNKNOWN)};
return std::make_shared<HostImpl>(
cluster, "", Network::Utility::resolveUrl(url), nullptr, weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), priority,
envoy::config::core::v3::UNKNOWN);
}

inline HostSharedPtr makeTestHost(ClusterInfoConstSharedPtr cluster, const std::string& url,
const envoy::config::core::v3::Metadata& metadata,
uint32_t weight = 1) {
return HostSharedPtr{
new HostImpl(cluster, "", Network::Utility::resolveUrl(url),
std::make_shared<const envoy::config::core::v3::Metadata>(metadata), weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0,
envoy::config::core::v3::UNKNOWN)};
return std::make_shared<HostImpl>(
cluster, "", Network::Utility::resolveUrl(url),
std::make_shared<const envoy::config::core::v3::Metadata>(metadata), weight,
envoy::config::core::v3::Locality(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0,
envoy::config::core::v3::UNKNOWN);
}

inline HostSharedPtr
makeTestHost(ClusterInfoConstSharedPtr cluster, const std::string& url,
const envoy::config::endpoint::v3::Endpoint::HealthCheckConfig& health_check_config,
uint32_t weight = 1) {
return HostSharedPtr{new HostImpl(cluster, "", Network::Utility::resolveUrl(url), nullptr, weight,
return std::make_shared<HostImpl>(cluster, "", Network::Utility::resolveUrl(url), nullptr, weight,
envoy::config::core::v3::Locality(), health_check_config, 0,
envoy::config::core::v3::UNKNOWN)};
envoy::config::core::v3::UNKNOWN);
}

inline HostDescriptionConstSharedPtr makeTestHostDescription(ClusterInfoConstSharedPtr cluster,
const std::string& url) {
return HostDescriptionConstSharedPtr{new HostDescriptionImpl(
return std::make_shared<HostDescriptionImpl>(
cluster, "", Network::Utility::resolveUrl(url), nullptr,
envoy::config::core::v3::Locality().default_instance(),
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0)};
envoy::config::endpoint::v3::Endpoint::HealthCheckConfig::default_instance(), 0);
}

inline HostsPerLocalitySharedPtr makeHostsPerLocality(std::vector<HostVector>&& locality_hosts,
Expand Down