Skip to content

Commit

Permalink
Fix TestCancelCompactions on windows
Browse files Browse the repository at this point in the history
It seems that readOnlyDB was still opened which blocked the temp dir
cleanup.

Also changed the copy dir to be another TempDir instead of manually
creating one.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
  • Loading branch information
colega committed Mar 30, 2023
1 parent ae42dd4 commit 3ded84e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tsdb/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,12 +1171,9 @@ func TestCancelCompactions(t *testing.T) {
createBlock(t, tmpdir, genSeries(1, 1, 2000, 2001)) // The most recent block is ignored so can be e small one.

// Copy the db so we have an exact copy to compare compaction times.
tmpdirCopy := tmpdir + "Copy"
tmpdirCopy := t.TempDir()
err := fileutil.CopyDirs(tmpdir, tmpdirCopy)
require.NoError(t, err)
defer func() {
require.NoError(t, os.RemoveAll(tmpdirCopy))
}()

// Measure the compaction time without interrupting it.
var timeCompactionUninterrupted time.Duration
Expand Down Expand Up @@ -1228,6 +1225,7 @@ func TestCancelCompactions(t *testing.T) {
for i, b := range blocks {
require.Falsef(t, b.Meta().Compaction.Failed, "block %d (%s) should not be marked as compaction failed", i, b.Meta().ULID)
}
require.NoError(t, readOnlyDB.Close())
}
}

Expand Down

0 comments on commit 3ded84e

Please sign in to comment.