mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Make benchmark tests pass
A new query object is needed for each evaulation, as the iterators would otherwise be shared across evaluations.
This commit is contained in:
parent
998dfcbac6
commit
e6ea146c81
|
@ -141,15 +141,15 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) {
|
||||||
}
|
}
|
||||||
parts := patEvalInstant.FindStringSubmatch(lines[i])
|
parts := patEvalInstant.FindStringSubmatch(lines[i])
|
||||||
var (
|
var (
|
||||||
mod = parts[1]
|
mod = parts[1]
|
||||||
at = parts[2]
|
at = parts[2]
|
||||||
qry = parts[3]
|
expr = parts[3]
|
||||||
)
|
)
|
||||||
expr, err := ParseExpr(qry)
|
_, err := ParseExpr(expr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if perr, ok := err.(*ParseErr); ok {
|
if perr, ok := err.(*ParseErr); ok {
|
||||||
perr.Line = i + 1
|
perr.Line = i + 1
|
||||||
perr.Pos += strings.Index(lines[i], qry)
|
perr.Pos += strings.Index(lines[i], expr)
|
||||||
}
|
}
|
||||||
return i, nil, err
|
return i, nil, err
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ func (cmd *loadCmd) append(a storage.Appender) error {
|
||||||
// evalCmd is a command that evaluates an expression for the given time (range)
|
// evalCmd is a command that evaluates an expression for the given time (range)
|
||||||
// and expects a specific result.
|
// and expects a specific result.
|
||||||
type evalCmd struct {
|
type evalCmd struct {
|
||||||
expr Expr
|
expr string
|
||||||
start, end time.Time
|
start, end time.Time
|
||||||
interval time.Duration
|
interval time.Duration
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ func (e entry) String() string {
|
||||||
return fmt.Sprintf("%d: %s", e.pos, e.vals)
|
return fmt.Sprintf("%d: %s", e.pos, e.vals)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEvalCmd(expr Expr, start, end time.Time, interval time.Duration) *evalCmd {
|
func newEvalCmd(expr string, start, end time.Time, interval time.Duration) *evalCmd {
|
||||||
return &evalCmd{
|
return &evalCmd{
|
||||||
expr: expr,
|
expr: expr,
|
||||||
start: start,
|
start: start,
|
||||||
|
@ -465,7 +465,8 @@ func (t *Test) exec(tc testCommand) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
case *evalCmd:
|
case *evalCmd:
|
||||||
q := t.queryEngine.newQuery(t.storage, cmd.expr, cmd.start, cmd.end, cmd.interval)
|
qry, _ := ParseExpr(cmd.expr)
|
||||||
|
q := t.queryEngine.newQuery(t.storage, qry, cmd.start, cmd.end, cmd.interval)
|
||||||
res := q.Exec(t.context)
|
res := q.Exec(t.context)
|
||||||
if res.Err != nil {
|
if res.Err != nil {
|
||||||
if cmd.fail {
|
if cmd.fail {
|
||||||
|
|
Loading…
Reference in a new issue