[#668] shard/test: Release shard in t.Cleanup()

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-09-06 17:18:04 +03:00 committed by Evgenii Stratonikov
parent 382eb8a485
commit 429f941cda
6 changed files with 3 additions and 7 deletions

View file

@ -28,7 +28,6 @@ func TestShard_Delete(t *testing.T) {
func testShardDelete(t *testing.T, hasWriteCache bool) {
sh := newShard(t, hasWriteCache)
defer releaseShard(sh, t)
cnr := cidtest.ID()

View file

@ -32,7 +32,6 @@ func TestShard_Get(t *testing.T) {
func testShardGet(t *testing.T, hasWriteCache bool) {
sh := newShard(t, hasWriteCache)
defer releaseShard(sh, t)
var putPrm PutPrm
var getPrm GetPrm

View file

@ -30,7 +30,6 @@ func TestShard_Head(t *testing.T) {
func testShardHead(t *testing.T, hasWriteCache bool) {
sh := newShard(t, hasWriteCache)
defer releaseShard(sh, t)
var putPrm PutPrm
var headPrm HeadPrm

View file

@ -27,7 +27,6 @@ func TestShard_Inhume(t *testing.T) {
func testShardInhume(t *testing.T, hasWriteCache bool) {
sh := newShard(t, hasWriteCache)
defer releaseShard(sh, t)
cnr := cidtest.ID()

View file

@ -18,14 +18,12 @@ func TestShard_List(t *testing.T) {
t.Run("without write cache", func(t *testing.T) {
t.Parallel()
sh := newShard(t, false)
defer releaseShard(sh, t)
testShardList(t, sh)
})
t.Run("with write cache", func(t *testing.T) {
t.Parallel()
shWC := newShard(t, true)
defer releaseShard(shWC, t)
testShardList(t, shWC)
})
}

View file

@ -31,10 +31,12 @@ func (s epochState) CurrentEpoch() uint64 {
}
func newShard(t testing.TB, enableWriteCache bool) *Shard {
return newCustomShard(t, t.TempDir(), enableWriteCache,
sh := newCustomShard(t, t.TempDir(), enableWriteCache,
writecacheconfig.Options{Type: writecacheconfig.TypeBBolt},
nil,
nil)
t.Cleanup(func() { releaseShard(sh, t) })
return sh
}
func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts writecacheconfig.Options, bsOpts []blobstor.Option, metaOptions []meta.Option) *Shard {