Run the runner
(tests []TestCase)
| 14 | |
| 15 | // Run the runner |
| 16 | func (r *Runner) Run(tests []TestCase) <-chan TestResult { |
| 17 | in := make(chan TestCase) |
| 18 | out := make(chan TestResult) |
| 19 | |
| 20 | go func(tests []TestCase) { |
| 21 | defer close(in) |
| 22 | for _, t := range tests { |
| 23 | in <- t |
| 24 | } |
| 25 | }(tests) |
| 26 | |
| 27 | var wg sync.WaitGroup |
| 28 | wg.Add(1) |
| 29 | |
| 30 | go func(tests chan TestCase) { |
| 31 | defer wg.Done() |
| 32 | |
| 33 | for t := range tests { |
| 34 | // If no node was set use local mode as default |
| 35 | if len(t.Nodes) == 0 { |
| 36 | t.Nodes = []string{"local"} |
| 37 | } |
| 38 | |
| 39 | for _, n := range t.Nodes { |
| 40 | result := TestResult{} |
| 41 | for i := 1; i <= t.Command.GetRetries(); i++ { |
| 42 | |
| 43 | if t.Skip { |
| 44 | result = TestResult{TestCase: t, Skipped: true, Node: n} |
| 45 | break |
| 46 | } |
| 47 | |
| 48 | e := r.getExecutor(n) |
| 49 | result = e.Execute(t) |
| 50 | result.Node = n |
| 51 | result.Tries = i |
| 52 | |
| 53 | if result.ValidationResult.Success { |
| 54 | break |
| 55 | } |
| 56 | |
| 57 | executeRetryInterval(t) |
| 58 | } |
| 59 | out <- result |
| 60 | } |
| 61 | } |
| 62 | }(in) |
| 63 | |
| 64 | go func(results chan TestResult) { |
| 65 | wg.Wait() |
| 66 | close(results) |
| 67 | }(out) |
| 68 | |
| 69 | return out |
| 70 | } |
| 71 | |
| 72 | // getExecutor gets the node by the name it matches within the runner config |
| 73 | func (r *Runner) getExecutor(node string) Executor { |