Skip to content

Commit 3ee9be1

Browse files
authored
db/state: skip Benchmark_BtreeIndex_Search when data file is absent (#19506)
`Benchmark_BtreeIndex_Search` hardcodes a path to an external data file (`../../data/storage.256-288.kv`) that doesn't exist in the repo, causing the benchmark to fail rather than skip when the file is absent. This applies the same `os.Stat` + `b.Skip()` guard already used by `Benchmark_Recsplit_Find_ExternalFile` in the same file. Spotted while experimenting with benchmarks.
1 parent b140eaf commit 3ee9be1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

db/state/aggregator_bench_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ func queueKeys(ctx context.Context, seed, ofSize uint64) <-chan []byte {
109109
}
110110

111111
func Benchmark_BtreeIndex_Search(b *testing.B) {
112+
dataPath := "../../data/storage.256-288.kv"
113+
f, err := os.Stat(dataPath)
114+
if err != nil || f.IsDir() {
115+
b.Skip("requires existing KV file at ../../data/storage.256-288.kv")
116+
}
117+
112118
logger := log.New()
113119
rnd := newRnd(uint64(time.Now().UnixNano()))
114120
tmp := b.TempDir()
115121
defer dir.RemoveAll(tmp)
116-
dataPath := "../../data/storage.256-288.kv"
117122

118123
indexPath := filepath.Join(tmp, filepath.Base(dataPath)+".bti")
119124
comp := seg.CompressKeys | seg.CompressVals

0 commit comments

Comments
 (0)