From 939a440d6bb2cb843220be779a39ecbb8d670b71 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Tue, 18 Jul 2023 23:13:57 +0800 Subject: [PATCH] pkg/ioutil: deflake TestPageWriterRandom The PageWriter has cache buffer so that it doesn't call the Writer until the cache is almost full. Since the data's length is random, the pending bytes should be always less than cache buffer size, instead of page size. Fix: #16255 Signed-off-by: Wei Fu (cherry picked from commit fddd1add52b33649a99d7f756404924138344a10) Signed-off-by: Wei Fu --- pkg/ioutil/pagewriter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ioutil/pagewriter_test.go b/pkg/ioutil/pagewriter_test.go index 10610691c..e1f41bb31 100644 --- a/pkg/ioutil/pagewriter_test.go +++ b/pkg/ioutil/pagewriter_test.go @@ -37,8 +37,8 @@ func TestPageWriterRandom(t *testing.T) { if cw.writeBytes > n { t.Fatalf("wrote %d bytes to io.Writer, but only wrote %d bytes", cw.writeBytes, n) } - if n-cw.writeBytes > pageBytes { - t.Fatalf("got %d bytes pending, expected less than %d bytes", n-cw.writeBytes, pageBytes) + if maxPendingBytes := pageBytes + defaultBufferBytes; n-cw.writeBytes > maxPendingBytes { + t.Fatalf("got %d bytes pending, expected less than %d bytes", n-cw.writeBytes, maxPendingBytes) } t.Logf("total writes: %d", cw.writes) t.Logf("total write bytes: %d (of %d)", cw.writeBytes, n)