From 5b6be7bc1c809b4fbb9afbb393e54acb4d3df5c0 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 27 Oct 2021 17:50:58 +0300 Subject: [PATCH] [#948] engine: Fix test file path Before: `..blobstor` After: `/.blobstor` Signed-off-by: Alex Vanin --- pkg/local_object_storage/engine/control_test.go | 6 +++++- pkg/local_object_storage/engine/engine_test.go | 5 +++-- pkg/local_object_storage/shard/shard_test.go | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/local_object_storage/engine/control_test.go b/pkg/local_object_storage/engine/control_test.go index dd9b1437af..dab560a8f4 100644 --- a/pkg/local_object_storage/engine/control_test.go +++ b/pkg/local_object_storage/engine/control_test.go @@ -2,6 +2,7 @@ package engine import ( "errors" + "os" "testing" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" @@ -10,7 +11,10 @@ import ( func TestExecBlocks(t *testing.T) { e := testNewEngineWithShardNum(t, 2) // number doesn't matter in this test, 2 is several but not many - defer e.Close() + t.Cleanup(func() { + e.Close() + os.RemoveAll(t.Name()) + }) // put some object obj := generateRawObjectWithCID(t, cidtest.GenerateID()).Object() diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index 9169df519e..dacdf702f5 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "fmt" "math/rand" + "path" "sync" "testing" @@ -56,13 +57,13 @@ func testNewShard(t *testing.T, id int) *shard.Shard { shard.WithID(sid), shard.WithLogger(zap.L()), shard.WithBlobStorOptions( - blobstor.WithRootPath(fmt.Sprintf("%s.%d.blobstor", t.Name(), id)), + blobstor.WithRootPath(path.Join(t.Name(), fmt.Sprintf("%d.blobstor", id))), blobstor.WithBlobovniczaShallowWidth(2), blobstor.WithBlobovniczaShallowDepth(2), blobstor.WithRootPerm(0700), ), shard.WithMetaBaseOptions( - meta.WithPath(fmt.Sprintf("%s.%d.metabase", t.Name(), id)), + meta.WithPath(path.Join(t.Name(), fmt.Sprintf("%d.metabase", id))), meta.WithPermissions(0700), )) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index fcd6927a91..30807b2b2a 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -5,6 +5,7 @@ import ( "math/rand" "os" "path" + "strings" "testing" "github.com/nspcc-dev/neofs-node/pkg/core/object" @@ -60,7 +61,7 @@ func newShard(t testing.TB, enableWriteCache bool) *shard.Shard { func releaseShard(s *shard.Shard, t testing.TB) { s.Close() - os.RemoveAll(t.Name()) + os.RemoveAll(strings.Split(t.Name(), string(os.PathSeparator))[0]) } func generateRawObject(t *testing.T) *object.RawObject {