Skip to content
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 tests for case where range vector selectors and subqueries have 0 range #10586

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions pkg/streamingpromql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestRangeVectorSelectors(t *testing.T) {
expected *promql.Result
ts time.Time
}{
"matches series with points in range": {
"floats: matches series with points in range": {
expr: "some_metric[1m1s]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Expand All @@ -419,21 +419,21 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"matches no series": {
"floats: matches no series": {
expr: "some_nonexistent_metric[1m]",
ts: baseT,
expected: &promql.Result{
Value: promql.Matrix{},
},
},
"no samples in range": {
"floats: no samples in range": {
expr: "some_metric[1m]",
ts: baseT.Add(20 * time.Minute),
expected: &promql.Result{
Value: promql.Matrix{},
},
},
"does not return points outside range if last selected point does not align to end of range": {
"floats: does not return points outside range if last selected point does not align to end of range": {
expr: "some_metric_with_gaps[1m1s]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Expand All @@ -447,7 +447,7 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"metric with stale marker": {
"floats: metric with stale marker": {
expr: "some_metric_with_stale_marker[3m1s]",
ts: baseT.Add(3 * time.Minute),
expected: &promql.Result{
Expand All @@ -463,7 +463,14 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"histogram: matches series with points in range": {
"floats: 0 length range": {
expr: "some_metric[0]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Value: promql.Matrix{},
},
},
"histograms: matches series with points in range": {
expr: "incr_histogram[1m1s]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Expand Down Expand Up @@ -549,14 +556,14 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"histogram: no samples in range": {
"histograms: no samples in range": {
expr: "incr_histogram[1m]",
ts: baseT.Add(20 * time.Minute),
expected: &promql.Result{
Value: promql.Matrix{},
},
},
"histogram: does not return points outside range if last selected point does not align to end of range": {
"histograms: does not return points outside range if last selected point does not align to end of range": {
expr: "histogram_with_gaps[1m1s]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Expand Down Expand Up @@ -586,7 +593,7 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"histogram: metric with stale marker": {
"histograms: metric with stale marker": {
expr: "histogram_with_stale_marker[3m1s]",
ts: baseT.Add(3 * time.Minute),
expected: &promql.Result{
Expand Down Expand Up @@ -650,6 +657,13 @@ func TestRangeVectorSelectors(t *testing.T) {
},
},
},
"histograms: 0 length range": {
expr: "incr_histogram[0]",
ts: baseT.Add(2 * time.Minute),
expected: &promql.Result{
Value: promql.Matrix{},
},
},
"mixed series with histograms and floats": {
expr: "mixed_metric[4m]",
ts: baseT.Add(4 * time.Minute),
Expand Down Expand Up @@ -1086,6 +1100,13 @@ func TestSubqueries(t *testing.T) {
},
Start: time.Unix(35, 0),
},
{
Query: "metric[0:5s]",
Result: promql.Result{
Value: promql.Matrix{},
},
Start: time.Unix(10, 0),
},
{ // Normal selector.
Query: `http_requests{group=~"pro.*",instance="0"}[30s:10s]`,
Result: promql.Result{
Expand Down
Loading