increasedSize += increasedSizes[key] } setMigSizes(increasedSizes) <del> ExpectNoError(WaitForClusterSizeFunc(c, func(size int) bool { return size == increasedSize }, DNSscaleUpTimeout)) </del> <ins> Expect(WaitForClusterSizeFunc(c, func(size int) bool { return size == increasedSize }, scaleUpTimeout)).NotTo(HaveOccurred()) By("Wait for kube-dns scaled to expected number") getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_1) Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) By("Replace the dns autoscaling parameters with another testing parameters") Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_3.data))).NotTo(HaveOccurred()) </ins> By("Wait for kube-dns scaled to expected number") <del> ExpectNoError(waitForDNSReplicasSatisfied(c, increasedSize, DNSdefaultTimeout)) </del> <ins> getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_3) Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) </ins> By("Restoring cluster size") setMigSizes(originalSizes) <del> framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount, DNSscaleDownTimeout)) </del> <ins> Expect(framework.WaitForClusterSize(c, sum, scaleDownTimeout)).NotTo(HaveOccurred()) </ins> By("Wait for kube-dns scaled to expected number") <del> ExpectNoError(waitForDNSReplicasSatisfied(c, nodeCount, DNSdefaultTimeout)) </del> <ins> Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) </ins> }) It("kube-dns-autoscaler should scale kube-dns pods in both nonfaulty and faulty scenarios", func() { By("--- Scenario: should scale kube-dns based on changed parameters ---") <del> By("Replace the dns autoscaling parameters with the second testing parameters") ExpectNoError(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_2))) </del> <ins> By("Replace the dns autoscaling parameters with another testing parameters") Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_3.data))).NotTo(HaveOccurred()) </ins> By("Wait for kube-dns scaled to expected number") <del> ExpectNoError(waitForDNSReplicasSatisfied(c, int(math.Ceil(float64(nodeCount)/2.0)), DNSdefaultTimeout)) </del> <ins> getExpectReplicasLinear := getExpectReplicasFuncLinear(c, &DNSParams_3) Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) </ins> By("--- Scenario: should re-create scaling parameters with default value when parameters got deleted ---") By("Delete the ConfigMap for autoscaler") err := deleteDNSScalingConfigMap(c) <del> ExpectNoError(err) </del> <ins> Expect(err).NotTo(HaveOccurred()) </ins> By("Wait for the ConfigMap got re-created") configMap, err := waitForDNSConfigMapCreated(c, DNSdefaultTimeout) <del> ExpectNoError(err) </del> <ins> Expect(err).NotTo(HaveOccurred()) </ins> By("Check the new created ConfigMap got the same data as we have") Expect(reflect.DeepEqual(previousParams, configMap.Data)).To(Equal(true)) <del> By("Replace the dns autoscaling parameters with the second testing parameters") ExpectNoError(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_2))) </del> <ins> By("Replace the dns autoscaling parameters with another testing parameters") Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_2.data))).NotTo(HaveOccurred()) </ins> By("Wait for kube-dns scaled to expected number") <del> ExpectNoError(waitForDNSReplicasSatisfied(c, int(math.Ceil(float64(nodeCount)/2.0)), DNSdefaultTimeout)) </del> <ins> getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_2) Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) </ins> By("--- Scenario: should recover after autoscaler pod got deleted ---") By("Delete the autoscaler pod for kube-dns") <del> ExpectNoError(deleteDNSAutoscalerPod(c)) </del> <ins> Expect(deleteDNSAutoscalerPod(c)).NotTo(HaveOccurred()) </ins> <del> By("Replace the dns autoscaling parameters with the third testing parameters") ExpectNoError(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_3))) </del> <ins> By("Replace the dns autoscaling parameters with another testing parameters") Expect(updateDNSScalingConfigMap(c, packDNSScalingConfigMap(DNSParams_1.data))).NotTo(HaveOccurred()) </ins> By("Wait for kube-dns scaled to expected number") <del> ExpectNoError(waitForDNSReplicasSatisfied(c, int(math.Ceil(float64(nodeCount)/3.0)), DNSdefaultTimeout)) </del> <ins> getExpectReplicasLinear = getExpectReplicasFuncLinear(c, &DNSParams_1) Expect(waitForDNSReplicasSatisfied(c, getExpectReplicasLinear, DNSdefaultTimeout)).NotTo(HaveOccurred()) </ins> }) }) <ins> type DNSParamsLinear struct { data            map[string]string nodesPerReplica float64 coresPerReplica float64 } type getExpectReplicasFunc func(c clientset.Interface) int func getExpectReplicasFuncLinear(c clientset.Interface, params *DNSParamsLinear) getExpectReplicasFunc { return func(c clientset.Interface) int { var replicasFromNodes float64 var replicasFromCores float64 nodes := framework.GetReadySchedulableNodesOrDie(c).Items if params.nodesPerReplica > 0 { replicasFromNodes = math.Ceil(float64(len(nodes)) / params.nodesPerReplica) } if params.coresPerReplica > 0 { replicasFromCores = math.Ceil(float64(getScheduableCores(nodes)) / params.coresPerReplica) } return int(math.Max(1.0, math.Max(replicasFromNodes, replicasFromCores))) } } func getScheduableCores(nodes []v1.Node) int64 { var sc resource.Quantity for _, node := range nodes { if !node.Spec.Unschedulable { sc.Add(node.Status.Capacity[v1.ResourceCPU]) } } scInt64, scOk := sc.AsInt64() if !scOk { framework.Logf("unable to compute integer values of schedulable cores in the cluster") return 0 } return scInt64 } </ins> func fetchDNSScalingConfigMap(c clientset.Interface) (*v1.ConfigMap, error) { cm, err := c.Core().ConfigMaps(DNSNamespace).Get(DNSAutoscalerLabelName) if err != nil {