From 610a1d1b96831c426c702d0f600267270e6ace47 Mon Sep 17 00:00:00 2001 From: SataQiu Date: Sun, 31 Mar 2019 16:32:22 +0800 Subject: [PATCH] fix golint failures of e2e/framework/ssh.go, e2e/framework/size.go --- test/e2e/framework/size.go | 4 ++++ test/e2e/framework/ssh.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/e2e/framework/size.go b/test/e2e/framework/size.go index e2e0624ab32..b20d162276c 100644 --- a/test/e2e/framework/size.go +++ b/test/e2e/framework/size.go @@ -26,6 +26,7 @@ const ( resizeNodeNotReadyTimeout = 2 * time.Minute ) +// ResizeGroup resizes an instance group func ResizeGroup(group string, size int32) error { if TestContext.ReportDir != "" { CoreDump(TestContext.ReportDir) @@ -34,14 +35,17 @@ func ResizeGroup(group string, size int32) error { return TestContext.CloudConfig.Provider.ResizeGroup(group, size) } +// GetGroupNodes returns a node name for the specified node group func GetGroupNodes(group string) ([]string, error) { return TestContext.CloudConfig.Provider.GetGroupNodes(group) } +// GroupSize returns the size of an instance group func GroupSize(group string) (int, error) { return TestContext.CloudConfig.Provider.GroupSize(group) } +// WaitForGroupSize waits for node instance group reached the desired size func WaitForGroupSize(group string, size int32) error { timeout := 30 * time.Minute for start := time.Now(); time.Since(start) < timeout; time.Sleep(20 * time.Second) { diff --git a/test/e2e/framework/ssh.go b/test/e2e/framework/ssh.go index 2949d16d38b..188bb35da94 100644 --- a/test/e2e/framework/ssh.go +++ b/test/e2e/framework/ssh.go @@ -111,6 +111,7 @@ func NodeSSHHosts(c clientset.Interface) ([]string, error) { return sshHosts, nil } +// SSHResult holds the execution result of SSH command type SSHResult struct { User string Host string @@ -230,6 +231,7 @@ func RunSSHCommandViaBastion(cmd, user, bastion, host string, signer ssh.Signer) return bout.String(), berr.String(), code, err } +// LogSSHResult records SSHResult log func LogSSHResult(result SSHResult) { remote := fmt.Sprintf("%s@%s", result.User, result.Host) Logf("ssh %s: command: %s", remote, result.Cmd) @@ -238,6 +240,7 @@ func LogSSHResult(result SSHResult) { Logf("ssh %s: exit code: %d", remote, result.Code) } +// IssueSSHCommandWithResult tries to execute a SSH command and returns the execution result func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult, error) { Logf("Getting external IP address for %s", node.Name) host := "" @@ -274,6 +277,7 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult, return &result, nil } +// IssueSSHCommand tries to execute a SSH command func IssueSSHCommand(cmd, provider string, node *v1.Node) error { _, err := IssueSSHCommandWithResult(cmd, provider, node) if err != nil {