Skip to content

Commit

Permalink
use framework gomega
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <jstur@microsoft.com>
  • Loading branch information
jsturtevant committed Nov 14, 2023
1 parent 4b1b9a1 commit 49e8c19
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions test/e2e/framework/autoscaling/autoscaling_utils.go
Expand Up @@ -507,23 +507,16 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
interval := 10 * time.Second
gomega.Consistently(ctx, framework.HandleRetry(func(ctx context.Context) (bool, error) {
replicas := rc.GetReplicas(ctx)
framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas)
as, err := rc.GetHpa(ctx, hpaName)
if err != nil {
framework.Logf("Error getting HPA: %s", err)
} else {
framework.Logf("HPA status: %+v", as.Status)
}
if replicas < minDesiredReplicas {
return false, fmt.Errorf("number of replicas below target")
} else if replicas > maxDesiredReplicas {
return false, fmt.Errorf("number of replicas above target")
} else {
return true, nil // Expected number of replicas found. Continue polling until timeout.
}
})).WithTimeout(duration).WithPolling(interval).Should(gomega.BeTrue())
framework.Gomega().Consistently(ctx, func(ctx context.Context) int {
return rc.GetReplicas(ctx)
}).WithTimeout(duration).WithPolling(interval).Should(gomega.And(gomega.BeNumerically(">=", minDesiredReplicas), gomega.BeNumerically("<=", maxDesiredReplicas)))

as, err := rc.GetHpa(ctx, hpaName)
if err != nil {
framework.Logf("Error getting HPA: %s", err)
} else {
framework.Logf("HPA status: %+v", as.Status)
}
}

// Pause stops background goroutines responsible for consuming resources.
Expand Down

0 comments on commit 49e8c19

Please sign in to comment.