Merge pull request #85890 from tanjunchen/fix-golint-test-e2e_node-ruuner

fix golint check in test/e2e_node/runner/remote
This commit is contained in:
Kubernetes Prow Robot 2019-12-05 00:36:32 -08:00 committed by GitHub
commit 2f58d2e3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
test/e2e/common
test/e2e/storage/vsphere
test/e2e_node/runner/remote
test/utils

View File

@ -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 {