From ca1e6c796cdf5a3385f57d5ca9eefbe35236c59e Mon Sep 17 00:00:00 2001 From: Yingrong Zhao <22300958+VinozzZ@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:48:41 -0500 Subject: [PATCH] fix StableMaxAlloc --- collect/collect_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/collect/collect_test.go b/collect/collect_test.go index 1833f62568..513c4cc103 100644 --- a/collect/collect_test.go +++ b/collect/collect_test.go @@ -812,10 +812,13 @@ func TestStableMaxAlloc(t *testing.T) { runtime.ReadMemStats(&mem) // Set MaxAlloc, which should cause cache evictions. conf.GetCollectionConfigVal.MaxAlloc = config.MemorySize(mem.Alloc * 99 / 100) - peerTrace := coll.cache.Get(peerTraceIDs[0]) + orphanPeerTrace := coll.cache.Get(peerTraceIDs[0]) - peerTrace.SendBy = coll.Clock.Now().Add(-conf.GetTracesConfig().GetTraceTimeout() * 5) - assert.True(t, peerTrace.IsOrphan(conf.GetTracesConfig().GetTraceTimeout(), coll.Clock.Now())) + orphanPeerTrace.SendBy = coll.Clock.Now().Add(-conf.GetTracesConfig().GetTraceTimeout() * 5) + peerSpan := orphanPeerTrace.GetSpans()[0] + // cache impact is also calculated based on the arrival time + peerSpan.ArrivalTime = coll.Clock.Now().Add(-conf.GetTracesConfig().GetTraceTimeout()) + assert.True(t, orphanPeerTrace.IsOrphan(conf.GetTracesConfig().GetTraceTimeout(), coll.Clock.Now())) coll.mutex.Unlock() // wait for the cache to take some action