mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
Update package promql tests for new labels.Labels type
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
56fefcd812
commit
aa634e0b7e
|
@ -684,6 +684,7 @@ load 10s
|
||||||
Result: Matrix{
|
Result: Matrix{
|
||||||
Series{
|
Series{
|
||||||
Points: []Point{{V: 1, T: 0}, {V: 1, T: 1000}, {V: 1, T: 2000}},
|
Points: []Point{{V: 1, T: 0}, {V: 1, T: 1000}, {V: 1, T: 2000}},
|
||||||
|
Metric: labels.EmptyLabels(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Start: time.Unix(0, 0),
|
Start: time.Unix(0, 0),
|
||||||
|
@ -4008,7 +4009,7 @@ func TestSparseHistogram_Sum_Count_AddOperator(t *testing.T) {
|
||||||
// sum().
|
// sum().
|
||||||
queryString := fmt.Sprintf("sum(%s)", seriesName)
|
queryString := fmt.Sprintf("sum(%s)", seriesName)
|
||||||
queryAndCheck(queryString, []Sample{
|
queryAndCheck(queryString, []Sample{
|
||||||
{Point{T: ts, H: &c.expected}, labels.Labels{}},
|
{Point{T: ts, H: &c.expected}, labels.EmptyLabels()},
|
||||||
})
|
})
|
||||||
|
|
||||||
// + operator.
|
// + operator.
|
||||||
|
@ -4017,13 +4018,13 @@ func TestSparseHistogram_Sum_Count_AddOperator(t *testing.T) {
|
||||||
queryString += fmt.Sprintf(` + ignoring(idx) %s{idx="%d"}`, seriesName, idx)
|
queryString += fmt.Sprintf(` + ignoring(idx) %s{idx="%d"}`, seriesName, idx)
|
||||||
}
|
}
|
||||||
queryAndCheck(queryString, []Sample{
|
queryAndCheck(queryString, []Sample{
|
||||||
{Point{T: ts, H: &c.expected}, labels.Labels{}},
|
{Point{T: ts, H: &c.expected}, labels.EmptyLabels()},
|
||||||
})
|
})
|
||||||
|
|
||||||
// count().
|
// count().
|
||||||
queryString = fmt.Sprintf("count(%s)", seriesName)
|
queryString = fmt.Sprintf("count(%s)", seriesName)
|
||||||
queryAndCheck(queryString, []Sample{
|
queryAndCheck(queryString, []Sample{
|
||||||
{Point{T: ts, V: 3}, labels.Labels{}},
|
{Point{T: ts, V: 3}, labels.EmptyLabels()},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if f, err := parseNumber(defLine); err == nil {
|
if f, err := parseNumber(defLine); err == nil {
|
||||||
cmd.expect(0, labels.EmptyLabels(), parser.SequenceValue{Value: f})
|
cmd.expect(0, parser.SequenceValue{Value: f})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
metric, vals, err := parser.ParseSeriesDesc(defLine)
|
metric, vals, err := parser.ParseSeriesDesc(defLine)
|
||||||
|
@ -218,7 +218,7 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) {
|
||||||
if len(vals) > 1 {
|
if len(vals) > 1 {
|
||||||
return i, nil, raise(i, "expecting multiple values in instant evaluation not allowed")
|
return i, nil, raise(i, "expecting multiple values in instant evaluation not allowed")
|
||||||
}
|
}
|
||||||
cmd.expect(j, metric, vals...)
|
cmd.expectMetric(j, metric, vals...)
|
||||||
}
|
}
|
||||||
return i, cmd, nil
|
return i, cmd, nil
|
||||||
}
|
}
|
||||||
|
@ -368,13 +368,15 @@ func (ev *evalCmd) String() string {
|
||||||
return "eval"
|
return "eval"
|
||||||
}
|
}
|
||||||
|
|
||||||
// expect adds a new metric with a sequence of values to the set of expected
|
// expect adds a sequence of values to the set of expected
|
||||||
// results for the query.
|
// results for the query.
|
||||||
func (ev *evalCmd) expect(pos int, m labels.Labels, vals ...parser.SequenceValue) {
|
func (ev *evalCmd) expect(pos int, vals ...parser.SequenceValue) {
|
||||||
if m.IsEmpty() {
|
|
||||||
ev.expected[0] = entry{pos: pos, vals: vals}
|
ev.expected[0] = entry{pos: pos, vals: vals}
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
// expectMetric adds a new metric with a sequence of values to the set of expected
|
||||||
|
// results for the query.
|
||||||
|
func (ev *evalCmd) expectMetric(pos int, m labels.Labels, vals ...parser.SequenceValue) {
|
||||||
h := m.Hash()
|
h := m.Hash()
|
||||||
ev.metrics[h] = m
|
ev.metrics[h] = m
|
||||||
ev.expected[h] = entry{pos: pos, vals: vals}
|
ev.expected[h] = entry{pos: pos, vals: vals}
|
||||||
|
|
|
@ -127,11 +127,11 @@ func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
for _, s := range tc.series {
|
for _, s := range tc.series {
|
||||||
var matchers []*labels.Matcher
|
var matchers []*labels.Matcher
|
||||||
for _, label := range s.Metric {
|
s.Metric.Range(func(label labels.Label) {
|
||||||
m, err := labels.NewMatcher(labels.MatchEqual, label.Name, label.Value)
|
m, err := labels.NewMatcher(labels.MatchEqual, label.Name, label.Value)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
matchers = append(matchers, m)
|
matchers = append(matchers, m)
|
||||||
}
|
})
|
||||||
|
|
||||||
// Get the series for the matcher.
|
// Get the series for the matcher.
|
||||||
ss := querier.Select(false, nil, matchers...)
|
ss := querier.Select(false, nil, matchers...)
|
||||||
|
|
Loading…
Reference in a new issue