Skip to content

Commit 81684fe

Browse files
committed
Make autoscaler e2e test more stable
1 parent 7a3750c commit 81684fe

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

Diff for: tests/e2e/autoscaling/autoscaler.go

+3-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package autoscaling
1818

1919
import (
20-
"fmt"
2120
"strconv"
2221

2322
appsv1 "k8s.io/api/apps/v1"
@@ -80,6 +79,7 @@ var _ = Describe("Cluster size autoscaler [Serial][Slow]", func() {
8079
emptyQuantity.Sub(runningQuantity)
8180

8281
podCount = int(emptyQuantity.MilliValue()/podSize) + 1
82+
utils.Logf("%vm space are already in use", runningQuantity.Value())
8383
utils.Logf("will create %v pod, each %vm size", podCount, podSize)
8484
})
8585

@@ -107,24 +107,6 @@ var _ = Describe("Cluster size autoscaler [Serial][Slow]", func() {
107107
podCount = 0
108108
})
109109

110-
It("should scale up if created pods exceed the node capacity [Feature:Autoscaling]", func() {
111-
utils.Logf("creating pods")
112-
for i := 0; i < podCount; i++ {
113-
pod := createScalerPodManifest(fmt.Sprintf("%s-pod-%v", basename, i))
114-
_, err := cs.CoreV1().Pods(ns.Name).Create(pod)
115-
Expect(err).NotTo(HaveOccurred())
116-
}
117-
defer func() {
118-
utils.Logf("deleting pods")
119-
err := utils.DeletePodsInNamespace(cs, ns.Name)
120-
Expect(err).NotTo(HaveOccurred())
121-
}()
122-
By("scale up")
123-
targetNodeCount := initNodeCount + 1
124-
err := utils.WaitAutoScaleNodes(cs, targetNodeCount)
125-
Expect(err).NotTo(HaveOccurred())
126-
})
127-
128110
It("should scale up or down if deployment replicas leave nodes busy or idle [Feature:Autoscaling]", func() {
129111
utils.Logf("Create deployment")
130112
replicas := int32(podCount)
@@ -135,6 +117,7 @@ var _ = Describe("Cluster size autoscaler [Serial][Slow]", func() {
135117
By("Scale up")
136118
targetNodeCount := initNodeCount + 1
137119
err = utils.WaitAutoScaleNodes(cs, targetNodeCount)
120+
utils.LogPodStatus(cs, ns.Name)
138121
Expect(err).NotTo(HaveOccurred())
139122

140123
By("Scale down")
@@ -145,6 +128,7 @@ var _ = Describe("Cluster size autoscaler [Serial][Slow]", func() {
145128
Expect(err).NotTo(HaveOccurred())
146129
targetNodeCount = initNodeCount
147130
err = utils.WaitAutoScaleNodes(cs, targetNodeCount)
131+
utils.LogPodStatus(cs, ns.Name)
148132
Expect(err).NotTo(HaveOccurred())
149133
})
150134
})

Diff for: tests/e2e/utils/node_utils.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ func getNodeList(cs clientset.Interface) (*v1.NodeList, error) {
5454
if wait.PollImmediate(poll, singleCallTimeout, func() (bool, error) {
5555
nodes, err = cs.CoreV1().Nodes().List(metav1.ListOptions{})
5656
if err != nil {
57-
if IsRetryableAPIError(err) {
58-
return false, nil
59-
}
60-
return false, err
57+
return false, nil
6158
}
6259
return true, nil
6360
}) != nil {
@@ -132,8 +129,8 @@ func WaitAutoScaleNodes(cs clientset.Interface, targetNodeCount int) error {
132129
Logf(fmt.Sprintf("waiting for auto-scaling the node... Target node count: %v", targetNodeCount))
133130
var nodes []v1.Node
134131
var err error
135-
poll := 20 * time.Second
136-
autoScaleTimeOut := 30 * time.Minute
132+
poll := 60 * time.Second
133+
autoScaleTimeOut := 50 * time.Minute
137134
if wait.PollImmediate(poll, autoScaleTimeOut, func() (bool, error) {
138135
nodes, err = GetAgentNodes(cs)
139136
if err != nil {

Diff for: tests/e2e/utils/pod_utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ func getPodList(cs clientset.Interface, ns string) (*v1.PodList, error) {
4747
return pods, nil
4848
}
4949

50+
// LogPodStatus logs the rate of pending
51+
func LogPodStatus(cs clientset.Interface, ns string) error {
52+
pods, err := getPodList(cs, ns)
53+
if err != nil {
54+
return err
55+
}
56+
pendingPodCount := 0
57+
for _, p := range pods.Items {
58+
if p.Status.Phase == v1.PodPending {
59+
pendingPodCount++
60+
}
61+
}
62+
Logf("%d of %d pods in namespace %s are pending", pendingPodCount, len(pods.Items), ns)
63+
return nil
64+
}
65+
5066
// DeletePodsInNamespace deletes all pods in the namespace
5167
func DeletePodsInNamespace(cs clientset.Interface, ns string) error {
5268
Logf("Deleting all pods in namespace %s", ns)

0 commit comments

Comments
 (0)