Skip to content

Commit 49e8c19

Browse files
committed
use framework gomega
Signed-off-by: James Sturtevant <[email protected]>
1 parent 4b1b9a1 commit 49e8c19

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

test/e2e/framework/autoscaling/autoscaling_utils.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -507,23 +507,16 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
507507
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
508508
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
509509
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+
}
527520
}
528521

529522
// Pause stops background goroutines responsible for consuming resources.

0 commit comments

Comments
 (0)