mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #77113 from s-ito-ts/77103_autoscaling
Use framework.ExpectNoError() for e2e/autoscaling
This commit is contained in:
commit
19ed7fa731
@ -61,10 +61,10 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
|
|||||||
By("Collecting original replicas count and DNS scaling params")
|
By("Collecting original replicas count and DNS scaling params")
|
||||||
var err error
|
var err error
|
||||||
originDNSReplicasCount, err = getDNSReplicas(c)
|
originDNSReplicasCount, err = getDNSReplicas(c)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
pcm, err := fetchDNSScalingConfigMap(c)
|
pcm, err := fetchDNSScalingConfigMap(c)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
previousParams = pcm.Data
|
previousParams = pcm.Data
|
||||||
|
|
||||||
if nodeCount <= 500 {
|
if nodeCount <= 500 {
|
||||||
@ -101,28 +101,30 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
|
|||||||
// Will take around 5 minutes to run on a 4 nodes cluster.
|
// Will take around 5 minutes to run on a 4 nodes cluster.
|
||||||
It("[Serial] [Slow] kube-dns-autoscaler should scale kube-dns pods when cluster size changed", func() {
|
It("[Serial] [Slow] kube-dns-autoscaler should scale kube-dns pods when cluster size changed", func() {
|
||||||
numNodes, err := framework.NumberOfRegisteredNodes(c)
|
numNodes, err := framework.NumberOfRegisteredNodes(c)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Replace the dns autoscaling parameters with testing parameters")
|
By("Replace the dns autoscaling parameters with testing parameters")
|
||||||
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
defer func() {
|
defer func() {
|
||||||
By("Restoring initial dns autoscaling parameters")
|
By("Restoring initial dns autoscaling parameters")
|
||||||
Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(previousParams))).NotTo(HaveOccurred())
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(previousParams))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Wait for number of running and ready kube-dns pods recover")
|
By("Wait for number of running and ready kube-dns pods recover")
|
||||||
label := labels.SelectorFromSet(labels.Set(map[string]string{ClusterAddonLabelKey: DNSLabelName}))
|
label := labels.SelectorFromSet(labels.Set(map[string]string{ClusterAddonLabelKey: DNSLabelName}))
|
||||||
_, err := framework.WaitForPodsWithLabelRunningReady(c, metav1.NamespaceSystem, label, originDNSReplicasCount, DNSdefaultTimeout)
|
_, err := framework.WaitForPodsWithLabelRunningReady(c, metav1.NamespaceSystem, label, originDNSReplicasCount, DNSdefaultTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
}()
|
}()
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_1)
|
getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_1)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
originalSizes := make(map[string]int)
|
originalSizes := make(map[string]int)
|
||||||
for _, mig := range strings.Split(framework.TestContext.CloudConfig.NodeInstanceGroup, ",") {
|
for _, mig := range strings.Split(framework.TestContext.CloudConfig.NodeInstanceGroup, ",") {
|
||||||
size, err := framework.GroupSize(mig)
|
size, err := framework.GroupSize(mig)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
By(fmt.Sprintf("Initial size of %s: %d", mig, size))
|
By(fmt.Sprintf("Initial size of %s: %d", mig, size))
|
||||||
originalSizes[mig] = size
|
originalSizes[mig] = size
|
||||||
}
|
}
|
||||||
@ -133,27 +135,32 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
|
|||||||
increasedSizes[key] = val + 1
|
increasedSizes[key] = val + 1
|
||||||
}
|
}
|
||||||
setMigSizes(increasedSizes)
|
setMigSizes(increasedSizes)
|
||||||
Expect(WaitForClusterSizeFunc(c,
|
err = WaitForClusterSizeFunc(c,
|
||||||
func(size int) bool { return size == numNodes+len(originalSizes) }, scaleUpTimeout)).NotTo(HaveOccurred())
|
func(size int) bool { return size == numNodes+len(originalSizes) }, scaleUpTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1)
|
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Replace the dns autoscaling parameters with another testing parameters")
|
By("Replace the dns autoscaling parameters with another testing parameters")
|
||||||
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3)))
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3)
|
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Restoring cluster size")
|
By("Restoring cluster size")
|
||||||
setMigSizes(originalSizes)
|
setMigSizes(originalSizes)
|
||||||
Expect(framework.WaitForReadyNodes(c, numNodes, scaleDownTimeout)).NotTo(HaveOccurred())
|
err = framework.WaitForReadyNodes(c, numNodes, scaleDownTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Get rid of [DisabledForLargeClusters] tag when issue #55779 is fixed.
|
// TODO: Get rid of [DisabledForLargeClusters] tag when issue #55779 is fixed.
|
||||||
@ -161,49 +168,55 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() {
|
|||||||
|
|
||||||
By("Replace the dns autoscaling parameters with testing parameters")
|
By("Replace the dns autoscaling parameters with testing parameters")
|
||||||
err := updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
err := updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
defer func() {
|
defer func() {
|
||||||
By("Restoring initial dns autoscaling parameters")
|
By("Restoring initial dns autoscaling parameters")
|
||||||
Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(previousParams))).NotTo(HaveOccurred())
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(previousParams))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
}()
|
}()
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_1)
|
getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_1)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("--- Scenario: should scale kube-dns based on changed parameters ---")
|
By("--- Scenario: should scale kube-dns based on changed parameters ---")
|
||||||
By("Replace the dns autoscaling parameters with another testing parameters")
|
By("Replace the dns autoscaling parameters with another testing parameters")
|
||||||
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3)))
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3)
|
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("--- Scenario: should re-create scaling parameters with default value when parameters got deleted ---")
|
By("--- Scenario: should re-create scaling parameters with default value when parameters got deleted ---")
|
||||||
By("Delete the ConfigMap for autoscaler")
|
By("Delete the ConfigMap for autoscaler")
|
||||||
err = deleteDNSScalingConfigMap(c)
|
err = deleteDNSScalingConfigMap(c)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Wait for the ConfigMap got re-created")
|
By("Wait for the ConfigMap got re-created")
|
||||||
_, err = waitForDNSConfigMapCreated(c, DNSdefaultTimeout)
|
_, err = waitForDNSConfigMapCreated(c, DNSdefaultTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Replace the dns autoscaling parameters with another testing parameters")
|
By("Replace the dns autoscaling parameters with another testing parameters")
|
||||||
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_2)))
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_2)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_2)
|
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_2)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("--- Scenario: should recover after autoscaler pod got deleted ---")
|
By("--- Scenario: should recover after autoscaler pod got deleted ---")
|
||||||
By("Delete the autoscaler pod for kube-dns")
|
By("Delete the autoscaler pod for kube-dns")
|
||||||
Expect(deleteDNSAutoscalerPod(c)).NotTo(HaveOccurred())
|
err = deleteDNSAutoscalerPod(c)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
By("Replace the dns autoscaling parameters with another testing parameters")
|
By("Replace the dns autoscaling parameters with another testing parameters")
|
||||||
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1)))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
framework.ExpectNoError(err)
|
||||||
By("Wait for kube-dns scaled to expected number")
|
By("Wait for kube-dns scaled to expected number")
|
||||||
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1)
|
getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1)
|
||||||
Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred())
|
err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user