diff --git a/test/e2e/autoscaling/dns_autoscaling.go b/test/e2e/autoscaling/dns_autoscaling.go index 6ec9d63fb76..a2bad195cbd 100644 --- a/test/e2e/autoscaling/dns_autoscaling.go +++ b/test/e2e/autoscaling/dns_autoscaling.go @@ -61,10 +61,10 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() { By("Collecting original replicas count and DNS scaling params") var err error originDNSReplicasCount, err = getDNSReplicas(c) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) pcm, err := fetchDNSScalingConfigMap(c) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) previousParams = pcm.Data 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. It("[Serial] [Slow] kube-dns-autoscaler should scale kube-dns pods when cluster size changed", func() { numNodes, err := framework.NumberOfRegisteredNodes(c) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Replace the dns autoscaling parameters with testing parameters") err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) defer func() { 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") label := labels.SelectorFromSet(labels.Set(map[string]string{ClusterAddonLabelKey: DNSLabelName})) _, 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") 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) for _, mig := range strings.Split(framework.TestContext.CloudConfig.NodeInstanceGroup, ",") { size, err := framework.GroupSize(mig) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By(fmt.Sprintf("Initial size of %s: %d", mig, size)) originalSizes[mig] = size } @@ -133,27 +135,32 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() { increasedSizes[key] = val + 1 } setMigSizes(increasedSizes) - Expect(WaitForClusterSizeFunc(c, - func(size int) bool { return size == numNodes+len(originalSizes) }, scaleUpTimeout)).NotTo(HaveOccurred()) + err = WaitForClusterSizeFunc(c, + func(size int) bool { return size == numNodes+len(originalSizes) }, scaleUpTimeout) + framework.ExpectNoError(err) By("Wait for kube-dns scaled to expected number") 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") err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Wait for kube-dns scaled to expected number") getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3) - Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) + err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout) + framework.ExpectNoError(err) By("Restoring cluster size") 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") - 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. @@ -161,49 +168,55 @@ var _ = SIGDescribe("DNS horizontal autoscaling", func() { By("Replace the dns autoscaling parameters with testing parameters") err := updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) defer func() { 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") 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("Replace the dns autoscaling parameters with another testing parameters") err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_3))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Wait for kube-dns scaled to expected number") 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("Delete the ConfigMap for autoscaler") err = deleteDNSScalingConfigMap(c) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Wait for the ConfigMap got re-created") _, err = waitForDNSConfigMapCreated(c, DNSdefaultTimeout) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Replace the dns autoscaling parameters with another testing parameters") err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_2))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Wait for kube-dns scaled to expected number") 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("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") err = updateDNSScalingConfigMap(c, packDNSScalingConfigMap(packLinearParams(&DNSParams_1))) - Expect(err).NotTo(HaveOccurred()) + framework.ExpectNoError(err) By("Wait for kube-dns scaled to expected number") getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1) - Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) + err = waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout) + framework.ExpectNoError(err) }) })