mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Add more topk() / bottomk() tests.
Test what happens if k > number of input elements. Change-Id: Ie724b850939e297ebf085f0a5a3522e9cfcc6534
This commit is contained in:
parent
c582ae73c2
commit
3fdb74e571
|
@ -333,6 +333,15 @@ func TestExpressions(t *testing.T) {
|
|||
checkOrder: true,
|
||||
fullRanges: 0,
|
||||
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)`,
|
||||
output: []string{
|
||||
|
@ -343,6 +352,15 @@ func TestExpressions(t *testing.T) {
|
|||
checkOrder: true,
|
||||
fullRanges: 0,
|
||||
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.
|
||||
expr: `x{y="testvalue"}`,
|
||||
|
@ -409,11 +427,11 @@ func TestExpressions(t *testing.T) {
|
|||
fullRanges: 0,
|
||||
intervalRanges: 0,
|
||||
}, {
|
||||
// Empty expressions shouldn"t parse.
|
||||
// Empty expressions shouldn't parse.
|
||||
expr: ``,
|
||||
shouldFail: true,
|
||||
}, {
|
||||
// Interval durations can"t be in quotes.
|
||||
// Interval durations can't be in quotes.
|
||||
expr: `http_requests["1m"]`,
|
||||
shouldFail: true,
|
||||
}, {
|
||||
|
|
Loading…
Reference in a new issue