From 85e60a842fedeec1e10b69cee1670b826e046be4 Mon Sep 17 00:00:00 2001 From: Or Ouziel Date: Tue, 2 Apr 2024 17:35:01 +0300 Subject: [PATCH] use cycle period as manager timeout --- internal/flavors/benchmark/gcp.go | 1 + .../resources/providers/gcplib/inventory/grpc_rate_limiter.go | 2 +- .../providers/gcplib/inventory/grpc_rate_limiter_test.go | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/flavors/benchmark/gcp.go b/internal/flavors/benchmark/gcp.go index ec2e0f36c3..78b3ccc07d 100644 --- a/internal/flavors/benchmark/gcp.go +++ b/internal/flavors/benchmark/gcp.go @@ -49,6 +49,7 @@ func (g *GCP) NewBenchmark(ctx context.Context, log *logp.Logger, cfg *config.Co return builder.New( builder.WithBenchmarkDataProvider(bdp), + builder.WithManagerTimeout(cfg.Period), ).Build(ctx, log, cfg, resourceCh, reg) } diff --git a/internal/resources/providers/gcplib/inventory/grpc_rate_limiter.go b/internal/resources/providers/gcplib/inventory/grpc_rate_limiter.go index 1ec9f48753..e37be631bb 100644 --- a/internal/resources/providers/gcplib/inventory/grpc_rate_limiter.go +++ b/internal/resources/providers/gcplib/inventory/grpc_rate_limiter.go @@ -62,7 +62,7 @@ func (rl *AssetsInventoryRateLimiter) Wait(ctx context.Context, method string, r if limiter != nil { err := limiter.Wait(ctx) if err != nil { - rl.log.Errorf("Failed to wait for project quota on method: %s, request: %v, error: %w", method, req, err) + rl.log.Errorf("Failed to wait for project quota on method: %s, request: %v, error: %v", method, req, err) } } } diff --git a/internal/resources/providers/gcplib/inventory/grpc_rate_limiter_test.go b/internal/resources/providers/gcplib/inventory/grpc_rate_limiter_test.go index b1cb58df78..2130b69264 100644 --- a/internal/resources/providers/gcplib/inventory/grpc_rate_limiter_test.go +++ b/internal/resources/providers/gcplib/inventory/grpc_rate_limiter_test.go @@ -19,7 +19,6 @@ package inventory import ( "context" - "fmt" "testing" "time" @@ -54,11 +53,10 @@ func (s *RateLimiterTestSuite) TestRateLimiterWait() { startTime := time.Now() for i := 0; i < totalRequests; i++ { s.rateLimiter.Wait(ctx, "someMethod", nil) - fmt.Println("request", i) } endTime := time.Now() actualDuration := endTime.Sub(startTime) minDuration := duration * time.Duration((totalRequests - 1)) // 1st request is instant, 2nd and above wait 1duration each - s.Assert().True(actualDuration >= minDuration, fmt.Sprintf("expected %v to be greater or equal than %v", actualDuration, minDuration)) + s.GreaterOrEqual(actualDuration, minDuration) }