-
Notifications
You must be signed in to change notification settings - Fork 533
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
MQE: Add support for histogram_quantile #9929
base: main
Are you sure you want to change the base?
Conversation
Also preps support for more classic histogram functions to come. (Will require some re-work, but the basics are there). Tidies up annotation tests and checks their results between engines. (Since sometimes we emit annotations with results, and sometimes the results are omitted when there is an annotation).
38d1a77
to
d293f3a
Compare
d89bbab
to
78fc811
Compare
78fc811
to
5abeee0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still working my way through the implementation and will keep going tomorrow - I have some suggestions for the tests in the meantime
@@ -295,7 +295,7 @@ func TestOurTestCases(t *testing.T) { | |||
prometheusEngine := promql.NewEngine(opts.CommonOpts) | |||
|
|||
testdataFS := os.DirFS("./testdata") | |||
testFiles, err := fs.Glob(testdataFS, "ours*/*.test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has the asterisk been removed? We want to run tests from both the ours
and ours-only
directories.
` | ||
// TODO add series with malformed le? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO still valid?
// Because we test a huge amount of combinations, if we get a failure, stop running the other tests. | ||
// This will reduce the output to make it easier to manage. | ||
shouldStop := false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality is built into go test
: use go test -failfast
.
} | ||
|
||
func getMixedMetricsForTests() ([]string, int, string) { | ||
func getMixedMetricsForTests(includeClassicHistograms bool) ([]string, int, string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like includeClassicHistograms
is always true
- is this needed?
results = append(results, res) | ||
|
||
_, infos := res.Warnings.AsStrings(testCase.expr, 0, 0) | ||
//require.ElementsMatch(t, testCase.expectedWarningAnnotations, warnings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be commented out?
"bad bucket label warning": { | ||
data: mixedClassicHistograms, | ||
expr: `histogram_quantile(0.5, series{host="c"})`, | ||
expectedWarningAnnotations: []string{"PromQL warning: bucket label \"le\" is missing or has a malformed value of \"abc\" for metric name \"series\" (1:25)"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Might be clearer to use raw strings here to avoid the need for all the escaping
@@ -1836,11 +1836,82 @@ func (t *timeoutTestingQueryTracker) Close() error { | |||
return nil | |||
} | |||
|
|||
func TestAnnotations(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you've split this test in half?
// If both results are available, compare them (sometimes we skip prometheus) | ||
if len(results) == 2 { | ||
// We do this extra comparison to ensure that we don't skip a series that may be outputted during a warning | ||
// or vice-versa where no result may be expected etc. | ||
testutils.RequireEqualResults(t, testCase.expr, results[0], results[1]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to compare the results when we're testing annotations? I'd expect the results to be exercised elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test for the case where the buckets for an output series change over time (eg. at T=1, buckets are 1, 2 and 5, but at T=2, buckets are 1, 3 and 7).
Also preps support for more classic histogram functions to come. (Will require some re-work, but the basics are there).
Tidies up annotation tests and checks their results between engines. (Since sometimes we emit annotations with results, and sometimes the results are omitted when there is an annotation).
What this PR does
Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.