Skip to content

Commit

Permalink
fix StableMaxAlloc
Browse files Browse the repository at this point in the history
  • Loading branch information
VinozzZ committed Nov 8, 2024
1 parent d58efe4 commit ca1e6c7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions collect/collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca1e6c7

Please sign in to comment.