Skip to content

Commit bc6cebb

Browse files
committed
db: reduce TestBlobRewriteRandomized log spam
TestBlobRewriteRandomized logs a lot of context on its random state and operations and it's overwhelming when running tests with -v. This commit updates the test to write this context into an in-memory buffer, logging the contents only if the test fails.
1 parent 1e09c7f commit bc6cebb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

blob_rewrite_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ func TestBlobRewriteRandomized(t *testing.T) {
344344
referencingTables: originalTables,
345345
}}
346346

347+
var verboseBuffer bytes.Buffer
348+
verboseBuffer.Grow(16 << 10 /* 16KiB */)
349+
defer func() {
350+
if t.Failed() {
351+
t.Logf("verbose output:\n%s", verboseBuffer.String())
352+
}
353+
}()
354+
347355
for i := range numRewrites {
348356
fileIdx := rng.IntN(len(files))
349357
fileToRewrite := files[fileIdx]
@@ -357,7 +365,7 @@ func TestBlobRewriteRandomized(t *testing.T) {
357365
if len(fileToRewrite.valueIndices) > 1 {
358366
n = testutils.RandIntInRange(rng, 1, len(fileToRewrite.valueIndices))
359367
}
360-
t.Logf("rewriting file %s, preserving %d values", fileToRewrite.metadata.Physical.FileNum, n)
368+
fmt.Fprintf(&verboseBuffer, "rewriting file %s, preserving %d values\n", fileToRewrite.metadata.Physical.FileNum, n)
361369

362370
// Produce the inputs for the rewrite.
363371
newFile := sourceFile{
@@ -377,7 +385,7 @@ func TestBlobRewriteRandomized(t *testing.T) {
377385
}
378386
slices.Sort(newFile.valueIndices)
379387
for _, idx := range newFile.valueIndices {
380-
t.Logf("newFile.valueIndices: %d: %q; handle: %s", idx, values[idx], handles[idx])
388+
fmt.Fprintf(&verboseBuffer, "newFile.valueIndices: %d: %q; handle: %s\n", idx, values[idx], handles[idx])
381389
}
382390

383391
// Rewrite the blob file.

0 commit comments

Comments
 (0)