[#1450] engine/test: Refactor (*testEngineWrapper).setInitializedShards

This function was a duplicate of the `(*StorageEngine).addShard`
but it didn't allow to set an engine's shard pool size what can
be very useful sometimes.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-11-02 12:43:19 +03:00
parent 7edec9193c
commit 251d17e36a
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639

View file

@ -3,7 +3,6 @@ package engine
import (
"context"
"path/filepath"
"sync/atomic"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
@ -19,8 +18,6 @@ import (
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
"git.frostfs.info/TrueCloudLab/hrw"
"github.com/panjf2000/ants/v2"
"github.com/stretchr/testify/require"
)
@ -90,17 +87,7 @@ func testNewEngine(t testing.TB, opts ...Option) *testEngineWrapper {
func (te *testEngineWrapper) setInitializedShards(t testing.TB, shards ...*shard.Shard) *testEngineWrapper {
for _, s := range shards {
pool, err := ants.NewPool(10, ants.WithNonblocking(true))
require.NoError(t, err)
te.engine.shards[s.ID().String()] = hashedShard{
shardWrapper: shardWrapper{
errorCount: new(atomic.Uint32),
Shard: s,
},
hash: hrw.StringHash(s.ID().String()),
}
te.engine.shardPools[s.ID().String()] = pool
require.NoError(t, te.engine.addShard(s))
te.shardIDs = append(te.shardIDs, s.ID())
}
return te