fix golint check in test/e2e_node/runner/remote

This commit is contained in:
tanjunchen 2019-12-04 18:14:52 +08:00
parent e28ae9ce09
commit 29eb15c3a8
2 changed files with 15 additions and 12 deletions

View File

@ -520,5 +520,4 @@ staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
test/e2e/common test/e2e/common
test/e2e/storage/vsphere test/e2e/storage/vsphere
test/e2e_node/runner/remote
test/utils test/utils

View File

@ -105,12 +105,14 @@ var (
suite remote.TestSuite suite remote.TestSuite
) )
// Archive contains path info in the archive.
type Archive struct { type Archive struct {
sync.Once sync.Once
path string path string
err error err error
} }
// TestResult contains some information about the test results.
type TestResult struct { type TestResult struct {
output string output string
err error err error
@ -129,22 +131,24 @@ type TestResult struct {
// project: gce-image-project // project: gce-image-project
// machine: for benchmark only, the machine type (GCE instance) to run test // 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 // tests: for benchmark only, a list of ginkgo focus strings to match tests
// TODO(coufon): replace 'image' with 'node' in configurations // TODO(coufon): replace 'image' with 'node' in configurations
// and we plan to support testing custom machines other than GCE by specifying host // and we plan to support testing custom machines other than GCE by specifying host
type ImageConfig struct { type ImageConfig struct {
Images map[string]GCEImage `json:"images"` Images map[string]GCEImage `json:"images"`
} }
// Accelerator contains type and count about resource.
type Accelerator struct { type Accelerator struct {
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
Count int64 `json:"count,omitempty"` Count int64 `json:"count,omitempty"`
} }
// Resources contains accelerators array.
type Resources struct { type Resources struct {
Accelerators []Accelerator `json:"accelerators,omitempty"` Accelerators []Accelerator `json:"accelerators,omitempty"`
} }
// GCEImage contains some information about CGE Image.
type GCEImage struct { type GCEImage struct {
Image string `json:"image,omitempty"` Image string `json:"image,omitempty"`
ImageDesc string `json:"image_description,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" { 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{ return &TestResult{
err: err, err: err,
host: host, host: host,
exitOk: false, exitOk: false,
} }
} }
externalIp := getExternalIp(instance) externalIP := getExternalIP(instance)
if len(externalIp) > 0 { if len(externalIP) > 0 {
remote.AddHostnameIP(host, externalIp) remote.AddHostnameIP(host, externalIP)
} }
path, err := arc.getArchive() path, err := arc.getArchive()
if err != nil { if err != nil {
// Don't log fatal because we need to do any needed cleanup contained in "defer" statements // Don't log fatal because we need to do any needed cleanup contained in "defer" statements
return &TestResult{ 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 continue
} }
if strings.ToUpper(instance.Status) != "RUNNING" { 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 continue
} }
externalIp := getExternalIp(instance) externalIP := getExternalIP(instance)
if len(externalIp) > 0 { if len(externalIP) > 0 {
remote.AddHostnameIP(name, externalIp) remote.AddHostnameIP(name, externalIP)
} }
// TODO(random-liu): Remove the docker version check. Use some other command to check // TODO(random-liu): Remove the docker version check. Use some other command to check
// instance readiness. // instance readiness.
@ -699,7 +703,7 @@ func isCloudInitUsed(metadata *compute.Metadata) bool {
return false return false
} }
func getExternalIp(instance *compute.Instance) string { func getExternalIP(instance *compute.Instance) string {
for i := range instance.NetworkInterfaces { for i := range instance.NetworkInterfaces {
ni := instance.NetworkInterfaces[i] ni := instance.NetworkInterfaces[i]
for j := range ni.AccessConfigs { for j := range ni.AccessConfigs {