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: improving dynamic_forward_proxy coverage #14672

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,22 @@ Http::FilterHeadersStatus ProxyFilter::decodeHeaders(Http::RequestHeaderMap& hea
}

switch (result.status_) {
case LoadDnsCacheEntryStatus::InCache: {
case LoadDnsCacheEntryStatus::InCache:
Copy link
Member

Choose a reason for hiding this comment

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

As an aside, I'm guessing if this kind of change is enough to tip us over the line, that things will remain fragile, but fine to remove an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you look at pre-change coverage reports, literally the only lines which did not have coverage were the closing braces in the switch statements and the COVERAGE_EXCLUDE at the bottom. For some reason closing braces in switch statements are considered non-covered even when (as in this case) the switch code is tested. Removing the braces removes a coverage report error.

ASSERT(cache_load_handle_ == nullptr);
ENVOY_STREAM_LOG(debug, "DNS cache entry already loaded, continuing", *decoder_callbacks_);
return Http::FilterHeadersStatus::Continue;
}
case LoadDnsCacheEntryStatus::Loading: {
case LoadDnsCacheEntryStatus::Loading:
ASSERT(cache_load_handle_ != nullptr);
ENVOY_STREAM_LOG(debug, "waiting to load DNS cache entry", *decoder_callbacks_);
return Http::FilterHeadersStatus::StopAllIterationAndWatermark;
}
case LoadDnsCacheEntryStatus::Overflow: {
case LoadDnsCacheEntryStatus::Overflow:
ASSERT(cache_load_handle_ == nullptr);
ENVOY_STREAM_LOG(debug, "DNS cache overflow", *decoder_callbacks_);
decoder_callbacks_->sendLocalReply(Http::Code::ServiceUnavailable,
ResponseStrings::get().DnsCacheOverflow, nullptr,
absl::nullopt, ResponseStrings::get().DnsCacheOverflow);
return Http::FilterHeadersStatus::StopIteration;
}
}

NOT_REACHED_GCOVR_EXCL_LINE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ TEST_F(DnsCacheResourceManagerTest, CheckDnsResource) {
EXPECT_EQ(2, pending_requests.count());
EXPECT_TRUE(pending_requests.canCreate());

EXPECT_EQ(0, resource_manager_->stats().rq_pending_open_.value());
EXPECT_EQ(0, resource_manager_->stats().rq_pending_remaining_.value());

cleanup();
}
} // namespace
} // namespace DynamicForwardProxy
} // namespace Common
} // namespace Extensions
} // namespace Envoy
} // namespace Envoy
1 change: 0 additions & 1 deletion test/per_file_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ declare -a KNOWN_LOW_COVERAGE=(
"source/extensions/filters/common/rbac:87.5"
"source/extensions/filters/http/cache:92.4"
"source/extensions/filters/http/cache/simple_http_cache:95.2"
"source/extensions/filters/http/dynamic_forward_proxy:95.0"
"source/extensions/filters/http/grpc_json_transcoder:94.8"
"source/extensions/filters/http/ip_tagging:91.2"
"source/extensions/filters/http/kill_request:95.0" # Death tests don't report LCOV
Expand Down