Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix golint check in test/e2e_node/runner/remote #85890

Merged
merged 1 commit into from Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.golint_failures
Expand Up @@ -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
26 changes: 15 additions & 11 deletions test/e2e_node/runner/remote/run_remote.go
Expand Up @@ -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
Expand All @@ -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"`
Expand Down Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down