-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(query-tee): improvements to skip samples outside comparison window #15794
Conversation
func TestCompareMatrix_SamplesOutsideComparableWindow(t *testing.T) { | ||
for _, tc := range []struct { | ||
name string | ||
expected json.RawMessage | ||
actual json.RawMessage | ||
skipSamplesBefore time.Time | ||
skipRecentSamples time.Duration | ||
evaluationTime time.Time | ||
err error | ||
}{ | ||
{ | ||
name: "skip samples before window", | ||
expected: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[0,"1"],[5,"2"],[15,"3"],[20,"4"]]} | ||
]`), | ||
actual: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[5,"1"],[15,"3"],[20,"4"]]} | ||
]`), | ||
skipSamplesBefore: time.Unix(10, 0), | ||
evaluationTime: time.Unix(100, 0), | ||
}, | ||
{ | ||
name: "skip recent samples", | ||
expected: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[5,"1"],[25,"2"],[80,"3"],[94,"4"],[96,"5"]]} | ||
]`), | ||
actual: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[5,"1"],[25,"2"],[80,"3"],[95, "4"]]} | ||
]`), | ||
skipRecentSamples: 10 * time.Second, | ||
evaluationTime: time.Unix(100, 0), | ||
}, | ||
{ | ||
name: "skip both recent and old samples", | ||
expected: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[5,"1"],[25,"2"],[80,"3"],[94,"4"],[96,"5"]]} | ||
]`), | ||
actual: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[5,"0"],[25,"2"],[80,"3"],[95, "4"]]} | ||
]`), | ||
skipSamplesBefore: time.Unix(10, 0), | ||
skipRecentSamples: 10 * time.Second, | ||
evaluationTime: time.Unix(100, 0), | ||
}, | ||
{ | ||
name: "skip entire series", | ||
expected: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[50,"1"],[75,"2"]]}, | ||
{"metric":{"foo":"buzz"},"values":[[5,"1"],[9,"4"],[96,"5"]]} | ||
]`), // skip comparing {"foo":"buzz"} | ||
actual: json.RawMessage(`[ | ||
{"metric":{"foo":"bar"},"values":[[50,"1"],[75,"2"],[95,"3"]]} | ||
]`), | ||
skipSamplesBefore: time.Unix(10, 0), | ||
skipRecentSamples: 10 * time.Second, | ||
evaluationTime: time.Unix(100, 0), | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
_, err := compareMatrix(tc.expected, tc.actual, tc.evaluationTime, SampleComparisonOptions{ | ||
SkipSamplesBefore: tc.skipSamplesBefore, | ||
SkipRecentSamples: tc.skipRecentSamples, | ||
}) | ||
|
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.
most places we tend to find mistakes/bugs etc are off by one errors and boundaries.
Could you add tests for the exact handoff time (skipSamplesBefore: time.Unix(10,0) and then have a sample at exactly 10 to make sure it does what you expect it to do, same with the skipRecentSamples.
4e5a2d2
to
efebcce
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.
LGTM
What this PR does / why we need it:
proxy.compare-skip-samples-before
cortex_querytee_responses_compared_total
now reportsskipped
count which was previously getting counted assuccess
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR