@@ -507,23 +507,16 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
507
507
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
508
508
func (rc * ResourceConsumer ) EnsureDesiredReplicasInRange (ctx context.Context , minDesiredReplicas , maxDesiredReplicas int , duration time.Duration , hpaName string ) {
509
509
interval := 10 * time .Second
510
- gomega .Consistently (ctx , framework .HandleRetry (func (ctx context.Context ) (bool , error ) {
511
- replicas := rc .GetReplicas (ctx )
512
- framework .Logf ("expecting there to be in [%d, %d] replicas (are: %d)" , minDesiredReplicas , maxDesiredReplicas , replicas )
513
- as , err := rc .GetHpa (ctx , hpaName )
514
- if err != nil {
515
- framework .Logf ("Error getting HPA: %s" , err )
516
- } else {
517
- framework .Logf ("HPA status: %+v" , as .Status )
518
- }
519
- if replicas < minDesiredReplicas {
520
- return false , fmt .Errorf ("number of replicas below target" )
521
- } else if replicas > maxDesiredReplicas {
522
- return false , fmt .Errorf ("number of replicas above target" )
523
- } else {
524
- return true , nil // Expected number of replicas found. Continue polling until timeout.
525
- }
526
- })).WithTimeout (duration ).WithPolling (interval ).Should (gomega .BeTrue ())
510
+ framework .Gomega ().Consistently (ctx , func (ctx context.Context ) int {
511
+ return rc .GetReplicas (ctx )
512
+ }).WithTimeout (duration ).WithPolling (interval ).Should (gomega .And (gomega .BeNumerically (">=" , minDesiredReplicas ), gomega .BeNumerically ("<=" , maxDesiredReplicas )))
513
+
514
+ as , err := rc .GetHpa (ctx , hpaName )
515
+ if err != nil {
516
+ framework .Logf ("Error getting HPA: %s" , err )
517
+ } else {
518
+ framework .Logf ("HPA status: %+v" , as .Status )
519
+ }
527
520
}
528
521
529
522
// Pause stops background goroutines responsible for consuming resources.
0 commit comments