[#xx] Avoid manual management of files in tests
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 2m36s
Build / Build Components (1.21) (pull_request) Successful in 3m33s
DCO action / DCO (pull_request) Successful in 3m33s
Tests and linters / Staticcheck (pull_request) Successful in 4m15s
Tests and linters / Lint (pull_request) Successful in 5m31s
Build / Build Components (1.20) (pull_request) Successful in 7m2s
Tests and linters / Tests with -race (pull_request) Failing after 8m51s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m55s
Tests and linters / Tests (1.21) (pull_request) Successful in 10m6s
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 2m36s
Build / Build Components (1.21) (pull_request) Successful in 3m33s
DCO action / DCO (pull_request) Successful in 3m33s
Tests and linters / Staticcheck (pull_request) Successful in 4m15s
Tests and linters / Lint (pull_request) Successful in 5m31s
Build / Build Components (1.20) (pull_request) Successful in 7m2s
Tests and linters / Tests with -race (pull_request) Failing after 8m51s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m55s
Tests and linters / Tests (1.21) (pull_request) Successful in 10m6s
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
376f03a445
commit
ae8be495c8
13 changed files with 17 additions and 79 deletions
|
@ -1,9 +1,6 @@
|
||||||
package blobovniczatree
|
package blobovniczatree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
|
@ -15,8 +12,6 @@ import (
|
||||||
func TestGeneric(t *testing.T) {
|
func TestGeneric(t *testing.T) {
|
||||||
const maxObjectSize = 1 << 16
|
const maxObjectSize = 1 << 16
|
||||||
|
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
||||||
|
|
||||||
helper := func(t *testing.T, dir string) common.Storage {
|
helper := func(t *testing.T, dir string) common.Storage {
|
||||||
return NewBlobovniczaTree(
|
return NewBlobovniczaTree(
|
||||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||||
|
@ -27,16 +22,14 @@ func TestGeneric(t *testing.T) {
|
||||||
WithBlobovniczaSize(1<<20))
|
WithBlobovniczaSize(1<<20))
|
||||||
}
|
}
|
||||||
|
|
||||||
var n int
|
|
||||||
newTree := func(t *testing.T) common.Storage {
|
newTree := func(t *testing.T) common.Storage {
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
return helper(t, t.TempDir())
|
||||||
return helper(t, dir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
|
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
|
||||||
|
|
||||||
t.Run("info", func(t *testing.T) {
|
t.Run("info", func(t *testing.T) {
|
||||||
dir := filepath.Join(t.Name(), "info")
|
dir := t.TempDir()
|
||||||
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
|
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
|
||||||
return helper(t, dir)
|
return helper(t, dir)
|
||||||
}, Type, dir)
|
}, Type, dir)
|
||||||
|
@ -46,17 +39,13 @@ func TestGeneric(t *testing.T) {
|
||||||
func TestControl(t *testing.T) {
|
func TestControl(t *testing.T) {
|
||||||
const maxObjectSize = 2048
|
const maxObjectSize = 2048
|
||||||
|
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
||||||
|
|
||||||
var n int
|
|
||||||
newTree := func(t *testing.T) common.Storage {
|
newTree := func(t *testing.T) common.Storage {
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
||||||
return NewBlobovniczaTree(
|
return NewBlobovniczaTree(
|
||||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||||
WithObjectSizeLimit(maxObjectSize),
|
WithObjectSizeLimit(maxObjectSize),
|
||||||
WithBlobovniczaShallowWidth(2),
|
WithBlobovniczaShallowWidth(2),
|
||||||
WithBlobovniczaShallowDepth(2),
|
WithBlobovniczaShallowDepth(2),
|
||||||
WithRootPath(dir),
|
WithRootPath(t.TempDir()),
|
||||||
WithBlobovniczaSize(1<<20))
|
WithBlobovniczaSize(1<<20))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,18 +44,12 @@ func TestInitializationFailure(t *testing.T) {
|
||||||
sid, err := generateShardID()
|
sid, err := generateShardID()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
tempDir := t.TempDir()
|
storages, smallFileStorage, largeFileStorage := newTestStorages(t.TempDir(), 1<<20)
|
||||||
blobstorPath := filepath.Join(tempDir, "bs")
|
|
||||||
metabasePath := filepath.Join(tempDir, "mb")
|
|
||||||
writecachePath := filepath.Join(tempDir, "wc")
|
|
||||||
piloramaPath := filepath.Join(tempDir, "pl")
|
|
||||||
|
|
||||||
storages, smallFileStorage, largeFileStorage := newTestStorages(blobstorPath, 1<<20)
|
|
||||||
|
|
||||||
wcOpts := writecacheconfig.Options{
|
wcOpts := writecacheconfig.Options{
|
||||||
Type: writecacheconfig.TypeBBolt,
|
Type: writecacheconfig.TypeBBolt,
|
||||||
BBoltOptions: []writecachebbolt.Option{
|
BBoltOptions: []writecachebbolt.Option{
|
||||||
writecachebbolt.WithPath(writecachePath),
|
writecachebbolt.WithPath(t.TempDir()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,13 +63,13 @@ func TestInitializationFailure(t *testing.T) {
|
||||||
Timeout: 100 * time.Millisecond,
|
Timeout: 100 * time.Millisecond,
|
||||||
OpenFile: opts.openFileMetabase,
|
OpenFile: opts.openFileMetabase,
|
||||||
}),
|
}),
|
||||||
meta.WithPath(metabasePath),
|
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||||
meta.WithPermissions(0700),
|
meta.WithPermissions(0700),
|
||||||
meta.WithEpochState(epochState{})),
|
meta.WithEpochState(epochState{})),
|
||||||
shard.WithWriteCache(true),
|
shard.WithWriteCache(true),
|
||||||
shard.WithWriteCacheOptions(wcOpts),
|
shard.WithWriteCacheOptions(wcOpts),
|
||||||
shard.WithPiloramaOptions(
|
shard.WithPiloramaOptions(
|
||||||
pilorama.WithPath(piloramaPath),
|
pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama")),
|
||||||
pilorama.WithOpenFile(opts.openFilePilorama),
|
pilorama.WithOpenFile(opts.openFilePilorama),
|
||||||
),
|
),
|
||||||
}, smallFileStorage, largeFileStorage
|
}, smallFileStorage, largeFileStorage
|
||||||
|
@ -178,10 +172,6 @@ func testEngineFailInitAndReload(t *testing.T, errOnAdd bool, opts []shard.Optio
|
||||||
func TestExecBlocks(t *testing.T) {
|
func TestExecBlocks(t *testing.T) {
|
||||||
e := testNewEngine(t).setShardsNum(t, 2).engine // number doesn't matter in this test, 2 is several but not many
|
e := testNewEngine(t).setShardsNum(t, 2).engine // number doesn't matter in this test, 2 is several but not many
|
||||||
|
|
||||||
t.Cleanup(func() {
|
|
||||||
os.RemoveAll(t.Name())
|
|
||||||
})
|
|
||||||
|
|
||||||
// put some object
|
// put some object
|
||||||
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
|
@ -20,8 +19,6 @@ import (
|
||||||
func TestDeleteBigObject(t *testing.T) {
|
func TestDeleteBigObject(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
defer os.RemoveAll(t.Name())
|
|
||||||
|
|
||||||
cnr := cidtest.ID()
|
cnr := cidtest.ID()
|
||||||
parentID := oidtest.ID()
|
parentID := oidtest.ID()
|
||||||
splitID := objectSDK.NewSplitID()
|
splitID := objectSDK.NewSplitID()
|
||||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -204,11 +203,10 @@ func testDefaultShardOptions(t testing.TB, id int) []shard.Option {
|
||||||
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
||||||
shard.WithBlobStorOptions(
|
shard.WithBlobStorOptions(
|
||||||
blobstor.WithStorages(
|
blobstor.WithStorages(
|
||||||
newStorages(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", id)),
|
newStorages(t.TempDir(), 1<<20))),
|
||||||
1<<20))),
|
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
|
||||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.pilorama", id)))),
|
|
||||||
shard.WithMetaBaseOptions(
|
shard.WithMetaBaseOptions(
|
||||||
meta.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.metabase", id))),
|
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||||
meta.WithPermissions(0700),
|
meta.WithPermissions(0700),
|
||||||
meta.WithEpochState(epochState{}),
|
meta.WithEpochState(epochState{}),
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
|
@ -14,8 +13,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHeadRaw(t *testing.T) {
|
func TestHeadRaw(t *testing.T) {
|
||||||
defer os.RemoveAll(t.Name())
|
|
||||||
|
|
||||||
cnr := cidtest.ID()
|
cnr := cidtest.ID()
|
||||||
splitID := objectSDK.NewSplitID()
|
splitID := objectSDK.NewSplitID()
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
|
@ -14,8 +13,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStorageEngine_Inhume(t *testing.T) {
|
func TestStorageEngine_Inhume(t *testing.T) {
|
||||||
defer os.RemoveAll(t.Name())
|
|
||||||
|
|
||||||
cnr := cidtest.ID()
|
cnr := cidtest.ID()
|
||||||
splitID := objectSDK.NewSplitID()
|
splitID := objectSDK.NewSplitID()
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -71,11 +69,10 @@ func TestListWithCursor(t *testing.T) {
|
||||||
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
||||||
shard.WithBlobStorOptions(
|
shard.WithBlobStorOptions(
|
||||||
blobstor.WithStorages(
|
blobstor.WithStorages(
|
||||||
newStorages(filepath.Join(t.Name(), tt.name, fmt.Sprintf("%d.blobstor", id)),
|
newStorages(t.TempDir(), 1<<20))),
|
||||||
1<<20))),
|
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
|
||||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.Name(), tt.name, fmt.Sprintf("%d.pilorama", id)))),
|
|
||||||
shard.WithMetaBaseOptions(
|
shard.WithMetaBaseOptions(
|
||||||
meta.WithPath(filepath.Join(t.Name(), tt.name, fmt.Sprintf("%d.metabase", id))),
|
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||||
meta.WithPermissions(0700),
|
meta.WithPermissions(0700),
|
||||||
meta.WithEpochState(epochState{}),
|
meta.WithEpochState(epochState{}),
|
||||||
)}
|
)}
|
||||||
|
@ -85,7 +82,6 @@ func TestListWithCursor(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
e.Close()
|
e.Close()
|
||||||
os.RemoveAll(t.Name())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := make([]object.AddressWithType, 0, tt.objectNum)
|
expected := make([]object.AddressWithType, 0, tt.objectNum)
|
||||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -65,7 +64,6 @@ func TestLockUserScenario(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = e.Close()
|
_ = e.Close()
|
||||||
_ = os.RemoveAll(t.Name())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
lockerID := oidtest.ID()
|
lockerID := oidtest.ID()
|
||||||
|
@ -174,7 +172,6 @@ func TestLockExpiration(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = e.Close()
|
_ = e.Close()
|
||||||
_ = os.RemoveAll(t.Name())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const lockerExpiresAfter = 13
|
const lockerExpiresAfter = 13
|
||||||
|
@ -254,7 +251,6 @@ func TestLockForceRemoval(t *testing.T) {
|
||||||
require.NoError(t, e.Init(context.Background()))
|
require.NoError(t, e.Init(context.Background()))
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = e.Close()
|
_ = e.Close()
|
||||||
_ = os.RemoveAll(t.Name())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cnr := cidtest.ID()
|
cnr := cidtest.ID()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -14,7 +13,6 @@ func TestRemoveShard(t *testing.T) {
|
||||||
e, ids := te.engine, te.shardIDs
|
e, ids := te.engine, te.shardIDs
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
e.Close()
|
e.Close()
|
||||||
os.RemoveAll(t.Name())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
require.Equal(t, numOfShards, len(e.shardPools))
|
require.Equal(t, numOfShards, len(e.shardPools))
|
||||||
|
|
|
@ -2,7 +2,6 @@ package meta_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
|
@ -18,9 +17,6 @@ const objCount = 10
|
||||||
|
|
||||||
func TestCounters(t *testing.T) {
|
func TestCounters(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
t.Cleanup(func() {
|
|
||||||
require.NoError(t, os.RemoveAll(t.Name()))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("defaults", func(t *testing.T) {
|
t.Run("defaults", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
|
@ -2,6 +2,7 @@ package meta_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -40,11 +41,9 @@ func testSelect(t *testing.T, db *meta.DB, cnr cid.ID, fs objectSDK.SearchFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDB(t testing.TB, opts ...meta.Option) *meta.DB {
|
func newDB(t testing.TB, opts ...meta.Option) *meta.DB {
|
||||||
path := t.Name()
|
|
||||||
|
|
||||||
bdb := meta.New(
|
bdb := meta.New(
|
||||||
append([]meta.Option{
|
append([]meta.Option{
|
||||||
meta.WithPath(path),
|
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||||
meta.WithPermissions(0600),
|
meta.WithPermissions(0600),
|
||||||
meta.WithEpochState(epochState{}),
|
meta.WithEpochState(epochState{}),
|
||||||
}, opts...)...,
|
}, opts...)...,
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package meta
|
package meta
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
||||||
|
@ -12,15 +10,10 @@ import (
|
||||||
func TestGeneric(t *testing.T) {
|
func TestGeneric(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
||||||
|
|
||||||
var n int
|
|
||||||
newMetabase := func(t *testing.T) storagetest.Component {
|
newMetabase := func(t *testing.T) storagetest.Component {
|
||||||
n++
|
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
||||||
return New(
|
return New(
|
||||||
WithEpochState(epochStateImpl{}),
|
WithEpochState(epochStateImpl{}),
|
||||||
WithPath(dir))
|
WithPath(filepath.Join(t.TempDir(), "metabase")))
|
||||||
}
|
}
|
||||||
|
|
||||||
storagetest.TestAll(t, newMetabase)
|
storagetest.TestAll(t, newMetabase)
|
||||||
|
|
|
@ -1,23 +1,15 @@
|
||||||
package pilorama
|
package pilorama
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGeneric(t *testing.T) {
|
func TestGeneric(t *testing.T) {
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
||||||
|
|
||||||
var n int
|
|
||||||
newPilorama := func(t *testing.T) storagetest.Component {
|
newPilorama := func(t *testing.T) storagetest.Component {
|
||||||
n++
|
return NewBoltForest(WithPath(filepath.Join(t.TempDir(), "pilorama")))
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
||||||
return NewBoltForest(
|
|
||||||
WithPath(dir))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storagetest.TestAll(t, newPilorama)
|
storagetest.TestAll(t, newPilorama)
|
||||||
|
|
Loading…
Reference in a new issue