Skip to content

Commit

Permalink
test: improving test coverage by removing unused functions (envoyprox…
Browse files Browse the repository at this point in the history
…y#11086)

Risk Level: Low (may be used downstream)
Testing: tests pass
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk authored May 7, 2020
1 parent b4873a3 commit 10e7c9d
Show file tree
Hide file tree
Showing 37 changed files with 27 additions and 186 deletions.
6 changes: 3 additions & 3 deletions source/common/common/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ uint64_t MurmurHash::murmurHash2_64(absl::string_view key, uint64_t seed) {
const char* const end = buf + len_aligned;
uint64_t hash = seed ^ (len * mul);
for (const char* p = buf; p != end; p += 8) {
const uint64_t data = shift_mix(unaligned_load(p) * mul) * mul;
const uint64_t data = shiftMix(unaligned_load(p) * mul) * mul;
hash ^= data;
hash *= mul;
}
Expand All @@ -29,8 +29,8 @@ uint64_t MurmurHash::murmurHash2_64(absl::string_view key, uint64_t seed) {
hash ^= data;
hash *= mul;
}
hash = shift_mix(hash) * mul;
hash = shift_mix(hash);
hash = shiftMix(hash) * mul;
hash = shiftMix(hash);
return hash;
}

Expand Down
16 changes: 1 addition & 15 deletions source/common/common/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,9 @@ class MurmurHash {
return result;
}

static inline uint64_t shift_mix(uint64_t v) { return v ^ (v >> 47); }
static inline uint64_t shiftMix(uint64_t v) { return v ^ (v >> 47); }
};

struct ConstCharStarHash {
size_t operator()(const char* a) const { return HashUtil::xxHash64(a); }
};

struct ConstCharStarEqual {
size_t operator()(const char* a, const char* b) const { return strcmp(a, b) == 0; }
};

template <class Value>
using ConstCharStarHashMap =
absl::flat_hash_map<const char*, Value, ConstCharStarHash, ConstCharStarEqual>;
using ConstCharStarHashSet =
absl::flat_hash_set<const char*, ConstCharStarHash, ConstCharStarEqual>;

using SharedString = std::shared_ptr<std::string>;

