-
Notifications
You must be signed in to change notification settings - Fork 5.3k
tools: add coverage reporting & enforcement to router check #7727
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
Merged
mattklein123
merged 13 commits into
envoyproxy:master
from
dschaller:routercheckcoverage
Aug 1, 2019
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4191183
tools: add coverage reporting & enforcement to router check
dschaller 56beb7d
Merge branch 'master' into routercheckcoverage
dschaller ffe69d9
fix spelling in flag description
dschaller 1eb7337
update total route count variable name
dschaller b8fc746
constants
dschaller 8954c3c
fix bug in coverage percentage report
dschaller 2999c10
add percentage sign to output
dschaller 2a1bbac
remove http filters from build
dschaller 1094189
update based on feedback
dschaller 6f5e230
pass by reference
dschaller d5ff7af
add note about avoiding duplicate coverage
dschaller 129aef5
Merge branch 'master' into routercheckcoverage
dschaller 7c5c4a4
fix nit
dschaller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "test/tools/router_check/coverage.h" | ||
|
|
||
| #include <algorithm> | ||
|
|
||
| #include "envoy/api/v2/core/base.pb.h" | ||
|
|
||
| namespace Envoy { | ||
| void Coverage::markCovered(const Envoy::Router::RouteEntry& route) { | ||
| // n.b. If we reach the end of the seen routes without finding the specified | ||
| // route we add it as seen, otherwise it's a duplicate. | ||
| if (std::find(seen_routes_.begin(), seen_routes_.end(), &route) == seen_routes_.end()) { | ||
dschaller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| seen_routes_.push_back(&route); | ||
| } | ||
| } | ||
|
|
||
| double Coverage::report() { | ||
| uint64_t num_routes = 0; | ||
| for (const auto& host : route_config_.virtual_hosts()) { | ||
| num_routes += host.routes_size(); | ||
| } | ||
| return 100 * static_cast<double>(seen_routes_.size()) / num_routes; | ||
| } | ||
| } // namespace Envoy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/router/router.h" | ||
|
|
||
| #include "test/mocks/server/mocks.h" | ||
|
|
||
| namespace Envoy { | ||
| class Coverage : Logger::Loggable<Logger::Id::testing> { | ||
| public: | ||
| Coverage(envoy::api::v2::RouteConfiguration config) : route_config_(config){}; | ||
| void markCovered(const Envoy::Router::RouteEntry& route); | ||
| double report(); | ||
|
|
||
| private: | ||
| std::vector<const Envoy::Router::RouteEntry*> seen_routes_; | ||
| const envoy::api::v2::RouteConfiguration route_config_; | ||
| }; | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.