@@ -31,16 +31,17 @@ import (
31
31
"k8s.io/klog"
32
32
)
33
33
34
- var testTimeoutSeconds = flag .Duration ("test-timeout" , 45 * time .Minute , "How long (in golang duration format) to wait for ginkgo tests to complete." )
34
+ var testTimeout = flag .Duration ("test-timeout" , 45 * time .Minute , "How long (in golang duration format) to wait for ginkgo tests to complete." )
35
35
var resultsDir = flag .String ("results-dir" , "/tmp/" , "Directory to scp test results to." )
36
36
37
37
const archiveName = "e2e_node_test.tar.gz"
38
38
39
+ // CreateTestArchive creates the archive package for the node e2e test.
39
40
func CreateTestArchive (suite TestSuite , systemSpecName string ) (string , error ) {
40
41
klog .V (2 ).Infof ("Building archive..." )
41
42
tardir , err := ioutil .TempDir ("" , "node-e2e-archive" )
42
43
if err != nil {
43
- return "" , fmt .Errorf ("failed to create temporary directory %v. " , err )
44
+ return "" , fmt .Errorf ("failed to create temporary directory %v" , err )
44
45
}
45
46
defer os .RemoveAll (tardir )
46
47
@@ -58,12 +59,12 @@ func CreateTestArchive(suite TestSuite, systemSpecName string) (string, error) {
58
59
59
60
dir , err := os .Getwd ()
60
61
if err != nil {
61
- return "" , fmt .Errorf ("failed to get working directory %v. " , err )
62
+ return "" , fmt .Errorf ("failed to get working directory %v" , err )
62
63
}
63
64
return filepath .Join (dir , archiveName ), nil
64
65
}
65
66
66
- // Returns the command output, whether the exit was ok, and any errors
67
+ // RunRemote returns the command output, whether the exit was ok, and any errors
67
68
// TODO(random-liu): junitFilePrefix is not prefix actually, the file name is junit-junitFilePrefix.xml. Change the variable name.
68
69
func RunRemote (suite TestSuite , archive string , host string , cleanup bool , imageDesc , junitFilePrefix string , testArgs string , ginkgoArgs string , systemSpecName string , extraEnvs string ) (string , bool , error ) {
69
70
// Create the temp staging directory
@@ -84,7 +85,7 @@ func RunRemote(suite TestSuite, archive string, host string, cleanup bool, image
84
85
}
85
86
86
87
// Copy the archive to the staging directory
87
- if output , err := runSSHCommand ("scp" , archive , fmt .Sprintf ("%s:%s/" , GetHostnameOrIp (host ), workspace )); err != nil {
88
+ if output , err := runSSHCommand ("scp" , archive , fmt .Sprintf ("%s:%s/" , GetHostnameOrIP (host ), workspace )); err != nil {
88
89
// Exit failure with the error
89
90
return "" , false , fmt .Errorf ("failed to copy test archive: %v, output: %q" , err , output )
90
91
}
@@ -110,7 +111,7 @@ func RunRemote(suite TestSuite, archive string, host string, cleanup bool, image
110
111
}
111
112
112
113
klog .V (2 ).Infof ("Running test on %q" , host )
113
- output , err := suite .RunTest (host , workspace , resultDir , imageDesc , junitFilePrefix , testArgs , ginkgoArgs , systemSpecName , extraEnvs , * testTimeoutSeconds )
114
+ output , err := suite .RunTest (host , workspace , resultDir , imageDesc , junitFilePrefix , testArgs , ginkgoArgs , systemSpecName , extraEnvs , * testTimeout )
114
115
115
116
aggErrs := []error {}
116
117
// Do not log the output here, let the caller deal with the test output.
@@ -143,7 +144,7 @@ func newWorkspaceDir() string {
143
144
return filepath .Join ("/tmp" , workspaceDirPrefix + getTimestamp ())
144
145
}
145
146
146
- // Parses the workspace directory name and gets the timestamp part of it.
147
+ // GetTimestampFromWorkspaceDir parses the workspace directory name and gets the timestamp part of it.
147
148
// This can later be used to name other artifacts (such as the
148
149
// kubelet-${instance}.service systemd transient service used to launch
149
150
// Kubelet) so that they can be matched to each other.
@@ -163,18 +164,18 @@ func getTestArtifacts(host, testDir string) error {
163
164
return fmt .Errorf ("failed to create log directory %q: %v" , logPath , err )
164
165
}
165
166
// Copy logs to artifacts/hostname
166
- if _ , err := runSSHCommand ("scp" , "-r" , fmt .Sprintf ("%s:%s/results/*.log" , GetHostnameOrIp (host ), testDir ), logPath ); err != nil {
167
+ if _ , err := runSSHCommand ("scp" , "-r" , fmt .Sprintf ("%s:%s/results/*.log" , GetHostnameOrIP (host ), testDir ), logPath ); err != nil {
167
168
return err
168
169
}
169
170
// Copy json files (if any) to artifacts.
170
171
if _ , err := SSH (host , "ls" , fmt .Sprintf ("%s/results/*.json" , testDir )); err == nil {
171
- if _ , err = runSSHCommand ("scp" , "-r" , fmt .Sprintf ("%s:%s/results/*.json" , GetHostnameOrIp (host ), testDir ), * resultsDir ); err != nil {
172
+ if _ , err = runSSHCommand ("scp" , "-r" , fmt .Sprintf ("%s:%s/results/*.json" , GetHostnameOrIP (host ), testDir ), * resultsDir ); err != nil {
172
173
return err
173
174
}
174
175
}
175
176
if _ , err := SSH (host , "ls" , fmt .Sprintf ("%s/results/junit*" , testDir )); err == nil {
176
177
// Copy junit (if any) to the top of artifacts
177
- if _ , err = runSSHCommand ("scp" , fmt .Sprintf ("%s:%s/results/junit*" , GetHostnameOrIp (host ), testDir ), * resultsDir ); err != nil {
178
+ if _ , err = runSSHCommand ("scp" , fmt .Sprintf ("%s:%s/results/junit*" , GetHostnameOrIP (host ), testDir ), * resultsDir ); err != nil {
178
179
return err
179
180
}
180
181
}
@@ -200,7 +201,7 @@ func collectSystemLog(host string) {
200
201
// it could've be been removed if the node was rebooted.
201
202
if output , err := SSH (host , "sh" , "-c" , fmt .Sprintf ("'journalctl --system --all > %s'" , logPath )); err == nil {
202
203
klog .V (2 ).Infof ("Got the system logs from journald; copying it back..." )
203
- if output , err := runSSHCommand ("scp" , fmt .Sprintf ("%s:%s" , GetHostnameOrIp (host ), logPath ), destPath ); err != nil {
204
+ if output , err := runSSHCommand ("scp" , fmt .Sprintf ("%s:%s" , GetHostnameOrIP (host ), logPath ), destPath ); err != nil {
204
205
klog .V (2 ).Infof ("Failed to copy the log: err: %v, output: %q" , err , output )
205
206
}
206
207
} else {
0 commit comments