Skip to content

Commit 7db4ff6

Browse files
committed
review comments
1 parent 90d2764 commit 7db4ff6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

internal/fs/inode/dir_prefetcher_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ func (t *DirPrefetchTest) TestMetadataPrefetcher_TTLGuard() {
344344
// 2. Immediate Run: Should NOT trigger another prefetch because the
345345
// TTL has not passed since the last run.
346346
p.Run("dir/obj2")
347-
assert.Eventually(t.T(), func() bool {
348-
return listCallCtr.Load() == 1
349-
}, 200*time.Millisecond, 10*time.Millisecond)
347+
// Wait to ensure no new prefetch is triggered.
348+
time.Sleep(20 * time.Millisecond)
349+
assert.Equal(t.T(), int32(1), listCallCtr.Load())
350350

351351
// 3. Run after TTL expiry: Should trigger a new prefetch.
352352
t.clock.AdvanceTime(60 * time.Second)
@@ -363,13 +363,15 @@ func (t *DirPrefetchTest) TestMetadataPrefetcher_0CacheSize() {
363363
MetadataCache: cfg.MetadataCacheConfig{
364364
EnableMetadataPrefetch: true,
365365
StatCacheMaxSizeMb: 0,
366+
TtlSecs: 60,
366367
},
367368
}
368369
p := NewMetadataPrefetcher(config, semaphore.NewWeighted(1), &t.clock, mockListFunc)
369370

370371
p.Run("dir/obj1")
371372

372-
assert.Eventually(t.T(), func() bool {
373-
return listCallCtr.Load() == 0
374-
}, 50*time.Millisecond, 10*time.Millisecond)
373+
// Allow some time for any potential background work to start.
374+
time.Sleep(20 * time.Millisecond)
375+
// Assert that no list calls were made because stat cache size is 0.
376+
assert.Equal(t.T(), int32(0), listCallCtr.Load())
375377
}

0 commit comments

Comments
 (0)