...
1
16
17 package remote
18
19 import (
20 "fmt"
21 )
22
23 var _ Runner = (*SSHRunner)(nil)
24
25 type SSHRunner struct {
26 cfg Config
27 }
28
29 func (s *SSHRunner) StartTests(suite TestSuite, archivePath string, results chan *TestResult) (numTests int) {
30 for _, host := range s.cfg.Hosts {
31 fmt.Printf("Initializing e2e tests using host %s.\n", host)
32 numTests++
33 go func(host string, junitFileName string) {
34 output, exitOk, err := RunRemote(RunRemoteConfig{
35 Suite: suite,
36 Archive: archivePath,
37 Host: host,
38 Cleanup: s.cfg.Cleanup,
39 ImageDesc: "",
40 JunitFileName: junitFileName,
41 TestArgs: s.cfg.TestArgs,
42 GinkgoArgs: s.cfg.GinkgoFlags,
43 SystemSpecName: s.cfg.SystemSpecName,
44 ExtraEnvs: s.cfg.ExtraEnvs,
45 RuntimeConfig: s.cfg.RuntimeConfig,
46 })
47 results <- &TestResult{
48 Output: output,
49 Err: err,
50 Host: host,
51 ExitOK: exitOk,
52 }
53 }(host, host)
54 }
55 return
56 }
57
58 func NewSSHRunner(cfg Config) Runner {
59 return &SSHRunner{
60 cfg: cfg,
61 }
62 }
63
64 func (s *SSHRunner) Validate() error {
65 if len(s.cfg.Hosts) == 0 {
66 return fmt.Errorf("must specify --hosts when running ssh")
67 }
68 if s.cfg.ImageConfigFile != "" {
69 return fmt.Errorf("must not specify --image-config-file when running ssh")
70 }
71 if len(s.cfg.Images) > 0 {
72 return fmt.Errorf("must not specify --images when running ssh")
73 }
74 return nil
75 }
76
View as plain text