Skip to content

Commit b9e65a3

Browse files
bborehamtomwilkie
authored andcommitted
Quantize expected samples the same as Prom query
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
1 parent 88fa8c6 commit b9e65a3

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

pkg/test/case.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ type Case interface {
1515

1616
Query(ctx context.Context, client v1.API, selectors string, start time.Time, duration time.Duration) ([]model.SamplePair, error)
1717
ExpectedValueAt(time.Time) float64
18+
Quantized(time.Duration) time.Duration
1819
}

pkg/test/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (r *Runner) runRandomTest() {
212212
}
213213
}
214214

215-
expectedNumSamples := int(duration / r.cfg.ScrapeInterval)
215+
expectedNumSamples := int(tc.Quantized(duration) / r.cfg.ScrapeInterval)
216216
if !epsilonCorrect(float64(len(pairs)), float64(expectedNumSamples), r.cfg.samplesEpsilon) {
217217
log.Errorf("Expected %d samples, got %d", expectedNumSamples, len(pairs))
218218
failures = true

pkg/test/simple.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ func (tc *simpleTestCase) Query(ctx context.Context, client v1.API, selectors st
7171
}
7272
return result, nil
7373
}
74+
75+
func (tc *simpleTestCase) Quantized(duration time.Duration) time.Duration {
76+
return duration.Truncate(time.Minute)
77+
}

0 commit comments

Comments
 (0)