Skip to content

Commit

Permalink
use cycle period as manager timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
orouz committed Apr 7, 2024
1 parent a67d308 commit 7625e87
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/flavors/benchmark/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package inventory

import (
"context"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -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)
}

0 comments on commit 7625e87

Please sign in to comment.