[#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
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
|
@ -15,8 +12,6 @@ import (
|
|||
func TestGeneric(t *testing.T) {
|
||||
const maxObjectSize = 1 << 16
|
||||
|
||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||
|
||||
helper := func(t *testing.T, dir string) common.Storage {
|
||||
return NewBlobovniczaTree(
|
||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||
|
@ -27,16 +22,14 @@ func TestGeneric(t *testing.T) {
|
|||
WithBlobovniczaSize(1<<20))
|
||||
}
|
||||
|
||||
var n int
|
||||
newTree := func(t *testing.T) common.Storage {
|
||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
||||
return helper(t, dir)
|
||||
return helper(t, t.TempDir())
|
||||
}
|
||||
|
||||
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
|
||||
|
||||
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 {
|
||||
return helper(t, dir)
|
||||
}, Type, dir)
|
||||
|
@ -46,17 +39,13 @@ func TestGeneric(t *testing.T) {
|
|||
func TestControl(t *testing.T) {
|
||||
const maxObjectSize = 2048
|
||||
|
||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||
|
||||
var n int
|
||||
newTree := func(t *testing.T) common.Storage {
|
||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
||||
return NewBlobovniczaTree(
|
||||
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
||||
WithObjectSizeLimit(maxObjectSize),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
WithRootPath(dir),
|
||||
WithRootPath(t.TempDir()),
|
||||
WithBlobovniczaSize(1<<20))
|
||||
}
|
||||
|
||||
|
|
|
@ -44,18 +44,12 @@ func TestInitializationFailure(t *testing.T) {
|
|||
sid, err := generateShardID()
|
||||
require.NoError(t, err)
|
||||
|
||||
tempDir := t.TempDir()
|
||||
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)
|
||||
storages, smallFileStorage, largeFileStorage := newTestStorages(t.TempDir(), 1<<20)
|
||||
|
||||
wcOpts := writecacheconfig.Options{
|
||||
Type: writecacheconfig.TypeBBolt,
|
||||
BBoltOptions: []writecachebbolt.Option{
|
||||
writecachebbolt.WithPath(writecachePath),
|
||||
writecachebbolt.WithPath(t.TempDir()),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -69,13 +63,13 @@ func TestInitializationFailure(t *testing.T) {
|
|||
Timeout: 100 * time.Millisecond,
|
||||
OpenFile: opts.openFileMetabase,
|
||||
}),
|
||||
meta.WithPath(metabasePath),
|
||||
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||
meta.WithPermissions(0700),
|
||||
meta.WithEpochState(epochState{})),
|
||||
shard.WithWriteCache(true),
|
||||
shard.WithWriteCacheOptions(wcOpts),
|
||||
shard.WithPiloramaOptions(
|
||||
pilorama.WithPath(piloramaPath),
|
||||
pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama")),
|
||||
pilorama.WithOpenFile(opts.openFilePilorama),
|
||||
),
|
||||
}, smallFileStorage, largeFileStorage
|
||||
|
@ -178,10 +172,6 @@ func testEngineFailInitAndReload(t *testing.T, errOnAdd bool, opts []shard.Optio
|
|||
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
|
||||
|
||||
t.Cleanup(func() {
|
||||
os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
// put some object
|
||||
obj := testutil.GenerateObjectWithCID(cidtest.ID())
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -20,8 +19,6 @@ import (
|
|||
func TestDeleteBigObject(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
defer os.RemoveAll(t.Name())
|
||||
|
||||
cnr := cidtest.ID()
|
||||
parentID := oidtest.ID()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync/atomic"
|
||||
|
@ -204,11 +203,10 @@ func testDefaultShardOptions(t testing.TB, id int) []shard.Option {
|
|||
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
||||
shard.WithBlobStorOptions(
|
||||
blobstor.WithStorages(
|
||||
newStorages(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", id)),
|
||||
1<<20))),
|
||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.pilorama", id)))),
|
||||
newStorages(t.TempDir(), 1<<20))),
|
||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
|
||||
shard.WithMetaBaseOptions(
|
||||
meta.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.metabase", id))),
|
||||
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||
meta.WithPermissions(0700),
|
||||
meta.WithEpochState(epochState{}),
|
||||
)}
|
||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
|
@ -14,8 +13,6 @@ import (
|
|||
)
|
||||
|
||||
func TestHeadRaw(t *testing.T) {
|
||||
defer os.RemoveAll(t.Name())
|
||||
|
||||
cnr := cidtest.ID()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -14,8 +13,6 @@ import (
|
|||
)
|
||||
|
||||
func TestStorageEngine_Inhume(t *testing.T) {
|
||||
defer os.RemoveAll(t.Name())
|
||||
|
||||
cnr := cidtest.ID()
|
||||
splitID := objectSDK.NewSplitID()
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
|
@ -71,11 +69,10 @@ func TestListWithCursor(t *testing.T) {
|
|||
shard.WithLogger(&logger.Logger{Logger: zap.L()}),
|
||||
shard.WithBlobStorOptions(
|
||||
blobstor.WithStorages(
|
||||
newStorages(filepath.Join(t.Name(), tt.name, fmt.Sprintf("%d.blobstor", id)),
|
||||
1<<20))),
|
||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.Name(), tt.name, fmt.Sprintf("%d.pilorama", id)))),
|
||||
newStorages(t.TempDir(), 1<<20))),
|
||||
shard.WithPiloramaOptions(pilorama.WithPath(filepath.Join(t.TempDir(), "pilorama"))),
|
||||
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.WithEpochState(epochState{}),
|
||||
)}
|
||||
|
@ -85,7 +82,6 @@ func TestListWithCursor(t *testing.T) {
|
|||
|
||||
t.Cleanup(func() {
|
||||
e.Close()
|
||||
os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
expected := make([]object.AddressWithType, 0, tt.objectNum)
|
||||
|
|
|
@ -2,7 +2,6 @@ package engine
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -65,7 +64,6 @@ func TestLockUserScenario(t *testing.T) {
|
|||
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
_ = os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
lockerID := oidtest.ID()
|
||||
|
@ -174,7 +172,6 @@ func TestLockExpiration(t *testing.T) {
|
|||
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
_ = os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
const lockerExpiresAfter = 13
|
||||
|
@ -254,7 +251,6 @@ func TestLockForceRemoval(t *testing.T) {
|
|||
require.NoError(t, e.Init(context.Background()))
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
_ = os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
cnr := cidtest.ID()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package engine
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -14,7 +13,6 @@ func TestRemoveShard(t *testing.T) {
|
|||
e, ids := te.engine, te.shardIDs
|
||||
t.Cleanup(func() {
|
||||
e.Close()
|
||||
os.RemoveAll(t.Name())
|
||||
})
|
||||
|
||||
require.Equal(t, numOfShards, len(e.shardPools))
|
||||
|
|
|
@ -2,7 +2,6 @@ package meta_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -18,9 +17,6 @@ const objCount = 10
|
|||
|
||||
func TestCounters(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, os.RemoveAll(t.Name()))
|
||||
})
|
||||
|
||||
t.Run("defaults", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
|
|
@ -2,6 +2,7 @@ package meta_test
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"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 {
|
||||
path := t.Name()
|
||||
|
||||
bdb := meta.New(
|
||||
append([]meta.Option{
|
||||
meta.WithPath(path),
|
||||
meta.WithPath(filepath.Join(t.TempDir(), "metabase")),
|
||||
meta.WithPermissions(0600),
|
||||
meta.WithEpochState(epochState{}),
|
||||
}, opts...)...,
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
||||
|
@ -12,15 +10,10 @@ import (
|
|||
func TestGeneric(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||
|
||||
var n int
|
||||
newMetabase := func(t *testing.T) storagetest.Component {
|
||||
n++
|
||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
||||
return New(
|
||||
WithEpochState(epochStateImpl{}),
|
||||
WithPath(dir))
|
||||
WithPath(filepath.Join(t.TempDir(), "metabase")))
|
||||
}
|
||||
|
||||
storagetest.TestAll(t, newMetabase)
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package pilorama
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/storagetest"
|
||||
)
|
||||
|
||||
func TestGeneric(t *testing.T) {
|
||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||
|
||||
var n int
|
||||
newPilorama := func(t *testing.T) storagetest.Component {
|
||||
n++
|
||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
||||
return NewBoltForest(
|
||||
WithPath(dir))
|
||||
return NewBoltForest(WithPath(filepath.Join(t.TempDir(), "pilorama")))
|
||||
}
|
||||
|
||||
storagetest.TestAll(t, newPilorama)
|
||||
|
|
Loading…
Reference in a new issue