From 2310a5c7ba5577ac61837418a2de94ea20fc4c7a Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 6 Jul 2023 18:29:16 +0300 Subject: [PATCH] [#498] policer: Allow to set sleep duration between iterations Speed up tests on CI. Signed-off-by: Evgenii Stratonikov --- pkg/services/policer/option.go | 3 ++- pkg/services/policer/policer_test.go | 4 ++++ pkg/services/policer/process.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/services/policer/option.go b/pkg/services/policer/option.go index e182c6be7..4194353ca 100644 --- a/pkg/services/policer/option.go +++ b/pkg/services/policer/option.go @@ -76,7 +76,7 @@ type cfg struct { batchSize, cacheSize uint32 - rebalanceFreq, evictDuration time.Duration + rebalanceFreq, evictDuration, sleepDuration time.Duration } func defaultCfg() *cfg { @@ -85,6 +85,7 @@ func defaultCfg() *cfg { batchSize: 10, cacheSize: 1024, // 1024 * address size = 1024 * 64 = 64 MiB rebalanceFreq: 1 * time.Second, + sleepDuration: 1 * time.Second, evictDuration: 30 * time.Second, } } diff --git a/pkg/services/policer/policer_test.go b/pkg/services/policer/policer_test.go index ad82d2477..664e7d105 100644 --- a/pkg/services/policer/policer_test.go +++ b/pkg/services/policer/policer_test.go @@ -6,6 +6,7 @@ import ( "errors" "sort" "testing" + "time" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container" objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" @@ -279,6 +280,9 @@ func TestIteratorContract(t *testing.T) { WithBuryFunc(buryFn), WithPool(pool), WithNodeLoader(constNodeLoader(0)), + func(c *cfg) { + c.sleepDuration = time.Millisecond + }, ) ctx, cancel := context.WithCancel(context.Background()) diff --git a/pkg/services/policer/process.go b/pkg/services/policer/process.go index cdc92ed12..3b54bf929 100644 --- a/pkg/services/policer/process.go +++ b/pkg/services/policer/process.go @@ -28,7 +28,7 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { if err != nil { if errors.Is(err, engine.ErrEndOfListing) { p.keySpaceIterator.Rewind() - time.Sleep(time.Second) // finished whole cycle, sleep a bit + time.Sleep(p.sleepDuration) // finished whole cycle, sleep a bit continue } p.log.Warn(logs.PolicerFailureAtObjectSelectForReplication, zap.Error(err))