mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
use framework gomega
Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
parent
4b1b9a198a
commit
49e8c196c3
@ -507,23 +507,16 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
|
|||||||
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
|
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
|
||||||
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
|
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
|
||||||
interval := 10 * time.Second
|
interval := 10 * time.Second
|
||||||
gomega.Consistently(ctx, framework.HandleRetry(func(ctx context.Context) (bool, error) {
|
framework.Gomega().Consistently(ctx, func(ctx context.Context) int {
|
||||||
replicas := rc.GetReplicas(ctx)
|
return rc.GetReplicas(ctx)
|
||||||
framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas)
|
}).WithTimeout(duration).WithPolling(interval).Should(gomega.And(gomega.BeNumerically(">=", minDesiredReplicas), gomega.BeNumerically("<=", maxDesiredReplicas)))
|
||||||
as, err := rc.GetHpa(ctx, hpaName)
|
|
||||||
if err != nil {
|
as, err := rc.GetHpa(ctx, hpaName)
|
||||||
framework.Logf("Error getting HPA: %s", err)
|
if err != nil {
|
||||||
} else {
|
framework.Logf("Error getting HPA: %s", err)
|
||||||
framework.Logf("HPA status: %+v", as.Status)
|
} 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())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause stops background goroutines responsible for consuming resources.
|
// Pause stops background goroutines responsible for consuming resources.
|
||||||
|
Loading…
Reference in New Issue
Block a user