forked from prometheus/client_golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testutil compareMetricFamilies: make less error-prone (prometheus#1424)
* testutil compareMetricFamilies: make less error-prone The functions `GatherAndCompare`, `ScrapeAndCompare` and others that use `compareMetricFamilies` under the hood can return no error if `metricNames` includes none of the names found in the scraped/gathered results. To avoid false Positves (an error being the negative case), we can return an error if there is is at least one name in `metricNames` that is not in the filtered results. Fixes: prometheus#1351 Signed-off-by: leonnicolas <[email protected]> * Add missing metricNames to error In to see which metric names are missing, we can add them to the error message. Signed-off-by: leonnicolas <[email protected]> * Apply suggestions from code review - remove if nil check - use two nested loops instead of map - use new function `hasMetricByName` for readability Co-authored-by: Bartlomiej Plotka <[email protected]> Signed-off-by: leonnicolas <[email protected]> * prometheus/testutil/testutil_test.go: compare complete error Before we would only compare the error prefix in `TestScrapeAndCompare`. Signed-off-by: leonnicolas <[email protected]> --------- Signed-off-by: leonnicolas <[email protected]> Signed-off-by: leonnicolas <[email protected]> Co-authored-by: Bartlomiej Plotka <[email protected]> Signed-off-by: Steven Swartz <[email protected]>
- Loading branch information
1 parent
d6b4379
commit b25bd9c
Showing
2 changed files
with
108 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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 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