Merge pull request #28344 from mwielgus/e2e-sd-nanp

E2e tests to check whether cluster autoscaling scale down works when one node pool is not autoscaled
pull/6/head
Piotr Szczesniak 2016-07-01 11:58:29 +02:00 committed by GitHub
commit 8cabbcbdcf
1 changed files with 31 additions and 5 deletions

View File

@ -137,7 +137,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with one n1-standard-4 machine") By("Creating new node-pool with one n1-standard-4 machine")
const extraPoolName = "extra-pool" const extraPoolName = "extra-pool"
addNodePool(extraPoolName, "n1-standard-4") addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName) defer deleteNodePool(extraPoolName)
framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout))
glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).") glog.Infof("Not enabling cluster autoscaler for the node pool (on purpose).")
@ -156,7 +156,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with one n1-standard-4 machine") By("Creating new node-pool with one n1-standard-4 machine")
const extraPoolName = "extra-pool" const extraPoolName = "extra-pool"
addNodePool(extraPoolName, "n1-standard-4") addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName) defer deleteNodePool(extraPoolName)
framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout))
framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2)) framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2))
@ -225,7 +225,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
By("Creating new node-pool with one n1-standard-4 machine") By("Creating new node-pool with one n1-standard-4 machine")
const extraPoolName = "extra-pool" const extraPoolName = "extra-pool"
addNodePool(extraPoolName, "n1-standard-4") addNodePool(extraPoolName, "n1-standard-4", 1)
defer deleteNodePool(extraPoolName) defer deleteNodePool(extraPoolName)
framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout)) framework.ExpectNoError(framework.WaitForClusterSize(c, nodeCount+1, resizeTimeout))
framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2)) framework.ExpectNoError(enableAutoscaler(extraPoolName, 1, 2))
@ -252,6 +252,32 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
framework.ExpectNoError(WaitForClusterSizeFunc(f.Client, framework.ExpectNoError(WaitForClusterSizeFunc(f.Client,
func(size int) bool { return size < increasedSize }, scaleDownTimeout)) func(size int) bool { return size < increasedSize }, scaleDownTimeout))
}) })
It("should correctly scale down after a node is not needed when there is non autoscaled pool[Feature:ClusterSizeAutoscalingScaleDown]", func() {
framework.SkipUnlessProviderIs("gke")
By("Manually increase cluster size")
increasedSize := 0
newSizes := make(map[string]int)
for key, val := range originalSizes {
newSizes[key] = val + 2
increasedSize += val + 2
}
setMigSizes(newSizes)
framework.ExpectNoError(WaitForClusterSizeFunc(f.Client,
func(size int) bool { return size >= increasedSize }, scaleUpTimeout))
const extraPoolName = "extra-pool"
addNodePool(extraPoolName, "n1-standard-1", 3)
defer deleteNodePool(extraPoolName)
framework.ExpectNoError(WaitForClusterSizeFunc(f.Client,
func(size int) bool { return size >= increasedSize+3 }, scaleUpTimeout))
By("Some node should be removed")
framework.ExpectNoError(WaitForClusterSizeFunc(f.Client,
func(size int) bool { return size < increasedSize+3 }, scaleDownTimeout))
})
}) })
func getGKEClusterUrl() string { func getGKEClusterUrl() string {
@ -378,10 +404,10 @@ func disableAutoscaler(nodePool string, minCount, maxCount int) error {
return fmt.Errorf("autoscaler still enabled") return fmt.Errorf("autoscaler still enabled")
} }
func addNodePool(name string, machineType string) { func addNodePool(name string, machineType string, numNodes int) {
output, err := exec.Command("gcloud", "alpha", "container", "node-pools", "create", name, "--quiet", output, err := exec.Command("gcloud", "alpha", "container", "node-pools", "create", name, "--quiet",
"--machine-type="+machineType, "--machine-type="+machineType,
"--num-nodes=1", "--num-nodes="+strconv.Itoa(numNodes),
"--project="+framework.TestContext.CloudConfig.ProjectID, "--project="+framework.TestContext.CloudConfig.ProjectID,
"--zone="+framework.TestContext.CloudConfig.Zone, "--zone="+framework.TestContext.CloudConfig.Zone,
"--cluster="+framework.TestContext.CloudConfig.Cluster).CombinedOutput() "--cluster="+framework.TestContext.CloudConfig.Cluster).CombinedOutput()