Skip to content

Commit 149870f

Browse files
authored
Fix fuzz failure counting (#561)
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
1 parent 6a06b22 commit 149870f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

engine/engine_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,15 @@ avg by (storage_info) (
22072207
http_requests_total{pod="nginx-1", series="1"} 1+2x40`,
22082208
query: `rate(http_requests_total[20s:10s] offset 20s)`,
22092209
},
2210+
{
2211+
name: "fuzz absent_over_time empty matcher",
2212+
load: `load 30s
2213+
http_requests_total{pod="nginx-1", route="/"} 41.00+0.20x40
2214+
http_requests_total{pod="nginx-2", route="/"} 1+2.41x40`,
2215+
query: `absent_over_time({__name__="http_requests_total",route=""}[4m])`,
2216+
start: time.UnixMilli(170000),
2217+
end: time.UnixMilli(170000),
2218+
},
22102219
}
22112220

22122221
disableOptimizerOpts := []bool{true, false}

engine/enginefuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func validateTestCases(t *testing.T, cases []*testCase) {
280280
logQuery(c)
281281

282282
t.Logf("case %d error mismatch.\nnew result: %s\nold result: %s\n", i, c.newRes.String(), c.oldRes.String())
283-
//failures++
283+
failures++
284284
continue
285285
}
286286
if !c.validateSamples || c.oldRes.Err != nil {

execution/function/absent.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (o *absentOperator) loadSeries() {
6363
o.once.Do(func() {
6464
o.pool.SetStepSize(1)
6565

66-
// https://github.com/prometheus/prometheus/blob/main/promql/functions.go#L1385
66+
// https://github.com/prometheus/prometheus/blob/df1b4da348a7c2f8c0b294ffa1f05db5f6641278/promql/functions.go#L1857
6767
var lm []*labels.Matcher
6868
switch n := o.funcExpr.Args[0].(type) {
6969
case *logicalplan.VectorSelector:
@@ -77,19 +77,19 @@ func (o *absentOperator) loadSeries() {
7777
}
7878

7979
has := make(map[string]bool)
80-
lmap := make(map[string]string)
80+
b := labels.NewBuilder(labels.EmptyLabels())
8181
for _, l := range lm {
8282
if l.Name == labels.MetricName {
8383
continue
8484
}
8585
if l.Type == labels.MatchEqual && !has[l.Name] {
86-
lmap[l.Name] = l.Value
86+
b.Set(l.Name, l.Value)
8787
has[l.Name] = true
8888
} else {
89-
delete(lmap, l.Name)
89+
b.Del(l.Name)
9090
}
9191
}
92-
o.series = []labels.Labels{labels.FromMap(lmap)}
92+
o.series = []labels.Labels{b.Labels()}
9393
})
9494
}
9595

0 commit comments

Comments
 (0)