From 5a50a513c4ff867a4914fcd1a15e35db865e4c14 Mon Sep 17 00:00:00 2001 From: Vishal Raj Date: Mon, 6 Oct 2025 15:41:16 +0100 Subject: [PATCH] [chore]Fix time skew in TestLRUSetLifeTime using epsilon assertion --- exporter/elasticsearchexporter/internal/lru/lruset_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exporter/elasticsearchexporter/internal/lru/lruset_test.go b/exporter/elasticsearchexporter/internal/lru/lruset_test.go index 33c9523ccba8a..b378e0da3e505 100644 --- a/exporter/elasticsearchexporter/internal/lru/lruset_test.go +++ b/exporter/elasticsearchexporter/internal/lru/lruset_test.go @@ -63,8 +63,10 @@ func TestLRUSetLifeTime(t *testing.T) { }) require.NoError(tt, err) assert.False(tt, val) - }, lifetime*2, lifetime/10) - assert.GreaterOrEqual(t, time.Since(timeSet), lifetime) + }, lifetime*2, lifetime/100) // tick is kept at 1% of lifetime + // Assert with epsilon to somewhat account for NTP adjustments. + // Also see: https://github.com/elastic/go-freelru/issues/1 + assert.InEpsilon(t, lifetime, time.Since(timeSet), 0.015) // epsilon is kept at 1.5% } func BenchmarkLRUSetCheck(b *testing.B) {