Add more topk() / bottomk() tests.
Test what happens if k > number of input elements. Change-Id: Ie724b850939e297ebf085f0a5a3522e9cfcc6534
This commit is contained in:
parent
200d02effe
commit
f7cd18abdf
|
@ -333,6 +333,15 @@ func TestExpressions(t *testing.T) {
|
||||||
checkOrder: true,
|
checkOrder: true,
|
||||||
fullRanges: 0,
|
fullRanges: 0,
|
||||||
intervalRanges: 8,
|
intervalRanges: 8,
|
||||||
|
}, {
|
||||||
|
expr: `topk(5, http_requests{group="canary",job="app-server"})`,
|
||||||
|
output: []string{
|
||||||
|
`http_requests{group="canary", instance="1", job="app-server"} => 800 @[%v]`,
|
||||||
|
`http_requests{group="canary", instance="0", job="app-server"} => 700 @[%v]`,
|
||||||
|
},
|
||||||
|
checkOrder: true,
|
||||||
|
fullRanges: 0,
|
||||||
|
intervalRanges: 2,
|
||||||
}, {
|
}, {
|
||||||
expr: `bottomk(3, http_requests)`,
|
expr: `bottomk(3, http_requests)`,
|
||||||
output: []string{
|
output: []string{
|
||||||
|
@ -343,6 +352,15 @@ func TestExpressions(t *testing.T) {
|
||||||
checkOrder: true,
|
checkOrder: true,
|
||||||
fullRanges: 0,
|
fullRanges: 0,
|
||||||
intervalRanges: 8,
|
intervalRanges: 8,
|
||||||
|
}, {
|
||||||
|
expr: `bottomk(5, http_requests{group="canary",job="app-server"})`,
|
||||||
|
output: []string{
|
||||||
|
`http_requests{group="canary", instance="0", job="app-server"} => 700 @[%v]`,
|
||||||
|
`http_requests{group="canary", instance="1", job="app-server"} => 800 @[%v]`,
|
||||||
|
},
|
||||||
|
checkOrder: true,
|
||||||
|
fullRanges: 0,
|
||||||
|
intervalRanges: 2,
|
||||||
}, {
|
}, {
|
||||||
// Single-letter label names and values.
|
// Single-letter label names and values.
|
||||||
expr: `x{y="testvalue"}`,
|
expr: `x{y="testvalue"}`,
|
||||||
|
@ -409,11 +427,11 @@ func TestExpressions(t *testing.T) {
|
||||||
fullRanges: 0,
|
fullRanges: 0,
|
||||||
intervalRanges: 0,
|
intervalRanges: 0,
|
||||||
}, {
|
}, {
|
||||||
// Empty expressions shouldn"t parse.
|
// Empty expressions shouldn't parse.
|
||||||
expr: ``,
|
expr: ``,
|
||||||
shouldFail: true,
|
shouldFail: true,
|
||||||
}, {
|
}, {
|
||||||
// Interval durations can"t be in quotes.
|
// Interval durations can't be in quotes.
|
||||||
expr: `http_requests["1m"]`,
|
expr: `http_requests["1m"]`,
|
||||||
shouldFail: true,
|
shouldFail: true,
|
||||||
}, {
|
}, {
|
||||||
|
|
Loading…
Reference in New Issue