From 29eb15c3a84a8d8d2299d6dea74b55029643a69f Mon Sep 17 00:00:00 2001 From: tanjunchen <2799194073@qq.com> Date: Wed, 4 Dec 2019 18:14:52 +0800 Subject: [PATCH] fix golint check in test/e2e_node/runner/remote --- hack/.golint_failures | 1 - test/e2e_node/runner/remote/run_remote.go | 26 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/hack/.golint_failures b/hack/.golint_failures index bdb26af9e07..1db3e86bc97 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -520,5 +520,4 @@ staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder test/e2e/common test/e2e/storage/vsphere -test/e2e_node/runner/remote test/utils diff --git a/test/e2e_node/runner/remote/run_remote.go b/test/e2e_node/runner/remote/run_remote.go index 94e0cf553e8..11c4487e3c3 100644 --- a/test/e2e_node/runner/remote/run_remote.go +++ b/test/e2e_node/runner/remote/run_remote.go @@ -105,12 +105,14 @@ var ( suite remote.TestSuite ) +// Archive contains path info in the archive. type Archive struct { sync.Once path string err error } +// TestResult contains some information about the test results. type TestResult struct { output string err error @@ -129,22 +131,24 @@ type TestResult struct { // project: gce-image-project // machine: for benchmark only, the machine type (GCE instance) to run test // tests: for benchmark only, a list of ginkgo focus strings to match tests - // TODO(coufon): replace 'image' with 'node' in configurations // and we plan to support testing custom machines other than GCE by specifying host type ImageConfig struct { Images map[string]GCEImage `json:"images"` } +// Accelerator contains type and count about resource. type Accelerator struct { Type string `json:"type,omitempty"` Count int64 `json:"count,omitempty"` } +// Resources contains accelerators array. type Resources struct { Accelerators []Accelerator `json:"accelerators,omitempty"` } +// GCEImage contains some information about CGE Image. type GCEImage struct { Image string `json:"image,omitempty"` ImageDesc string `json:"image_description,omitempty"` @@ -428,23 +432,23 @@ func testHost(host string, deleteFiles bool, imageDesc, junitFilePrefix, ginkgoF } } if strings.ToUpper(instance.Status) != "RUNNING" { - err = fmt.Errorf("instance %s not in state RUNNING, was %s.", host, instance.Status) + err = fmt.Errorf("instance %s not in state RUNNING, was %s", host, instance.Status) return &TestResult{ err: err, host: host, exitOk: false, } } - externalIp := getExternalIp(instance) - if len(externalIp) > 0 { - remote.AddHostnameIP(host, externalIp) + externalIP := getExternalIP(instance) + if len(externalIP) > 0 { + remote.AddHostnameIP(host, externalIP) } path, err := arc.getArchive() if err != nil { // Don't log fatal because we need to do any needed cleanup contained in "defer" statements return &TestResult{ - err: fmt.Errorf("unable to create test archive: %v.", err), + err: fmt.Errorf("unable to create test archive: %v", err), } } @@ -643,12 +647,12 @@ func createInstance(imageConfig *internalGCEImage) (string, error) { continue } if strings.ToUpper(instance.Status) != "RUNNING" { - err = fmt.Errorf("instance %s not in state RUNNING, was %s.", name, instance.Status) + err = fmt.Errorf("instance %s not in state RUNNING, was %s", name, instance.Status) continue } - externalIp := getExternalIp(instance) - if len(externalIp) > 0 { - remote.AddHostnameIP(name, externalIp) + externalIP := getExternalIP(instance) + if len(externalIP) > 0 { + remote.AddHostnameIP(name, externalIP) } // TODO(random-liu): Remove the docker version check. Use some other command to check // instance readiness. @@ -699,7 +703,7 @@ func isCloudInitUsed(metadata *compute.Metadata) bool { return false } -func getExternalIp(instance *compute.Instance) string { +func getExternalIP(instance *compute.Instance) string { for i := range instance.NetworkInterfaces { ni := instance.NetworkInterfaces[i] for j := range ni.AccessConfigs {