Skip to content

Commit

Permalink
Add envtest for HPA change
Browse files Browse the repository at this point in the history
  • Loading branch information
voelzmo committed Aug 8, 2023
1 parent 08b69b9 commit 2a6cd31
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controllers/hvpa_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"k8s.io/utils/pointer"
"time"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -191,6 +192,24 @@ var _ = Describe("#TestReconcile", func() {
return fmt.Errorf("Error: Expected 1 HPA; found %v", len(hpaList.Items))
}, timeout).Should(Succeed())

// Update the HPA spec and expect the change to be reconciled
hvpa := &autoscalingv1alpha1.Hvpa{}
c.Get(context.TODO(), types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace}, hvpa)
hvpa.Spec.Hpa.Template.Spec.MinReplicas = pointer.Int32(3)
err = c.Update(context.TODO(), hvpa)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
var actualMinReplicas int32
c.List(context.TODO(), hpaList)
for _, hpa := range hpaList.Items {
actualMinReplicas = *hpa.Spec.MinReplicas
}
if actualMinReplicas != 3 {
return fmt.Errorf("Expected minReplicas 3, got %v", actualMinReplicas)
}
return nil
}, timeout).Should(Succeed())

// Create a pod for the target deployment, and update status to "OOMKilled".
// The field hvpa.status.overrideScaleUpStabilization should be set to true.
p := v1.Pod{
Expand Down

0 comments on commit 2a6cd31

Please sign in to comment.