Impove promtool test rules output diff on test failure#7549
Closed
topliceanu wants to merge 3 commits intoprometheus:masterfrom
Closed
Impove promtool test rules output diff on test failure#7549topliceanu wants to merge 3 commits intoprometheus:masterfrom
promtool test rules output diff on test failure#7549topliceanu wants to merge 3 commits intoprometheus:masterfrom
Conversation
Signed-off-by: alexandru topliceanu <alexandru.topliceanu@gmail.com>
Signed-off-by: alexandru topliceanu <alexandru.topliceanu@gmail.com>
68f17de to
40ba0f3
Compare
Signed-off-by: alexandru topliceanu <alexandru.topliceanu@gmail.com>
75f0194 to
9838b32
Compare
Author
|
+1. Could we also get rid of the |
Member
|
Hello @simonpasquier, can you have a look at this? Thanks! Also, it appears that it is not our usual way to compare structs. |
Member
|
I looked at this a bit and one issue is using go-cmp prints out internal implementation details as it's really designed for unit tests, e.g.: It's a bit confusing for the user to see the diff in the form of the internal structures that promtool uses, rather than PromQL syntax. I'm working on an alternative, first removing the use of |
Member
|
Closing in favor of #8064, thanks for the PR @topliceanu! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
The
promtool test rulesutility produces error outputs that are sometimes hard to parse. This is because the expected and actual data structures being compared are printed using a%#vdump. It is hard to read the difference between the two structures when they are large - eg. a lot of labels and/or a lot of annotations.How?
I have imported
github.com/google/go-cmp@v0.5.0/cmpand I'm using it to calculate and pretty-print a diff between the two structures under test on failure.I don't feel strongly about using this library. Consider this as more of a PoC, I'm happy to proceed with this however the community feels its best: using a different library, adding a diff implementation to the source, etc.
An alternative is to defer the presentation to other tools by returning some kind of standardized output.
Thanks for your feedback!