forked from TrueCloudLab/frostfs-node
[#116] node: Improve shard/engine construction in tests
* Introduce testEngineWrapper that can be constructed with different options Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
parent
d6486d172e
commit
6f7b6a8813
10 changed files with 173 additions and 144 deletions
|
@ -192,7 +192,8 @@ func testEngineFailInitAndReload(t *testing.T, errOnAdd bool, opts []shard.Optio
|
|||
}
|
||||
|
||||
func TestExecBlocks(t *testing.T) {
|
||||
e := testNewEngineWithShardNum(t, 2) // 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())
|
||||
})
|
||||
|
@ -314,25 +315,26 @@ func TestReload(t *testing.T) {
|
|||
|
||||
// engineWithShards creates engine with specified number of shards. Returns
|
||||
// slice of paths to their metabase and the engine.
|
||||
// TODO: #1776 unify engine construction in tests
|
||||
func engineWithShards(t *testing.T, path string, num int) (*StorageEngine, []string) {
|
||||
addPath := filepath.Join(path, "add")
|
||||
|
||||
currShards := make([]string, 0, num)
|
||||
|
||||
e := New()
|
||||
for i := 0; i < num; i++ {
|
||||
id, err := e.AddShard(
|
||||
shard.WithBlobStorOptions(
|
||||
blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(i)), errSmallSize))),
|
||||
shard.WithMetaBaseOptions(
|
||||
meta.WithPath(filepath.Join(addPath, fmt.Sprintf("%d.metabase", i))),
|
||||
meta.WithPermissions(0700),
|
||||
meta.WithEpochState(epochState{}),
|
||||
),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
te := testNewEngine(t).
|
||||
setShardsNumAdditionalOpts(t, num, func(id int) []shard.Option {
|
||||
return []shard.Option{
|
||||
shard.WithBlobStorOptions(
|
||||
blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(id)), errSmallSize))),
|
||||
shard.WithMetaBaseOptions(
|
||||
meta.WithPath(filepath.Join(addPath, fmt.Sprintf("%d.metabase", id))),
|
||||
meta.WithPermissions(0700),
|
||||
meta.WithEpochState(epochState{}),
|
||||
),
|
||||
}
|
||||
})
|
||||
e, ids := te.engine, te.shardIDs
|
||||
|
||||
for _, id := range ids {
|
||||
currShards = append(currShards, calculateShardID(e.shards[id.String()].DumpInfo()))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue