[#498] policer: Allow to set sleep duration between iterations

Speed up tests on CI.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
feature/refactor_sdk_api_types
Evgenii Stratonikov 2023-07-06 18:29:16 +03:00 committed by Evgenii Stratonikov
parent e858479a74
commit 2310a5c7ba
3 changed files with 7 additions and 2 deletions

View File

@ -76,7 +76,7 @@ type cfg struct {
batchSize, cacheSize uint32 batchSize, cacheSize uint32
rebalanceFreq, evictDuration time.Duration rebalanceFreq, evictDuration, sleepDuration time.Duration
} }
func defaultCfg() *cfg { func defaultCfg() *cfg {
@ -85,6 +85,7 @@ func defaultCfg() *cfg {
batchSize: 10, batchSize: 10,
cacheSize: 1024, // 1024 * address size = 1024 * 64 = 64 MiB cacheSize: 1024, // 1024 * address size = 1024 * 64 = 64 MiB
rebalanceFreq: 1 * time.Second, rebalanceFreq: 1 * time.Second,
sleepDuration: 1 * time.Second,
evictDuration: 30 * time.Second, evictDuration: 30 * time.Second,
} }
} }

View File

@ -6,6 +6,7 @@ import (
"errors" "errors"
"sort" "sort"
"testing" "testing"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
@ -279,6 +280,9 @@ func TestIteratorContract(t *testing.T) {
WithBuryFunc(buryFn), WithBuryFunc(buryFn),
WithPool(pool), WithPool(pool),
WithNodeLoader(constNodeLoader(0)), WithNodeLoader(constNodeLoader(0)),
func(c *cfg) {
c.sleepDuration = time.Millisecond
},
) )
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())

View File

@ -28,7 +28,7 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
if err != nil { if err != nil {
if errors.Is(err, engine.ErrEndOfListing) { if errors.Is(err, engine.ErrEndOfListing) {
p.keySpaceIterator.Rewind() p.keySpaceIterator.Rewind()
time.Sleep(time.Second) // finished whole cycle, sleep a bit time.Sleep(p.sleepDuration) // finished whole cycle, sleep a bit
continue continue
} }
p.log.Warn(logs.PolicerFailureAtObjectSelectForReplication, zap.Error(err)) p.log.Warn(logs.PolicerFailureAtObjectSelectForReplication, zap.Error(err))