Skip to content

Commit d64a96d

Browse files
MikeSpreitzerk8s-publishing-bot
authored andcommitted
Relax noise margin in TestOneWeightedHistogram
Signed-off-by: Mike Spreitzer <[email protected]> Kubernetes-commit: 77541c1e35e10d16787fe5951e5014195bfbf09f
1 parent 95f30f1 commit d64a96d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

metrics/prometheusextension/weighted_histogram_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func exerciseWeightedHistograms(t *testing.T, whSpecs ...weightedHistogramSpecFu
9999
for _, term := range terms {
100100
ee.sum += term
101101
}
102-
t.Logf("Adding expectation %#+v", ee)
102+
t.Logf("At idx=%v, adding expectation of buckets=%#+v, upperBounds=%#+v, sum=%v, count=%v", whIdx, ee.buckets, ee.upperBounds, ee.sum, ee.count)
103103
expectations = append(expectations, ee)
104104
}
105105
// Do the planned calls on ObserveWithWeight, in randomized order
@@ -142,8 +142,10 @@ func exerciseWeightedHistograms(t *testing.T, whSpecs ...weightedHistogramSpecFu
142142
actualSum := actualHist.GetSampleSum()
143143
num := math.Abs(actualSum - ee.sum)
144144
den := math.Max(math.Abs(actualSum), math.Abs(ee.sum))
145-
if num > den/1e14 {
146-
t.Errorf("At idx=%d, expected sum %v but got %v, err=%v", idx, ee.sum, actualSum, actualSum-ee.sum)
145+
relErr := num / den
146+
// Issue 120112 reports relative errors as high as 9.55994394104272e-14
147+
if relErr > 1e-13 {
148+
t.Errorf("At idx=%d, expected sum %v but got %v, err=%v, relativeErr=%v", idx, ee.sum, actualSum, actualSum-ee.sum, relErr)
147149
}
148150
}
149151
}

0 commit comments

Comments
 (0)