From 511c96fd2fd93fc5441366f60795b688fbbf09b4 Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Thu, 19 Sep 2024 19:03:15 +0300 Subject: [PATCH] *: fix `unused` and `ineffassign` lint errors Signed-off-by: Andrey Butusov --- pkg/innerring/config_test.go | 4 ++-- .../engine/control_test.go | 2 +- pkg/local_object_storage/engine/delete_test.go | 6 +++--- pkg/local_object_storage/engine/engine_test.go | 4 ++-- pkg/local_object_storage/engine/error_test.go | 6 +++--- .../engine/evacuate_test.go | 2 +- pkg/local_object_storage/engine/gc_test.go | 18 +++++++++--------- pkg/local_object_storage/engine/get_test.go | 2 +- pkg/local_object_storage/engine/head_test.go | 6 +++--- pkg/local_object_storage/engine/inhume_test.go | 10 +++++----- pkg/local_object_storage/engine/list_test.go | 2 +- pkg/local_object_storage/engine/tree_test.go | 2 +- .../metabase/delete_test.go | 4 ++-- .../metabase/exists_test.go | 1 + .../metabase/graveyard_test.go | 4 ---- .../pilorama/forest_test.go | 1 + .../shard/container_test.go | 10 +++------- pkg/local_object_storage/shard/delete_test.go | 4 ++-- pkg/local_object_storage/shard/dump_test.go | 6 +++--- pkg/local_object_storage/shard/gc_test.go | 6 +++--- pkg/local_object_storage/shard/get_test.go | 10 +++++----- pkg/local_object_storage/shard/head_test.go | 6 +++--- pkg/local_object_storage/shard/inhume_test.go | 4 ++-- pkg/local_object_storage/shard/list_test.go | 4 ++-- pkg/local_object_storage/shard/lock_test.go | 10 +++++----- pkg/local_object_storage/shard/metrics_test.go | 5 ++--- pkg/local_object_storage/shard/range_test.go | 2 +- pkg/local_object_storage/shard/shard_test.go | 10 +++++----- .../shard/shutdown_test.go | 7 ++----- pkg/services/object/get/get_test.go | 11 ----------- pkg/services/object/tombstone/verify_test.go | 12 ++++++------ .../object_manager/placement/traverser_test.go | 16 ++++++++-------- 32 files changed, 88 insertions(+), 109 deletions(-) diff --git a/pkg/innerring/config_test.go b/pkg/innerring/config_test.go index a483ff5e41..9dde6e47b0 100644 --- a/pkg/innerring/config_test.go +++ b/pkg/innerring/config_test.go @@ -540,7 +540,7 @@ func TestIsAutoDeploymentMode(t *testing.T) { err = os.Setenv(envKey, "not a boolean") require.NoError(t, err) - b, err = isAutoDeploymentMode(v) + _, err = isAutoDeploymentMode(v) require.Error(t, err) err = os.Setenv(envKey, "false") @@ -571,7 +571,7 @@ fschain_autodeploy: true v.Set("fschain_autodeploy", "not a boolean") - b, err = isAutoDeploymentMode(v) + _, err = isAutoDeploymentMode(v) require.Error(t, err) v.Set("fschain_autodeploy", "false") diff --git a/pkg/local_object_storage/engine/control_test.go b/pkg/local_object_storage/engine/control_test.go index 48c857a8fa..7dd8d8647c 100644 --- a/pkg/local_object_storage/engine/control_test.go +++ b/pkg/local_object_storage/engine/control_test.go @@ -150,7 +150,7 @@ func TestExecBlocks(t *testing.T) { }) // put some object - obj := generateObjectWithCID(t, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) addr := object.AddressOf(obj) diff --git a/pkg/local_object_storage/engine/delete_test.go b/pkg/local_object_storage/engine/delete_test.go index 89c8e1246e..09f4ecb4be 100644 --- a/pkg/local_object_storage/engine/delete_test.go +++ b/pkg/local_object_storage/engine/delete_test.go @@ -21,7 +21,7 @@ func TestDeleteBigObject(t *testing.T) { parentID := oidtest.ID() splitID := objectSDK.NewSplitID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) parent.SetID(parentID) parent.SetPayload(nil) @@ -29,7 +29,7 @@ func TestDeleteBigObject(t *testing.T) { children := make([]*objectSDK.Object, childCount) childIDs := make([]oid.ID, childCount) for i := range children { - children[i] = generateObjectWithCID(t, cnr) + children[i] = generateObjectWithCID(cnr) if i != 0 { children[i].SetPreviousID(childIDs[i-1]) } @@ -41,7 +41,7 @@ func TestDeleteBigObject(t *testing.T) { childIDs[i], _ = children[i].ID() } - link := generateObjectWithCID(t, cnr) + link := generateObjectWithCID(cnr) link.SetParent(parent) link.SetParentID(parentID) link.SetSplitID(splitID) diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index 26a8519f5e..1e8dbb1667 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -63,7 +63,7 @@ func benchmarkExists(b *testing.B, shardNum int) { addr := oidtest.Address() for range 100 { - obj := generateObjectWithCID(b, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) err := Put(e, obj) if err != nil { b.Fatal(err) @@ -174,7 +174,7 @@ func testEngineFromShardOpts(t *testing.T, num int, extraOpts []shard.Option) *S return engine } -func generateObjectWithCID(t testing.TB, cnr cid.ID) *object.Object { +func generateObjectWithCID(cnr cid.ID) *object.Object { var ver version.Version ver.SetMajor(2) ver.SetMinor(1) diff --git a/pkg/local_object_storage/engine/error_test.go b/pkg/local_object_storage/engine/error_test.go index 845158dfb6..7c9b549c4e 100644 --- a/pkg/local_object_storage/engine/error_test.go +++ b/pkg/local_object_storage/engine/error_test.go @@ -65,7 +65,7 @@ func TestErrorReporting(t *testing.T) { t.Run("ignore errors by default", func(t *testing.T) { e, dir, id := newEngineWithErrorThreshold(t, "", 0) - obj := generateObjectWithCID(t, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) obj.SetPayload(make([]byte, errSmallSize)) var prm shard.PutPrm @@ -95,7 +95,7 @@ func TestErrorReporting(t *testing.T) { e, dir, id := newEngineWithErrorThreshold(t, "", errThreshold) - obj := generateObjectWithCID(t, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) obj.SetPayload(make([]byte, errSmallSize)) var prm shard.PutPrm @@ -145,7 +145,7 @@ func TestBlobstorFailback(t *testing.T) { objs := make([]*objectSDK.Object, 0, 2) for _, size := range []int{15, errSmallSize + 1} { - obj := generateObjectWithCID(t, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) obj.SetPayload(make([]byte, size)) var prm shard.PutPrm diff --git a/pkg/local_object_storage/engine/evacuate_test.go b/pkg/local_object_storage/engine/evacuate_test.go index d8cdc42562..f4c3b283a6 100644 --- a/pkg/local_object_storage/engine/evacuate_test.go +++ b/pkg/local_object_storage/engine/evacuate_test.go @@ -53,7 +53,7 @@ func newEngineEvacuate(t *testing.T, shardNum int, objPerShard int) (*StorageEng objects := make([]*objectSDK.Object, 0, objPerShard*len(ids)) for i := 0; ; i++ { - objects = append(objects, generateObjectWithCID(t, cidtest.ID())) + objects = append(objects, generateObjectWithCID(cidtest.ID())) var putPrm PutPrm putPrm.WithObject(objects[i]) diff --git a/pkg/local_object_storage/engine/gc_test.go b/pkg/local_object_storage/engine/gc_test.go index 01515b902a..5ec981e8be 100644 --- a/pkg/local_object_storage/engine/gc_test.go +++ b/pkg/local_object_storage/engine/gc_test.go @@ -67,27 +67,27 @@ func TestChildrenExpiration(t *testing.T) { cnr := cidtest.ID() splitID := objectSDK.NewSplitID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) parentID, _ := parent.ID() parent.SetAttributes(expAttr) - child1 := generateObjectWithCID(t, cnr) + child1 := generateObjectWithCID(cnr) child1ID, _ := child1.ID() child1.SetSplitID(splitID) - child2 := generateObjectWithCID(t, cnr) + child2 := generateObjectWithCID(cnr) child2ID, _ := child2.ID() child2.SetSplitID(splitID) child2.SetPreviousID(child1ID) - child3 := generateObjectWithCID(t, cnr) + child3 := generateObjectWithCID(cnr) child3ID, _ := child3.ID() child3.SetSplitID(splitID) child3.SetPreviousID(child2ID) child3.SetParent(parent) child3.SetParentID(parentID) - link := generateObjectWithCID(t, cnr) + link := generateObjectWithCID(cnr) link.SetParent(parent) link.SetParentID(parentID) link.SetChildren(child1ID, child2ID, child3ID) @@ -106,20 +106,20 @@ func TestChildrenExpiration(t *testing.T) { t.Run("V2", func(t *testing.T) { cnr := cidtest.ID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) parentID, _ := parent.ID() parent.SetAttributes(expAttr) - child1 := generateObjectWithCID(t, cnr) + child1 := generateObjectWithCID(cnr) child1ID, _ := child1.ID() child1.SetParent(parent) - child2 := generateObjectWithCID(t, cnr) + child2 := generateObjectWithCID(cnr) child2ID, _ := child2.ID() child2.SetFirstID(child1ID) child2.SetPreviousID(child1ID) - child3 := generateObjectWithCID(t, cnr) + child3 := generateObjectWithCID(cnr) child3ID, _ := child3.ID() child3.SetFirstID(child1ID) child3.SetPreviousID(child2ID) diff --git a/pkg/local_object_storage/engine/get_test.go b/pkg/local_object_storage/engine/get_test.go index f1e2732c61..c5bf6aee2b 100644 --- a/pkg/local_object_storage/engine/get_test.go +++ b/pkg/local_object_storage/engine/get_test.go @@ -10,7 +10,7 @@ import ( func TestStorageEngine_GetBytes(t *testing.T) { e, _, _ := newEngine(t, t.TempDir()) - obj := generateObjectWithCID(t, cidtest.ID()) + obj := generateObjectWithCID(cidtest.ID()) addr := object.AddressOf(obj) objBin := obj.Marshal() diff --git a/pkg/local_object_storage/engine/head_test.go b/pkg/local_object_storage/engine/head_test.go index 2ebf641d16..5cd5a66f4a 100644 --- a/pkg/local_object_storage/engine/head_test.go +++ b/pkg/local_object_storage/engine/head_test.go @@ -17,7 +17,7 @@ func TestHeadRaw(t *testing.T) { cnr := cidtest.ID() splitID := object.NewSplitID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) addAttribute(parent, "foo", "bar") var parentAddr oid.Address @@ -26,12 +26,12 @@ func TestHeadRaw(t *testing.T) { idParent, _ := parent.ID() parentAddr.SetObject(idParent) - child := generateObjectWithCID(t, cnr) + child := generateObjectWithCID(cnr) child.SetParent(parent) child.SetParentID(idParent) child.SetSplitID(splitID) - link := generateObjectWithCID(t, cnr) + link := generateObjectWithCID(cnr) link.SetParent(parent) link.SetParentID(idParent) diff --git a/pkg/local_object_storage/engine/inhume_test.go b/pkg/local_object_storage/engine/inhume_test.go index dc033ce743..ba611ce34c 100644 --- a/pkg/local_object_storage/engine/inhume_test.go +++ b/pkg/local_object_storage/engine/inhume_test.go @@ -22,16 +22,16 @@ func TestStorageEngine_Inhume(t *testing.T) { fs := objectSDK.SearchFilters{} fs.AddRootFilter() - tombstoneID := object.AddressOf(generateObjectWithCID(t, cnr)) - parent := generateObjectWithCID(t, cnr) + tombstoneID := object.AddressOf(generateObjectWithCID(cnr)) + parent := generateObjectWithCID(cnr) - child := generateObjectWithCID(t, cnr) + child := generateObjectWithCID(cnr) child.SetParent(parent) idParent, _ := parent.ID() child.SetParentID(idParent) child.SetSplitID(splitID) - link := generateObjectWithCID(t, cnr) + link := generateObjectWithCID(cnr) link.SetParent(parent) link.SetParentID(idParent) idChild, _ := child.ID() @@ -113,7 +113,7 @@ func TestStorageEngine_Inhume(t *testing.T) { }) t.Run("object is on wrong shard", func(t *testing.T) { - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) addr := object.AddressOf(obj) e := testNewEngineWithShardNum(t, 2) diff --git a/pkg/local_object_storage/engine/list_test.go b/pkg/local_object_storage/engine/list_test.go index 2871e1e7a2..9cb27dfdfe 100644 --- a/pkg/local_object_storage/engine/list_test.go +++ b/pkg/local_object_storage/engine/list_test.go @@ -29,7 +29,7 @@ func TestListWithCursor(t *testing.T) { for range total { containerID := cidtest.ID() - obj := generateObjectWithCID(t, containerID) + obj := generateObjectWithCID(containerID) var prm PutPrm prm.WithObject(obj) diff --git a/pkg/local_object_storage/engine/tree_test.go b/pkg/local_object_storage/engine/tree_test.go index 504f49ec42..2a340d10ac 100644 --- a/pkg/local_object_storage/engine/tree_test.go +++ b/pkg/local_object_storage/engine/tree_test.go @@ -28,7 +28,7 @@ func benchmarkTreeVsSearch(b *testing.B, objCount int) { treeID := "someTree" for i := range objCount { - obj := generateObjectWithCID(b, cid) + obj := generateObjectWithCID(cid) addAttribute(obj, pilorama.AttributeFilename, strconv.Itoa(i)) err := Put(e, obj) if err != nil { diff --git a/pkg/local_object_storage/metabase/delete_test.go b/pkg/local_object_storage/metabase/delete_test.go index 9202ce63bb..8396a5dfa8 100644 --- a/pkg/local_object_storage/metabase/delete_test.go +++ b/pkg/local_object_storage/metabase/delete_test.go @@ -61,10 +61,10 @@ func TestDB_Delete(t *testing.T) { // check if they marked as already removed ok, err := metaExists(db, object.AddressOf(child)) - require.Error(t, apistatus.ObjectAlreadyRemoved{}) + require.Error(t, err, apistatus.ObjectAlreadyRemoved{}) require.False(t, ok) - ok, err = metaExists(db, object.AddressOf(parent)) + ok, _ = metaExists(db, object.AddressOf(parent)) require.Error(t, apistatus.ObjectAlreadyRemoved{}) require.False(t, ok) } diff --git a/pkg/local_object_storage/metabase/exists_test.go b/pkg/local_object_storage/metabase/exists_test.go index e5c3245d4f..d773ceeede 100644 --- a/pkg/local_object_storage/metabase/exists_test.go +++ b/pkg/local_object_storage/metabase/exists_test.go @@ -180,6 +180,7 @@ func TestDB_Exists(t *testing.T) { require.ErrorIs(t, err, meta.ErrObjectIsExpired) gotObj, err = metaExists(db, object.AddressOf(nonExp)) + require.NoError(t, err) require.True(t, gotObj) }) }) diff --git a/pkg/local_object_storage/metabase/graveyard_test.go b/pkg/local_object_storage/metabase/graveyard_test.go index 747e512ac2..1aa483e6a6 100644 --- a/pkg/local_object_storage/metabase/graveyard_test.go +++ b/pkg/local_object_storage/metabase/graveyard_test.go @@ -7,7 +7,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/core/object" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" - objectsdk "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test" "github.com/stretchr/testify/require" @@ -442,7 +441,6 @@ func TestDB_GetGarbage(t *testing.T) { const numOfObjs = 5 cID := cidtest.ID() - var oo []*objectsdk.Object var size uint64 for i := range numOfObjs { @@ -450,7 +448,6 @@ func TestDB_GetGarbage(t *testing.T) { addAttribute(raw, "foo"+strconv.Itoa(i), "bar"+strconv.Itoa(i)) size += raw.PayloadSize() - oo = append(oo, raw) err := putBig(db, raw) require.NoError(t, err) @@ -460,7 +457,6 @@ func TestDB_GetGarbage(t *testing.T) { anotherObj := generateObjectWithCID(t, cidtest.ID()) err := putBig(db, anotherObj) require.NoError(t, err) - oo = append(oo, anotherObj) _, err = db.InhumeContainer(cID) require.NoError(t, err) diff --git a/pkg/local_object_storage/pilorama/forest_test.go b/pkg/local_object_storage/pilorama/forest_test.go index fd7138193f..3de04808a5 100644 --- a/pkg/local_object_storage/pilorama/forest_test.go +++ b/pkg/local_object_storage/pilorama/forest_test.go @@ -226,6 +226,7 @@ func testForestTreeDrop(t *testing.T, s Forest) { } } list, err := s.TreeList(cid) + require.NoError(t, err) require.NotEmpty(t, list) require.NoError(t, s.TreeDrop(cid, "")) diff --git a/pkg/local_object_storage/shard/container_test.go b/pkg/local_object_storage/shard/container_test.go index f7a59817c4..ca1d0de44d 100644 --- a/pkg/local_object_storage/shard/container_test.go +++ b/pkg/local_object_storage/shard/container_test.go @@ -15,28 +15,24 @@ func TestShard_DeleteContainer(t *testing.T) { defer releaseShard(sh, t) cID := cidtest.ID() - var objs []*objectSDK.Object var prm shard.PutPrm - o1 := generateObjectWithCID(t, cID) + o1 := generateObjectWithCID(cID) prm.SetObject(o1) _, err := sh.Put(prm) require.NoError(t, err) - objs = append(objs, o1) - o2 := generateObjectWithCID(t, cID) + o2 := generateObjectWithCID(cID) o2.SetType(objectSDK.TypeStorageGroup) prm.SetObject(o2) _, err = sh.Put(prm) require.NoError(t, err) - objs = append(objs, o2) - o3 := generateObjectWithCID(t, cID) + o3 := generateObjectWithCID(cID) prm.SetObject(o3) o3.SetType(objectSDK.TypeLock) _, err = sh.Put(prm) require.NoError(t, err) - objs = append(objs, o3) err = sh.DeleteContainer(context.Background(), cID) require.NoError(t, err) diff --git a/pkg/local_object_storage/shard/delete_test.go b/pkg/local_object_storage/shard/delete_test.go index 2acd094b04..02363f6b55 100644 --- a/pkg/local_object_storage/shard/delete_test.go +++ b/pkg/local_object_storage/shard/delete_test.go @@ -26,7 +26,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) { cnr := cidtest.ID() - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) addAttribute(obj, "foo", "bar") var putPrm shard.PutPrm @@ -55,7 +55,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) { }) t.Run("small object", func(t *testing.T) { - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) addAttribute(obj, "foo", "bar") addPayload(obj, 1<<5) diff --git a/pkg/local_object_storage/shard/dump_test.go b/pkg/local_object_storage/shard/dump_test.go index 2509f63531..573b1a8097 100644 --- a/pkg/local_object_storage/shard/dump_test.go +++ b/pkg/local_object_storage/shard/dump_test.go @@ -96,7 +96,7 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) { } data := make([]byte, size) _, _ = rand.Read(data) - obj := generateObjectWithPayload(t, cnr, data) + obj := generateObjectWithPayload(cnr, data) objects[i] = obj var prm shard.PutPrm @@ -226,7 +226,7 @@ func TestStream(t *testing.T) { objects := make([]*objectSDK.Object, objCount) for i := range objCount { cnr := cidtest.ID() - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) objects[i] = obj var prm shard.PutPrm @@ -321,7 +321,7 @@ func TestDumpIgnoreErrors(t *testing.T) { objects := make([]*objectSDK.Object, objCount) for i := range objCount { size := (wcSmallObjectSize << (i % 4)) - headerSize - obj := generateObjectWithPayload(t, cidtest.ID(), make([]byte, size)) + obj := generateObjectWithPayload(cidtest.ID(), make([]byte, size)) objects[i] = obj var prm shard.PutPrm diff --git a/pkg/local_object_storage/shard/gc_test.go b/pkg/local_object_storage/shard/gc_test.go index fe9ef3f20a..f152b51799 100644 --- a/pkg/local_object_storage/shard/gc_test.go +++ b/pkg/local_object_storage/shard/gc_test.go @@ -85,13 +85,13 @@ func TestGC_ExpiredObjectWithExpiredLock(t *testing.T) { expAttr.SetKey(objectV2.SysAttributeExpEpoch) expAttr.SetValue("1") - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) obj.SetAttributes(expAttr) objID, _ := obj.ID() expAttr.SetValue("3") - lock := generateObjectWithCID(t, cnr) + lock := generateObjectWithCID(cnr) lock.SetType(object.TypeLock) lock.SetAttributes(expAttr) lockID, _ := lock.ID() @@ -134,7 +134,7 @@ func TestGC_ContainerCleanup(t *testing.T) { for i := range numOfObjs { var putPrm shard.PutPrm - obj := generateObjectWithCID(t, cID) + obj := generateObjectWithCID(cID) addAttribute(obj, fmt.Sprintf("foo%d", i), fmt.Sprintf("bar%d", i)) if i%2 == 0 { addPayload(obj, 1<<5) // small diff --git a/pkg/local_object_storage/shard/get_test.go b/pkg/local_object_storage/shard/get_test.go index 9010254d41..0376f72bff 100644 --- a/pkg/local_object_storage/shard/get_test.go +++ b/pkg/local_object_storage/shard/get_test.go @@ -33,7 +33,7 @@ func testShardGet(t *testing.T, hasWriteCache bool) { var getPrm shard.GetPrm t.Run("small object", func(t *testing.T) { - obj := generateObject(t) + obj := generateObject() addAttribute(obj, "foo", "bar") addPayload(obj, 1<<5) addr := object.AddressOf(obj) @@ -54,7 +54,7 @@ func testShardGet(t *testing.T, hasWriteCache bool) { }) t.Run("big object", func(t *testing.T) { - obj := generateObject(t) + obj := generateObject() addAttribute(obj, "foo", "bar") obj.SetID(oidtest.ID()) addPayload(obj, 1<<20) // big obj @@ -76,15 +76,15 @@ func testShardGet(t *testing.T, hasWriteCache bool) { }) t.Run("parent object", func(t *testing.T) { - obj := generateObject(t) + obj := generateObject() addAttribute(obj, "foo", "bar") cnr := cidtest.ID() splitID := objectSDK.NewSplitID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) addAttribute(parent, "parent", "attribute") - child := generateObjectWithCID(t, cnr) + child := generateObjectWithCID(cnr) child.SetParent(parent) idParent, _ := parent.ID() child.SetParentID(idParent) diff --git a/pkg/local_object_storage/shard/head_test.go b/pkg/local_object_storage/shard/head_test.go index 00de09cfd9..c9bf80c064 100644 --- a/pkg/local_object_storage/shard/head_test.go +++ b/pkg/local_object_storage/shard/head_test.go @@ -30,7 +30,7 @@ func testShardHead(t *testing.T, hasWriteCache bool) { var headPrm shard.HeadPrm t.Run("regular object", func(t *testing.T) { - obj := generateObject(t) + obj := generateObject() addAttribute(obj, "foo", "bar") putPrm.SetObject(obj) @@ -49,10 +49,10 @@ func testShardHead(t *testing.T, hasWriteCache bool) { cnr := cidtest.ID() splitID := objectSDK.NewSplitID() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) addAttribute(parent, "foo", "bar") - child := generateObjectWithCID(t, cnr) + child := generateObjectWithCID(cnr) child.SetParent(parent) idParent, _ := parent.ID() child.SetParentID(idParent) diff --git a/pkg/local_object_storage/shard/inhume_test.go b/pkg/local_object_storage/shard/inhume_test.go index 011b0266fe..d5187bb3a1 100644 --- a/pkg/local_object_storage/shard/inhume_test.go +++ b/pkg/local_object_storage/shard/inhume_test.go @@ -26,10 +26,10 @@ func testShardInhume(t *testing.T, hasWriteCache bool) { cnr := cidtest.ID() - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) addAttribute(obj, "foo", "bar") - ts := generateObjectWithCID(t, cnr) + ts := generateObjectWithCID(cnr) var putPrm shard.PutPrm putPrm.SetObject(obj) diff --git a/pkg/local_object_storage/shard/list_test.go b/pkg/local_object_storage/shard/list_test.go index 9c7332766c..9ebffe2be1 100644 --- a/pkg/local_object_storage/shard/list_test.go +++ b/pkg/local_object_storage/shard/list_test.go @@ -38,11 +38,11 @@ func testShardList(t *testing.T, sh *shard.Shard) { cnr := cidtest.ID() for range N { - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) addPayload(obj, 1<<2) // add parent as virtual object, it must be ignored in List() - parent := generateObjectWithCID(t, cnr) + parent := generateObjectWithCID(cnr) idParent, _ := parent.ID() obj.SetParentID(idParent) obj.SetParent(parent) diff --git a/pkg/local_object_storage/shard/lock_test.go b/pkg/local_object_storage/shard/lock_test.go index bc5826a89b..424327cd22 100644 --- a/pkg/local_object_storage/shard/lock_test.go +++ b/pkg/local_object_storage/shard/lock_test.go @@ -58,10 +58,10 @@ func TestShard_Lock(t *testing.T) { }) cnr := cidtest.ID() - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) objID, _ := obj.ID() - lock := generateObjectWithCID(t, cnr) + lock := generateObjectWithCID(cnr) lock.SetType(object.TypeLock) lockID, _ := lock.ID() @@ -83,7 +83,7 @@ func TestShard_Lock(t *testing.T) { require.NoError(t, err) t.Run("inhuming locked objects", func(t *testing.T) { - ts := generateObjectWithCID(t, cnr) + ts := generateObjectWithCID(cnr) var inhumePrm shard.InhumePrm inhumePrm.InhumeByTomb(objectcore.AddressOf(ts), objectcore.AddressOf(obj)) @@ -97,7 +97,7 @@ func TestShard_Lock(t *testing.T) { }) t.Run("inhuming lock objects", func(t *testing.T) { - ts := generateObjectWithCID(t, cnr) + ts := generateObjectWithCID(cnr) var inhumePrm shard.InhumePrm inhumePrm.InhumeByTomb(objectcore.AddressOf(ts), objectcore.AddressOf(lock)) @@ -141,7 +141,7 @@ func TestShard_IsLocked(t *testing.T) { sh := newShard(t, false) cnr := cidtest.ID() - obj := generateObjectWithCID(t, cnr) + obj := generateObjectWithCID(cnr) cnrID, _ := obj.ContainerID() objID, _ := obj.ID() diff --git a/pkg/local_object_storage/shard/metrics_test.go b/pkg/local_object_storage/shard/metrics_test.go index b288769445..e6212c2edc 100644 --- a/pkg/local_object_storage/shard/metrics_test.go +++ b/pkg/local_object_storage/shard/metrics_test.go @@ -68,7 +68,6 @@ func (m *metricsStore) AddToPayloadSize(size int64) { const physical = "phy" const logical = "logic" -const readonly = "readonly" func TestCounters(t *testing.T) { dir := t.TempDir() @@ -84,7 +83,7 @@ func TestCounters(t *testing.T) { const objNumber = 10 oo := make([]*object.Object, objNumber) for i := range objNumber { - oo[i] = generateObject(t) + oo[i] = generateObject() } t.Run("defaults", func(t *testing.T) { @@ -141,7 +140,7 @@ func TestCounters(t *testing.T) { t.Run("inhume_TS", func(t *testing.T) { var prm shard.InhumePrm - ts := objectcore.AddressOf(generateObject(t)) + ts := objectcore.AddressOf(generateObject()) phy := mm.objectCounters[physical] logic := mm.objectCounters[logical] diff --git a/pkg/local_object_storage/shard/range_test.go b/pkg/local_object_storage/shard/range_test.go index b5273765d2..407a997eea 100644 --- a/pkg/local_object_storage/shard/range_test.go +++ b/pkg/local_object_storage/shard/range_test.go @@ -82,7 +82,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - obj := generateObject(t) + obj := generateObject() addAttribute(obj, "foo", "bar") addPayload(obj, tc.payloadSize) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index c971a73887..df0e5bc896 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -95,17 +95,17 @@ func releaseShard(s *shard.Shard, t testing.TB) { require.NoError(t, s.Close()) } -func generateObject(t *testing.T) *object.Object { - return generateObjectWithCID(t, cidtest.ID()) +func generateObject() *object.Object { + return generateObjectWithCID(cidtest.ID()) } -func generateObjectWithCID(t *testing.T, cnr cid.ID) *object.Object { +func generateObjectWithCID(cnr cid.ID) *object.Object { data := make([]byte, 32) _, _ = rand.Read(data) - return generateObjectWithPayload(t, cnr, data) + return generateObjectWithPayload(cnr, data) } -func generateObjectWithPayload(t testing.TB, cnr cid.ID, data []byte) *object.Object { +func generateObjectWithPayload(cnr cid.ID, data []byte) *object.Object { var ver version.Version ver.SetMajor(2) ver.SetMinor(1) diff --git a/pkg/local_object_storage/shard/shutdown_test.go b/pkg/local_object_storage/shard/shutdown_test.go index ec473b9e03..de08b84161 100644 --- a/pkg/local_object_storage/shard/shutdown_test.go +++ b/pkg/local_object_storage/shard/shutdown_test.go @@ -20,14 +20,11 @@ func TestWriteCacheObjectLoss(t *testing.T) { objects := make([]*objectSDK.Object, objCount) for i := range objects { - size := smallSize - // if i%2 == 0 { - size = smallSize / 2 - // } + size := smallSize / 2 data := make([]byte, size) _, _ = rand.Read(data) - objects[i] = generateObjectWithPayload(t, cidtest.ID(), data) + objects[i] = generateObjectWithPayload(cidtest.ID(), data) } dir := t.TempDir() diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index c623fd656d..0e5d80dc1e 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -54,12 +54,6 @@ type testClient struct { } } -type testEpochReceiver uint64 - -func (e testEpochReceiver) currentEpoch() (uint64, error) { - return uint64(e), nil -} - func newTestStorage() *testStorage { return &testStorage{ inhumed: make(map[string]struct{}), @@ -195,11 +189,6 @@ func (s *testStorage) inhume(addr oid.Address) { s.inhumed[addr.EncodeToString()] = struct{}{} } -const ( - splitV1 = iota - splitV2 -) - func generateObject(addr oid.Address, prev *oid.ID, payload []byte, children ...oid.ID) *objectSDK.Object { obj := objectSDK.New() obj.SetContainerID(addr.Container()) diff --git a/pkg/services/object/tombstone/verify_test.go b/pkg/services/object/tombstone/verify_test.go index 0b37657421..53327f4de7 100644 --- a/pkg/services/object/tombstone/verify_test.go +++ b/pkg/services/object/tombstone/verify_test.go @@ -82,9 +82,9 @@ func TestVerifier_VerifyTomb(t *testing.T) { cnr := cidtest.ID() children := []object.Object{ - objectWithCnr(t, cnr, false), - objectWithCnr(t, cnr, false), - objectWithCnr(t, cnr, false), + objectWithCnr(cnr, false), + objectWithCnr(cnr, false), + objectWithCnr(cnr, false), } *os = testObjectSource{ @@ -100,7 +100,7 @@ func TestVerifier_VerifyTomb(t *testing.T) { var tomb object.Tombstone cnr := cidtest.ID() - child := objectWithCnr(t, cnr, true) + child := objectWithCnr(cnr, true) childID, _ := child.ID() splitID := child.SplitID() @@ -124,7 +124,7 @@ func TestVerifier_VerifyTomb(t *testing.T) { }) t.Run("LINKs can be found", func(t *testing.T) { - link := objectWithCnr(t, cnr, false) + link := objectWithCnr(cnr, false) link.SetChildren(childID) linkID, _ := link.ID() @@ -255,7 +255,7 @@ func objectsToOIDs(oo []object.Object) []oid.ID { return res } -func objectWithCnr(t *testing.T, cnr cid.ID, hasParent bool) object.Object { +func objectWithCnr(cnr cid.ID, hasParent bool) object.Object { obj := objecttest.Object() obj.SetContainerID(cnr) diff --git a/pkg/services/object_manager/placement/traverser_test.go b/pkg/services/object_manager/placement/traverser_test.go index 1574c042c2..2aeb9f85d0 100644 --- a/pkg/services/object_manager/placement/traverser_test.go +++ b/pkg/services/object_manager/placement/traverser_test.go @@ -40,7 +40,7 @@ func copyVectors(v [][]netmap.NodeInfo) [][]netmap.NodeInfo { return vc } -func testPlacement(t *testing.T, ss, rs []int) ([][]netmap.NodeInfo, container.Container) { +func testPlacement(ss, rs []int) ([][]netmap.NodeInfo, container.Container) { nodes := make([][]netmap.NodeInfo, 0, len(rs)) replicas := make([]netmap.ReplicaDescriptor, 0, len(rs)) num := uint32(0) @@ -83,7 +83,7 @@ func TestTraverserObjectScenarios(t *testing.T) { selectors := []int{2, 3} replicas := []int{1, 2} - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) @@ -112,7 +112,7 @@ func TestTraverserObjectScenarios(t *testing.T) { selectors := []int{5, 3} replicas := []int{2, 2} - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) @@ -141,7 +141,7 @@ func TestTraverserObjectScenarios(t *testing.T) { selectors := []int{5, 3} replicas := []int{2, 2} - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) @@ -184,7 +184,7 @@ func TestTraverserObjectScenarios(t *testing.T) { selectors := []int{2, 3} replicas := []int{1, 2} - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) tr, err := NewTraverser( ForContainer(cnr), @@ -214,7 +214,7 @@ func TestCopiesNumber(t *testing.T) { selectors := []int{1, 2, 3} // 3 vectors with 1, 2, 3 lengths replicas := []int{0, 2, 3} // REP 0 ... REP 2 ... REP 3 - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) tr, err := NewTraverser( @@ -241,7 +241,7 @@ func TestCopiesNumber(t *testing.T) { selectors := []int{1, 1, 1} // 3 vectors with 1, 1, 1 lengths replicas := []int{1, 1, 1} // REP 1 ... REP 1 ... REP 1 - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) tr, err := NewTraverser( @@ -265,7 +265,7 @@ func TestCopiesNumber(t *testing.T) { selectors := []int{10, 10, 10} // 3 vectors with 10, 10, 10 lengths replicas := []int{1, 2, 3} // REP 1 ... REP 2 ... REP 3 - nodes, cnr := testPlacement(t, selectors, replicas) + nodes, cnr := testPlacement(selectors, replicas) nodesCopy := copyVectors(nodes) tr, err := NewTraverser(