mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
createPopulatedBlock returns the block dir instead of the block (#487)
It is easy to forget to close the block returned by createPopulatedBlock which causes failures for windows so instead it returns the block dir and which can be used by OpenBlock explicitly. Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
parent
090b6852e1
commit
a90a7195d4
|
@ -78,8 +78,8 @@ func createEmptyBlock(t *testing.T, dir string, meta *BlockMeta) *Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
// createPopulatedBlock creates a block with nSeries series, filled with
|
// createPopulatedBlock creates a block with nSeries series, filled with
|
||||||
// samples of the given mint,maxt time range.
|
// samples of the given mint,maxt time range and returns its dir.
|
||||||
func createPopulatedBlock(tb testing.TB, dir string, nSeries int, mint, maxt int64) *Block {
|
func createPopulatedBlock(tb testing.TB, dir string, nSeries int, mint, maxt int64) string {
|
||||||
head, err := NewHead(nil, nil, nil, 2*60*60*1000)
|
head, err := NewHead(nil, nil, nil, 2*60*60*1000)
|
||||||
testutil.Ok(tb, err)
|
testutil.Ok(tb, err)
|
||||||
defer head.Close()
|
defer head.Close()
|
||||||
|
@ -113,7 +113,5 @@ func createPopulatedBlock(tb testing.TB, dir string, nSeries int, mint, maxt int
|
||||||
ulid, err := compactor.Write(dir, head, head.MinTime(), head.MaxTime(), nil)
|
ulid, err := compactor.Write(dir, head, head.MinTime(), head.MaxTime(), nil)
|
||||||
testutil.Ok(tb, err)
|
testutil.Ok(tb, err)
|
||||||
|
|
||||||
blk, err := OpenBlock(filepath.Join(dir, ulid.String()), nil)
|
return filepath.Join(dir, ulid.String())
|
||||||
testutil.Ok(tb, err)
|
|
||||||
return blk
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1232,7 +1232,8 @@ func BenchmarkPersistedQueries(b *testing.B) {
|
||||||
dir, err := ioutil.TempDir("", "bench_persisted")
|
dir, err := ioutil.TempDir("", "bench_persisted")
|
||||||
testutil.Ok(b, err)
|
testutil.Ok(b, err)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
block := createPopulatedBlock(b, dir, nSeries, 1, int64(nSamples))
|
block, err := OpenBlock(createPopulatedBlock(b, dir, nSeries, 1, int64(nSamples)), nil)
|
||||||
|
testutil.Ok(b, err)
|
||||||
defer block.Close()
|
defer block.Close()
|
||||||
|
|
||||||
q, err := NewBlockQuerier(block, block.Meta().MinTime, block.Meta().MaxTime)
|
q, err := NewBlockQuerier(block, block.Meta().MinTime, block.Meta().MaxTime)
|
||||||
|
|
Loading…
Reference in a new issue