fix unit test

Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
This commit is contained in:
Mauro Stettler 2022-04-19 19:57:33 +00:00
parent 04114aa2e6
commit 3fa636a799
No known key found for this signature in database
GPG key ID: 1EBC1C55E2D201A2

View file

@ -1618,7 +1618,6 @@ func TestHeadReadWriterRepair(t *testing.T) {
opts := DefaultHeadOptions()
opts.ChunkRange = chunkRange
opts.ChunkDirRoot = dir
opts.ChunkWriteQueueSize = 1 // We need to set this option so that we use the async queue. Upstream prometheus uses the queue directly.
h, err := NewHead(nil, nil, w, opts, nil)
require.NoError(t, err)
require.Equal(t, 0.0, prom_testutil.ToFloat64(h.metrics.mmapChunkCorruptionTotal))
@ -1643,7 +1642,14 @@ func TestHeadReadWriterRepair(t *testing.T) {
// take effect without another chunk being written.
files, err := ioutil.ReadDir(mmappedChunksDir(dir))
require.NoError(t, err)
// With the new chunk disk mapper we only expect 6 files, because the last call to "CutNewFile()" won't
// take effect until the next chunk is being written.
if opts.NewChunkDiskMapper {
require.Equal(t, 6, len(files))
} else {
require.Equal(t, 7, len(files))
}
// Corrupt the 4th file by writing a random byte to series ref.
f, err := os.OpenFile(filepath.Join(mmappedChunksDir(dir), files[3].Name()), os.O_WRONLY, 0o666)