[#674] storage engine: Fix unit test failed on shard pool NPE

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-10-08 16:26:24 +03:00 committed by Alex Vanin
parent 2126235f0e
commit 43ccab3294

View file

@ -16,8 +16,10 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/test" "github.com/nspcc-dev/neofs-node/pkg/util/test"
"github.com/nspcc-dev/tzhash/tz" "github.com/nspcc-dev/tzhash/tz"
"github.com/panjf2000/ants/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -27,12 +29,19 @@ func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine {
cfg: &cfg{ cfg: &cfg{
log: zap.L(), log: zap.L(),
}, },
mtx: new(sync.RWMutex), mtx: new(sync.RWMutex),
shards: make(map[string]*shard.Shard, len(shards)), shards: make(map[string]*shard.Shard, len(shards)),
shardPools: make(map[string]util.WorkerPool, len(shards)),
} }
for _, s := range shards { for _, s := range shards {
pool, err := ants.NewPool(10, ants.WithNonblocking(true))
if err != nil {
panic(err)
}
engine.shards[s.ID().String()] = s engine.shards[s.ID().String()] = s
engine.shardPools[s.ID().String()] = pool
} }
return engine return engine