Skip to content

Commit

Permalink
Add grouping test cases to `TestCompareVariousMixedMetricsBinaryOpera…
Browse files Browse the repository at this point in the history
…tions`
  • Loading branch information
charleskorn committed Oct 15, 2024
1 parent 21a2726 commit bf3311c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/streamingpromql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,13 @@ func TestCompareVariousMixedMetricsBinaryOperations(t *testing.T) {
binaryExpr += fmt.Sprintf(` %s series{label="%s"}`, op, label)
}
expressions = append(expressions, binaryExpr)

// Same thing again, this time with grouping.
binaryExpr = fmt.Sprintf(`series{label="%s"}`, labels[0])
for _, label := range labels[1:] {
binaryExpr += fmt.Sprintf(` %s on (group) series{label="%s"}`, op, label)
}
expressions = append(expressions, binaryExpr)
}
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/streamingpromql/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ func requireInEpsilonIfNotZero(t testing.TB, expected, actual float64, msgAndArg
func requireFloatBucketsMatch(t testing.TB, b1, b2 []float64) {
require.Equal(t, len(b1), len(b2), "bucket lengths match")
for i, b := range b1 {
require.InEpsilon(t, b, b2[i], 1e-10, "bucket values match")
if b == 0 {
require.Equal(t, b, b2[i], "bucket values match")
} else {
require.InEpsilon(t, b, b2[i], 1e-10, "bucket values match")
}
}
}

Expand Down

0 comments on commit bf3311c

Please sign in to comment.