struct HeterogeneousStringHash {
Expand Down
1 change: 0 additions & 1 deletion source/common/common/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class StderrSinkDelegate : public SinkDelegate {
bool hasLock() const { return lock_ != nullptr; }
void setLock(Thread::BasicLockable& lock) { lock_ = &lock; }
void clearLock() { lock_ = nullptr; }
Thread::BasicLockable* lock() { return lock_; }

private:
Thread::BasicLockable* lock_{};
Expand Down
10 changes: 0 additions & 10 deletions source/common/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,6 @@ class InlineString : public InlineStorage {
*/
absl::string_view toStringView() const { return {data_, size_}; }

/**
* @return the number of bytes in the string
*/
size_t size() const { return size_; }

/**
* @return a pointer to the first byte of the string.
*/
const char* data() const { return data_; }

private:
// Constructor is declared private so that no one constructs one without the
// proper size allocation. to accommodate the variable-size buffer.
Expand Down
7 changes: 1 addition & 6 deletions source/common/config/grpc_mux_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ void GrpcMuxImpl::queueDiscoveryRequest(const std::string& queue_item) {
drainRequests();
}

void GrpcMuxImpl::clearRequestQueue() {
grpc_stream_.maybeUpdateQueueSizeStat(0);
request_queue_ = {};
}

void GrpcMuxImpl::drainRequests() {
while (!request_queue_.empty() && grpc_stream_.checkRateLimitAllowsDrain()) {
// Process the request, if rate limiting is not enabled at all or if it is under rate limit.
Expand All @@ -244,4 +239,4 @@ void GrpcMuxImpl::drainRequests() {
}

} // namespace Config
} // namespace Envoy
} // namespace Envoy
1 change: 0 additions & 1 deletion source/common/config/grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class GrpcMuxImpl : public GrpcMux,

// Request queue management logic.
void queueDiscoveryRequest(const std::string& queue_item);
void clearRequestQueue();

GrpcStream<envoy::service::discovery::v3::DiscoveryRequest,
envoy::service::discovery::v3::DiscoveryResponse>
Expand Down
7 changes: 0 additions & 7 deletions source/common/grpc/google_async_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ struct GoogleAsyncTag {

GoogleAsyncStreamImpl& stream_;
const Operation op_;

// Generate a void* tag for a given Operation.
static void* tag(Operation op) { return reinterpret_cast<void*>(op); }
// Extract Operation from void* tag.
static Operation operation(void* tag) {
return static_cast<Operation>(reinterpret_cast<intptr_t>(tag));
}
};

class GoogleAsyncClientThreadLocal : public ThreadLocal::ThreadLocalObject,
Expand Down
2 changes: 0 additions & 2 deletions source/common/http/http1/conn_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class ConnPoolImpl : public ConnPoolImplBase {

void onDownstreamReset(ActiveClient& client);
void onResponseComplete(ActiveClient& client);
ActiveClient& firstReady() const { return static_cast<ActiveClient&>(*ready_clients_.front()); }
ActiveClient& firstBusy() const { return static_cast<ActiveClient&>(*busy_clients_.front()); }

Event::TimerPtr upstream_ready_timer_;
bool upstream_ready_enabled_{false};
Expand Down
17 changes: 0 additions & 17 deletions source/common/stats/symbol_table_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ class SymbolTableImpl : public SymbolTable {
return data_bytes_required_ + encodingSizeBytes(data_bytes_required_);
}

/**
* @return the number of uint8_t entries we collected while adding symbols.
*/
uint64_t dataBytesRequired() const { return data_bytes_required_; }

/**
* Moves the contents of the vector into an allocated array. The array
* must have been allocated with bytesRequired() bytes.
Expand Down Expand Up @@ -174,8 +169,6 @@ class SymbolTableImpl : public SymbolTable {
*/
static std::pair<uint64_t, uint64_t> decodeNumber(const uint8_t* encoding);

StoragePtr release() { return mem_block_.release(); }

private:
uint64_t data_bytes_required_{0};
MemBlockBuilder<uint8_t> mem_block_;
Expand Down Expand Up @@ -464,11 +457,6 @@ class StatName {

const uint8_t* dataIncludingSize() const { return size_and_data_; }

/**
* @return A pointer to the buffer, including the size bytes.
*/
const uint8_t* sizeAndData() const { return size_and_data_; }

/**
* @return whether this is empty.
*/
Expand Down Expand Up @@ -607,11 +595,6 @@ class StatNameDynamicPool {
public:
explicit StatNameDynamicPool(SymbolTable& symbol_table) : symbol_table_(symbol_table) {}

/**
* Removes all StatNames from the pool.
*/
void clear() { storage_vector_.clear(); }

/**
* @param name the name to add the container.
* @return the StatName held in the container for this name.
Expand Down
7 changes: 0 additions & 7 deletions source/common/upstream/subset_lb.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class SubsetLoadBalancer : public LoadBalancer, Logger::Loggable<Logger::Id::ups
LocalityWeightsConstSharedPtr
determineLocalityWeights(const HostsPerLocality& hosts_per_locality) const;

void triggerCallbacks() { HostSetImpl::runUpdateCallbacks({}, {}); }
bool empty() { return hosts().empty(); }

private:
const HostSet& original_host_set_;
const bool locality_weight_aware_;
Expand All @@ -82,10 +79,6 @@ class SubsetLoadBalancer : public LoadBalancer, Logger::Loggable<Logger::Id::ups

bool empty() { return empty_; }

const HostSubsetImpl* getOrCreateHostSubset(uint32_t priority) {
return reinterpret_cast<const HostSubsetImpl*>(&getOrCreateHostSet(priority));
}

void triggerCallbacks() {
for (size_t i = 0; i < hostSetsPerPriority().size(); ++i) {
runReferenceUpdateCallbacks(i, {}, {});
Expand Down
4 changes: 0 additions & 4 deletions source/common/upstream/upstream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ class ClusterImplBase : public Cluster, protected Logger::Loggable<Logger::Id::u
static std::tuple<HostsPerLocalityConstSharedPtr, HostsPerLocalityConstSharedPtr,
HostsPerLocalityConstSharedPtr>
partitionHostsPerLocality(const HostsPerLocality& hosts);
Stats::SymbolTable& symbolTable() { return symbol_table_; }
Config::ConstMetadataSharedPoolSharedPtr constMetadataSharedPool() {
return const_metadata_shared_pool_;
}
Expand Down Expand Up @@ -816,9 +815,6 @@ class PriorityStateManager : protected Logger::Loggable<Logger::Id::upstream> {
const absl::optional<Upstream::Host::HealthFlag> health_checker_flag,
absl::optional<uint32_t> overprovisioning_factor = absl::nullopt);

// Returns the size of the current cluster priority state.
size_t size() const { return priority_state_.size(); }

// Returns the saved priority state.
PriorityState& priorityState() { return priority_state_; }

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/clusters/redis/redis_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RedisCluster::RedisCluster(
local_info_(factory_context.localInfo()), random_(factory_context.random()),
redis_discovery_session_(*this, redis_client_factory), lb_factory_(std::move(lb_factory)),
auth_password_(
NetworkFilters::RedisProxy::ProtocolOptionsConfigImpl::auth_password(info(), api)),
NetworkFilters::RedisProxy::ProtocolOptionsConfigImpl::authPassword(info(), api)),
cluster_name_(cluster.name()),
refresh_manager_(Common::Redis::getClusterRefreshManager(
factory_context.singletonManager(), factory_context.dispatcher(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ class ClientConfig {
*/
const MatcherSharedPtr& upstreamHeaderMatchers() const { return upstream_header_matchers_; }

/**
* Returns a list of headers that will be add to the authorization request.
*/
const Http::LowerCaseStrPairVector& headersToAdd() const { return authorization_headers_to_add_; }

/**
* Returns the name used for tracing.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class FilterSettings : public Router::RouteSpecificFilterConfig {
: arn_(arn), invocation_mode_(mode), payload_passthrough_(payload_passthrough) {}

const Arn& arn() const& { return arn_; }
Arn&& arn() && { return std::move(arn_); }
bool payloadPassthrough() const { return payload_passthrough_; }
InvocationMode invocationMode() const { return invocation_mode_; }

Expand Down
18 changes: 6 additions & 12 deletions source/extensions/filters/http/cache/http_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,6 @@ class LookupRequest {
// Caches may modify the key according to local needs, though care must be
// taken to ensure that meaningfully distinct responses have distinct keys.
const Key& key() const { return key_; }
Key& key() { return key_; }

// Returns the subset of this request's headers that are listed in
// envoy::extensions::filters::http::cache::v3alpha::CacheConfig::allowed_vary_headers. If a cache
// storage implementation forwards lookup requests to a remote cache server that supports *vary*
// headers, that server may need to see these headers. For local implementations, it may be
// simpler to instead call makeLookupResult with each potential response.
HeaderVector& vary_headers() { return vary_headers_; }
const HeaderVector& vary_headers() const { return vary_headers_; }

// Time when this LookupRequest was created (in response to an HTTP request).
SystemTime timestamp() const { return timestamp_; }

// WARNING: Incomplete--do not use in production (yet).
// Returns a LookupResult suitable for sending to the cache filter's
Expand All @@ -195,7 +183,13 @@ class LookupRequest {

Key key_;
std::vector<RawByteRange> request_range_spec_;
// Time when this LookupRequest was created (in response to an HTTP request).
SystemTime timestamp_;
// The subset of this request's headers that are listed in
// envoy::extensions::filters::http::cache::v3alpha::CacheConfig::allowed_vary_headers. If a cache
// storage implementation forwards lookup requests to a remote cache server that supports *vary*
// headers, that server may need to see these headers. For local implementations, it may be
// simpler to instead call makeLookupResult with each potential response.
HeaderVector vary_headers_;
const std::string request_cache_control_;
};
Expand Down
14 changes: 4 additions & 10 deletions source/extensions/filters/http/ext_authz/ext_authz.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ struct ExtAuthzFilterStats {
class FilterConfig {
public:
FilterConfig(const envoy::extensions::filters::http::ext_authz::v3::ExtAuthz& config,
const LocalInfo::LocalInfo& local_info, Stats::Scope& scope,
Runtime::Loader& runtime, Http::Context& http_context,
const std::string& stats_prefix)
const LocalInfo::LocalInfo&, Stats::Scope& scope, Runtime::Loader& runtime,
Http::Context& http_context, const std::string& stats_prefix)
: allow_partial_message_(config.with_request_body().allow_partial_message()),
failure_mode_allow_(config.failure_mode_allow()),
clear_route_cache_(config.clear_route_cache()),
max_request_bytes_(config.with_request_body().max_request_bytes()),
status_on_error_(toErrorCode(config.status_on_error().code())), local_info_(local_info),
scope_(scope), runtime_(runtime), http_context_(http_context),
status_on_error_(toErrorCode(config.status_on_error().code())), scope_(scope),
runtime_(runtime), http_context_(http_context),
filter_enabled_(config.has_filter_enabled()
? absl::optional<Runtime::FractionalPercent>(
Runtime::FractionalPercent(config.filter_enabled(), runtime_))
Expand All @@ -90,14 +89,10 @@ class FilterConfig {

uint32_t maxRequestBytes() const { return max_request_bytes_; }

const LocalInfo::LocalInfo& localInfo() const { return local_info_; }

Http::Code statusOnError() const { return status_on_error_; }

bool filterEnabled() { return filter_enabled_.has_value() ? filter_enabled_->enabled() : true; }

Runtime::Loader& runtime() { return runtime_; }

Stats::Scope& scope() { return scope_; }

Http::Context& httpContext() { return http_context_; }
Expand Down Expand Up @@ -133,7 +128,6 @@ class FilterConfig {
const bool clear_route_cache_;
const uint32_t max_request_bytes_;
const Http::Code status_on_error_;
const LocalInfo::LocalInfo& local_info_;
Stats::Scope& scope_;
Runtime::Loader& runtime_;
Http::Context& http_context_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class IpTaggingFilterConfig {
Runtime::Loader& runtime);

Runtime::Loader& runtime() { return runtime_; }
Stats::Scope& scope() { return scope_; }
FilterRequestType requestType() const { return request_type_; }
const Network::LcTrie::LcTrie<std::string>& trie() const { return *trie_; }

Expand Down
5 changes: 0 additions & 5 deletions source/extensions/filters/network/dubbo_proxy/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ class DecoderStateMachine : public Logger::Loggable<Logger::Id::dubbo> {
*/
ProtocolState currentState() const { return state_; }

/**
* Set the current state. Used for testing only.
*/
void setCurrentState(ProtocolState state) { state_ = state; }

private:
struct DecoderStatus {
DecoderStatus() = default;
Expand Down
2 changes: 0 additions & 2 deletions source/extensions/filters/network/mongo_proxy/mongo_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class MongoStats {
return stat_name_set_->getBuiltin(str, fallback);
}

Stats::SymbolTable& symbolTable() { return scope_.symbolTable(); }

private:
Stats::ElementVec addPrefix(const Stats::ElementVec& names);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class CommandResponse : public MySQLCodec {
int parseMessage(Buffer::Instance&, uint32_t) override { return MYSQL_SUCCESS; }
std::string encode() override { return ""; }

uint16_t getServerStatus() const { return server_status_; }
uint16_t getWarnings() const { return warnings_; }
void setServerStatus(uint16_t status);
void setWarnings(uint16_t warnings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ClientSwitchResponse : public MySQLCodec {
int parseMessage(Buffer::Instance& buffer, uint32_t len) override;
std::string encode() override;

const std::string& getAuthPluginResp() const { return auth_plugin_resp_; }
void setAuthPluginResp(std::string& auth_swith_resp);

private:
Expand Down
12 changes: 4 additions & 8 deletions source/extensions/filters/network/redis_proxy/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@ class ProtocolOptionsConfigImpl : public Upstream::ProtocolOptionsConfig {
proto_config)
: auth_password_(proto_config.auth_password()) {}

std::string auth_password(Api::Api& api) const {
std::string authPassword(Api::Api& api) const {
return Config::DataSource::read(auth_password_, true, api);
}

const envoy::config::core::v3::DataSource& auth_password_datasource() const {
return auth_password_;
}

static const std::string auth_password(const Upstream::ClusterInfoConstSharedPtr info,
Api::Api& api) {
static const std::string authPassword(const Upstream::ClusterInfoConstSharedPtr info,
Api::Api& api) {
auto options = info->extensionProtocolOptionsTyped<ProtocolOptionsConfigImpl>(
NetworkFilterNames::get().RedisProxy);
if (options) {
return options->auth_password(api);
return options->authPassword(api);
}
return EMPTY_STRING;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ InstanceImpl::ThreadLocalPool::ThreadLocalPool(InstanceImpl& parent, Event::Disp
cluster_update_handle_ = parent_.cm_.addThreadLocalClusterUpdateCallbacks(*this);
Upstream::ThreadLocalCluster* cluster = parent_.cm_.get(cluster_name_);
if (cluster != nullptr) {
auth_password_ = ProtocolOptionsConfigImpl::auth_password(cluster->info(), parent_.api_);
auth_password_ = ProtocolOptionsConfigImpl::authPassword(cluster->info(), parent_.api_);
onClusterAddOrUpdateNonVirtual(*cluster);
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ void InstanceImpl::ThreadLocalPool::onClusterAddOrUpdateNonVirtual(

if (cluster_ != nullptr) {
// Treat an update as a removal followed by an add.
onClusterRemoval(cluster_name_);
ThreadLocalPool::onClusterRemoval(cluster_name_);
}

ASSERT(cluster_ == nullptr);
Expand Down
Loading

0 comments on commit 10e7c9d

Please sign in to comment.