forked from TrueCloudLab/frostfs-node
[#668] shard/test: Use sane defaults in the test constructor
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
268adb79cb
commit
c661ba1312
3 changed files with 11 additions and 15 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
|
@ -26,10 +25,7 @@ func Test_GCDropsLockedExpiredSimpleObject(t *testing.T) {
|
|||
Value: 100,
|
||||
}
|
||||
|
||||
wcOpts := writecacheconfig.Options{
|
||||
Type: writecacheconfig.TypeBBolt,
|
||||
}
|
||||
sh := newCustomShard(t, false, shardOptions{rootPath: t.TempDir(), wcOpts: wcOpts, metaOptions: []meta.Option{meta.WithEpochState(epoch)}})
|
||||
sh := newCustomShard(t, false, shardOptions{metaOptions: []meta.Option{meta.WithEpochState(epoch)}})
|
||||
|
||||
t.Cleanup(func() {
|
||||
releaseShard(sh, t)
|
||||
|
@ -126,10 +122,7 @@ func Test_GCDropsLockedExpiredComplexObject(t *testing.T) {
|
|||
|
||||
linkID, _ := link.ID()
|
||||
|
||||
wcOpts := writecacheconfig.Options{
|
||||
Type: writecacheconfig.TypeBBolt,
|
||||
}
|
||||
sh := newCustomShard(t, false, shardOptions{rootPath: t.TempDir(), wcOpts: wcOpts, metaOptions: []meta.Option{meta.WithEpochState(epoch)}})
|
||||
sh := newCustomShard(t, false, shardOptions{metaOptions: []meta.Option{meta.WithEpochState(epoch)}})
|
||||
|
||||
t.Cleanup(func() {
|
||||
releaseShard(sh, t)
|
||||
|
|
|
@ -77,8 +77,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
|
|||
}
|
||||
|
||||
sh := newCustomShard(t, hasWriteCache, shardOptions{
|
||||
rootPath: t.TempDir(),
|
||||
wcOpts: wcOpts,
|
||||
wcOpts: wcOpts,
|
||||
bsOpts: []blobstor.Option{
|
||||
blobstor.WithStorages([]blobstor.SubStorage{
|
||||
{
|
||||
|
|
|
@ -38,15 +38,19 @@ type shardOptions struct {
|
|||
}
|
||||
|
||||
func newShard(t testing.TB, enableWriteCache bool) *Shard {
|
||||
sh := newCustomShard(t, enableWriteCache, shardOptions{
|
||||
rootPath: t.TempDir(),
|
||||
wcOpts: writecacheconfig.Options{Type: writecacheconfig.TypeBBolt},
|
||||
})
|
||||
sh := newCustomShard(t, enableWriteCache, shardOptions{})
|
||||
t.Cleanup(func() { releaseShard(sh, t) })
|
||||
return sh
|
||||
}
|
||||
|
||||
func newCustomShard(t testing.TB, enableWriteCache bool, o shardOptions) *Shard {
|
||||
if o.rootPath == "" {
|
||||
o.rootPath = t.TempDir()
|
||||
}
|
||||
if enableWriteCache && o.wcOpts.Type == 0 {
|
||||
o.wcOpts.Type = writecacheconfig.TypeBBolt
|
||||
}
|
||||
|
||||
var sh *Shard
|
||||
if enableWriteCache {
|
||||
o.rootPath = filepath.Join(o.rootPath, "wc")
|
||||
|
|
Loading…
Reference in a new issue