[#116] node: Improve shard/engine construction in tests
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
* 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
|
@ -45,15 +45,21 @@ func TestLockUserScenario(t *testing.T) {
|
|||
tombForLockID := oidtest.ID()
|
||||
tombObj.SetID(tombForLockID)
|
||||
|
||||
e := testEngineFromShardOpts(t, 2, []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
testEngine := testNewEngine(t).
|
||||
setShardsNumAdditionalOpts(t, 2, func(id int) []shard.Option {
|
||||
return []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
|
||||
return pool
|
||||
}),
|
||||
shard.WithTombstoneSource(tss{lockerExpiresAfter}),
|
||||
})
|
||||
return pool
|
||||
}),
|
||||
shard.WithTombstoneSource(tss{lockerExpiresAfter}),
|
||||
}
|
||||
})
|
||||
e := testEngine.engine
|
||||
require.NoError(t, e.Open())
|
||||
require.NoError(t, e.Init(context.Background()))
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
|
@ -146,14 +152,20 @@ func TestLockExpiration(t *testing.T) {
|
|||
// 3. lock expiration epoch is coming
|
||||
// 4. after some delay the object is not locked anymore
|
||||
|
||||
e := testEngineFromShardOpts(t, 2, []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
testEngine := testNewEngine(t).
|
||||
setShardsNumAdditionalOpts(t, 2, func(id int) []shard.Option {
|
||||
return []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
|
||||
return pool
|
||||
}),
|
||||
})
|
||||
return pool
|
||||
}),
|
||||
}
|
||||
})
|
||||
e := testEngine.engine
|
||||
require.NoError(t, e.Open())
|
||||
require.NoError(t, e.Init(context.Background()))
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
|
@ -218,16 +230,20 @@ func TestLockForceRemoval(t *testing.T) {
|
|||
// 5. the object is not locked anymore
|
||||
var e *StorageEngine
|
||||
|
||||
e = testEngineFromShardOpts(t, 2, []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
|
||||
return pool
|
||||
}),
|
||||
shard.WithDeletedLockCallback(e.processDeletedLocks),
|
||||
})
|
||||
e = testNewEngine(t).
|
||||
setShardsNumAdditionalOpts(t, 2, func(id int) []shard.Option {
|
||||
return []shard.Option{
|
||||
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
|
||||
pool, err := ants.NewPool(sz)
|
||||
require.NoError(t, err)
|
||||
|
||||
return pool
|
||||
}),
|
||||
shard.WithDeletedLockCallback(e.processDeletedLocks),
|
||||
}
|
||||
}).engine
|
||||
require.NoError(t, e.Open())
|
||||
require.NoError(t, e.Init(context.Background()))
|
||||
t.Cleanup(func() {
|
||||
_ = e.Close()
|
||||
_ = os.RemoveAll(t.Name())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue