You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
0 commit comments