From 41f5b0b765a77f9b4cc8b5df6564a680d8fc4c37 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Thu, 17 Dec 2015 10:45:29 -0800 Subject: [PATCH] Node e2e test - propagate errors from tests to runner exit code. --- test/e2e_node/runner/run_e2e.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/e2e_node/runner/run_e2e.go b/test/e2e_node/runner/run_e2e.go index 88c403c9571..2e6921ba54c 100644 --- a/test/e2e_node/runner/run_e2e.go +++ b/test/e2e_node/runner/run_e2e.go @@ -77,9 +77,9 @@ func main() { u.Add(1) } - w := sync.WaitGroup{} - for _, h := range strings.Split(*hosts, ",") { - w.Add(1) + results := make(chan error) + hs := strings.Split(*hosts, ",") + for _, h := range hs { go func(host string) { out, err := runTests(host) if err != nil { @@ -87,7 +87,7 @@ func main() { } else { glog.Infof("Success Finished Host %s Test Suite %s", host, out) } - w.Done() + results <- err }(h) } @@ -96,9 +96,19 @@ func main() { WaitForUser() } - // Wait for the tests to finish - w.Wait() - glog.Infof("Done") + // Wait for all tests to complete and check for failures + errCount := 0 + for i := 0; i < len(hs); i++ { + if <-results != nil { + errCount++ + } + } + + // Set the exit code if there were failures + if errCount > 0 { + glog.Errorf("Failure: %d errors encountered.", errCount) + os.Exit(1) + } } func WaitForUser() {