Skip to content

Commit ba7adb6

Browse files
committed
Fix tests
1 parent b1da814 commit ba7adb6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/api/memory_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ func TestMemoryLeakScenarios(t *testing.T) {
224224
run: func(t *testing.T) {
225225
t.Helper()
226226
// Ensure that releasing caches frees memory.
227-
getAlloc := func() uint64 {
227+
getAlloc := func() int64 {
228228
var m runtime.MemStats
229229
runtime.ReadMemStats(&m)
230-
return m.HeapAlloc
230+
return int64(m.HeapAlloc)
231231
}
232232

233233
runtime.GC()
@@ -260,7 +260,7 @@ func TestMemoryLeakScenarios(t *testing.T) {
260260
}
261261
runtime.GC()
262262
// Wait to allow GC to complete.
263-
time.Sleep(5 * time.Second)
263+
time.Sleep(1 * time.Second)
264264

265265
allocAfterRelease := getAlloc()
266266

@@ -609,15 +609,15 @@ func TestMemoryMetrics(t *testing.T) {
609609
runtime.GC()
610610

611611
// Wait a moment to allow GC to complete.
612-
time.Sleep(5 * time.Second)
612+
time.Sleep(1 * time.Second)
613613

614614
runtime.ReadMemStats(&mAfter)
615615
t.Logf("Mallocs: before=%d, after=%d, diff=%d", mBefore.Mallocs, mAfter.Mallocs, mAfter.Mallocs-mBefore.Mallocs)
616616
t.Logf("Frees: before=%d, after=%d, diff=%d", mBefore.Frees, mAfter.Frees, mAfter.Frees-mBefore.Frees)
617617

618618
// Use original acceptable threshold.
619-
diff := mAfter.Mallocs - mAfter.Frees
620-
require.LessOrEqual(t, diff, uint64(allocCount/10), "Unexpected allocation leak detected")
619+
diff := int64(mAfter.Mallocs-mBefore.Mallocs) - int64(mAfter.Frees-mBefore.Frees)
620+
require.LessOrEqual(t, diff, int64(allocCount/10), "Unexpected allocation leak detected")
621621
}
622622

623623
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)