From 3fa636a799e129b936467306e78b3d02d9511c12 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Tue, 19 Apr 2022 19:57:33 +0000 Subject: [PATCH] fix unit test Signed-off-by: Mauro Stettler --- tsdb/head_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 997eec2a6..8e24a5b98 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -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) - require.Equal(t, 6, len(files)) + + // 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)