[FEATURE] Promltest: support to test expectation annotations#15995
[FEATURE] Promltest: support to test expectation annotations#15995beorn7 merged 15 commits intoprometheus:mainfrom
Conversation
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
charleskorn
left a comment
There was a problem hiding this comment.
I think we can simplify this dramatically by dropping support for the old syntax and only supporting the new syntax: the number of consumers of this package are small, and converting from the old syntax to the new is straightforward to automate with something like sed.
What do you think @beorn7?
|
I would like to believe that the number of consumers is indeed small, but experience tells that these assumptions are usually wrong when it comes to Prometheus. If it's not an excessive amount of effort, I would like to have both ways in parallel for a while so that users can migrate gradually. Once the new way has proven itself, we can deprecate the old way and then drop the old way a minor release later or so (and then have the simplification we want after all). |
|
(Note: I still need to look at the code in detail, which might change my opinion above. ;) |
|
Sorry, this is still on my list. I'm just too busy with company-internal things at the moment. I hope I get to this before the week ends. |
beorn7
left a comment
There was a problem hiding this comment.
Thank you very much. Looks good so far, and I would say it seems manageable to support the "old way" for one or two more releases to allow a smooth migration.
One thing, though: I think we should (or need to) relax the requirement of "no annotations" for a simple eval command. That's a change of behavior, but it won't let any test fail that passes now (because it relaxes passing criteria). However, we clearly have to state that to keep the old strict behavior, you must add a expect no_warn and expect no_info now.
If we don't add this relaxation now, the no_info and no_warn expectations wouldn't do anything. But one of the requirements was to allow an eval that doesn't care about annotations (cf. #15713).
More general TODOs:
- Update documentation (in promql/promqltest/README.md) with the new stuff.
- Mark the old stuff as deprecated in the documentation.
- Ideally, provide conversion scripts (old → new) in the documentation (
sedline or something) or as a file (if it's an actual program of some kind in a language of choice – back in my days, I used Perl for that, but I guess that would look weird today… ;).
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
|
Thanks @beorn7 for the review.
Since this is requested, we can relax the "no annotations" for a simple eval cmd. So for this do we need to add both
Thanks. I will update the documentation for these TODOs. |
|
As discussed separately, we do not want to add |
beorn7
left a comment
There was a problem hiding this comment.
Just two small things left in the code. (But we also need documentation, see separate command.)
|
About the documentation update: What we need in this PR is an update of the documentation (in promql/promqltest/README.md) with the new stuff, and a deprecation note for the old stuff. Also, very important, the note that a simple We don't necessarily need the conversion scripts in this PR, but we should give written instructions how the old and the now way looks like. This could go along with the stuff above (like discussing when to add As discussed with @NeerajGartia21 separately, we'll have a separate PR to convert our own tests (those in the prometheus/prometheus repo). We can then also discuss where we want the explicit BTW, given that adding the |
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
|
@beorn7 I have added the suggestions and updated the ReadMe with the new stuffs. Please have another look. |
beorn7
left a comment
There was a problem hiding this comment.
Tiny documentation improvements, but otherwise looks good.
@charleskorn do you have any comments or concerns left?
Sorry, I've had a couple of other things on my plate, I'll try to review this today or early next week if not. |
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
I have updated the documentation based on your suggestions. |
|
Thank you. Let's wait a bit for @charleskorn . |
charleskorn
left a comment
There was a problem hiding this comment.
Thanks for working on this!
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
|
I've updated the PR. Please have a look, @charleskorn, @beorn7. |
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
|
@NeerajGartia21 thank you very much for following up. @charleskorn are all your concerns addressed? KubeCon week is starting, so I'll have limited availability during the coming week, but it would be great if we could wrap this up soon. |
|
In fact, if we get this merged before Wednesday, we could give the test conversions (including maybe a script) to attendees of the Prometheus contrib fest as one of the possible tasks. See https://kccnceu2025.sched.com/event/1tcx4/contribfest-contribution-guide-and-workshop-help-us-improve-the-prometheus-ecosystem |
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
charleskorn
left a comment
There was a problem hiding this comment.
Thanks for working on this @NeerajGartia21!
|
Thanks @charleskorn @beorn7 for the reviews! |
|
Great. I'll give this a final look and then merge. |
|
Created #16367 for the conversion. |
That's great! Meanwhile, I'll work on other issues. |
Follow up prometheus/prometheus#15995 Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Resolves #15794
This PR enhances the PromQL testing framework by allowing tests to check for expected annotations while keeping the existing syntax unchanged. Now, you can use
expectlines to verify expected annotations. For example:For more details see: #15794 (comment)
CC: @beorn7 @charleskorn