Enable cluster autoscaling in e2e tests using gcloud command

This commit is contained in:
Marcin Wielgus 2016-06-23 13:10:45 +02:00
parent 11fdfb50d5
commit 0000f1859b

View File

@ -273,24 +273,18 @@ func isAutoscalerEnabled(expectedMinNodeCountInTargetPool int) (bool, error) {
} }
func enableAutoscaler(nodePool string, minCount, maxCount int) error { func enableAutoscaler(nodePool string, minCount, maxCount int) error {
updateRequest := "{" + output, err := exec.Command("gcloud", "alpha", "container", "clusters", "update", framework.TestContext.CloudConfig.Cluster,
" \"update\": {" + "--enable-autoscaling",
" \"desiredNodePoolId\": \"" + nodePool + "\"," + "--min-nodes="+strconv.Itoa(minCount),
" \"desiredNodePoolAutoscaling\": {" + "--max-nodes="+strconv.Itoa(maxCount),
" \"enabled\": \"true\"," + "--node-pool="+nodePool,
" \"minNodeCount\": \"" + strconv.Itoa(minCount) + "\"," + "--project="+framework.TestContext.CloudConfig.ProjectID,
" \"maxNodeCount\": \"" + strconv.Itoa(maxCount) + "\"" + "--zone="+framework.TestContext.CloudConfig.Zone).Output()
" }" +
" }" +
"}"
url := getGKEClusterUrl()
glog.Infof("Using gke api url %s", url)
putResult, err := doPut(url, updateRequest)
if err != nil { if err != nil {
return fmt.Errorf("Failed to put %s: %v", url, err) return fmt.Errorf("Failed to enable autoscaling: %v", err)
} }
glog.Infof("Config update result: %s", putResult) glog.Infof("Config update result: %s", output)
for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) { for startTime := time.Now(); startTime.Add(gkeUpdateTimeout).After(time.Now()); time.Sleep(30 * time.Second) {
if val, err := isAutoscalerEnabled(minCount); err == nil && val { if val, err := isAutoscalerEnabled(minCount); err == nil && val {