From 2371c58a736b18379d1031fda745491f3c0f4664 Mon Sep 17 00:00:00 2001 From: tanjunchen <2799194073@qq.com> Date: Fri, 3 Jan 2020 10:39:44 +0800 Subject: [PATCH] remove unused code test/e2e/framework/google_compute.go --- test/e2e/framework/google_compute.go | 81 ---------------------------- test/e2e/framework/util.go | 16 ------ 2 files changed, 97 deletions(-) diff --git a/test/e2e/framework/google_compute.go b/test/e2e/framework/google_compute.go index 25f7564b4cb..4da845c3f5c 100644 --- a/test/e2e/framework/google_compute.go +++ b/test/e2e/framework/google_compute.go @@ -129,84 +129,3 @@ func LogClusterImageSources() { Logf("cluster images sources, could not write to %q: %v", filePath, err) } } - -// CreateManagedInstanceGroup creates a Compute Engine managed instance group. -func CreateManagedInstanceGroup(size int64, zone, template string) error { - // TODO(verult): make this hit the compute API directly instead of - // shelling out to gcloud. - _, _, err := retryCmd("gcloud", "compute", "instance-groups", "managed", - "create", - fmt.Sprintf("--project=%s", TestContext.CloudConfig.ProjectID), - fmt.Sprintf("--zone=%s", zone), - TestContext.CloudConfig.NodeInstanceGroup, - fmt.Sprintf("--size=%d", size), - fmt.Sprintf("--template=%s", template)) - if err != nil { - return fmt.Errorf("gcloud compute instance-groups managed create call failed with err: %v", err) - } - return nil -} - -// GetManagedInstanceGroupTemplateName returns the list of Google Compute Engine managed instance groups. -func GetManagedInstanceGroupTemplateName(zone string) (string, error) { - // TODO(verult): make this hit the compute API directly instead of - // shelling out to gcloud. Use InstanceGroupManager to get Instance Template name. - - stdout, _, err := retryCmd("gcloud", "compute", "instance-groups", "managed", - "list", - fmt.Sprintf("--filter=name:%s", TestContext.CloudConfig.NodeInstanceGroup), - fmt.Sprintf("--project=%s", TestContext.CloudConfig.ProjectID), - fmt.Sprintf("--zones=%s", zone), - ) - - if err != nil { - return "", fmt.Errorf("gcloud compute instance-groups managed list call failed with err: %v", err) - } - - templateName, err := parseInstanceTemplateName(stdout) - if err != nil { - return "", fmt.Errorf("error parsing gcloud output: %v", err) - } - return templateName, nil -} - -// DeleteManagedInstanceGroup deletes Google Compute Engine managed instance group. -func DeleteManagedInstanceGroup(zone string) error { - // TODO(verult): make this hit the compute API directly instead of - // shelling out to gcloud. - _, _, err := retryCmd("gcloud", "compute", "instance-groups", "managed", - "delete", - fmt.Sprintf("--project=%s", TestContext.CloudConfig.ProjectID), - fmt.Sprintf("--zone=%s", zone), - TestContext.CloudConfig.NodeInstanceGroup) - if err != nil { - return fmt.Errorf("gcloud compute instance-groups managed delete call failed with err: %v", err) - } - return nil -} - -func parseInstanceTemplateName(gcloudOutput string) (string, error) { - const templateNameField = "INSTANCE_TEMPLATE" - - lines := strings.Split(gcloudOutput, "\n") - if len(lines) <= 1 { // Empty output or only contains column names - return "", fmt.Errorf("the list is empty") - } - - // Otherwise, there should be exactly 1 entry, i.e. 2 lines - fieldNames := strings.Fields(lines[0]) - instanceTemplateColumn := 0 - for instanceTemplateColumn < len(fieldNames) && - fieldNames[instanceTemplateColumn] != templateNameField { - instanceTemplateColumn++ - } - - if instanceTemplateColumn == len(fieldNames) { - return "", fmt.Errorf("the list does not contain instance template information") - } - - fields := strings.Fields(lines[1]) - instanceTemplateName := fields[instanceTemplateColumn] - - return instanceTemplateName, nil -} diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 30418b98971..a8521863bfb 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -1714,22 +1714,6 @@ func RunCmdEnv(env []string, command string, args ...string) (string, string, er return stdout, stderr, nil } -// retryCmd runs cmd using args and retries it for up to SingleCallTimeout if -// it returns an error. It returns stdout and stderr. -func retryCmd(command string, args ...string) (string, string, error) { - var err error - stdout, stderr := "", "" - wait.Poll(Poll, SingleCallTimeout, func() (bool, error) { - stdout, stderr, err = RunCmd(command, args...) - if err != nil { - Logf("Got %v", err) - return false, nil - } - return true, nil - }) - return stdout, stderr, err -} - // E2ETestNodePreparer implements testutils.TestNodePreparer interface, which is used // to create/modify Nodes before running a test. type E2ETestNodePreparer struct {