diff --git a/.gitignore b/.gitignore index 3e8fe105e48..78ef71d8fce 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ Session.vim *.test /hack/.test-cmd-auth +# JUnit test output from ginkgo e2e tests +/junit*.xml + # Mercurial files **/.hg **/.hg* diff --git a/cmd/e2e/e2e.go b/cmd/e2e/e2e.go index becbf9abd90..1cada546ab6 100644 --- a/cmd/e2e/e2e.go +++ b/cmd/e2e/e2e.go @@ -29,6 +29,7 @@ import ( var ( authConfig = flag.String("auth_config", os.Getenv("HOME")+"/.kubernetes_auth", "Path to the auth info file.") certDir = flag.String("cert_dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.") + reportDir = flag.String("report_dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.") host = flag.String("host", "", "The host to connect to") repoRoot = flag.String("repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root") provider = flag.String("provider", "", "The name of the Kubernetes provider") @@ -52,5 +53,5 @@ func main() { glog.Error("Invalid --times (negative or no testing requested)!") os.Exit(1) } - e2e.RunE2ETests(*authConfig, *certDir, *host, *repoRoot, *provider, *orderseed, *times, testList) + e2e.RunE2ETests(*authConfig, *certDir, *host, *repoRoot, *provider, *orderseed, *times, *reportDir, testList) } diff --git a/test/e2e/driver.go b/test/e2e/driver.go index 58882516295..95ca1643b5c 100644 --- a/test/e2e/driver.go +++ b/test/e2e/driver.go @@ -17,12 +17,14 @@ limitations under the License. package e2e import ( + "path" "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/reporters" "github.com/onsi/gomega" ) @@ -32,7 +34,7 @@ func (t *testResult) Fail() { *t = false } // Run each Go end-to-end-test. This function assumes the // creation of a test cluster. -func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, orderseed int64, times int, testList []string) { +func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, orderseed int64, times int, reportDir string, testList []string) { testContext = testContextType{authConfig, certDir, host, repoRoot, provider} util.ReallyCrash = true util.InitLogs() @@ -57,7 +59,14 @@ func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, orderseed gomega.RegisterFailHandler(ginkgo.Fail) // Turn of colors for now to make it easier to collect console output in Jenkins config.DefaultReporterConfig.NoColor = true - ginkgo.RunSpecs(&passed, "Kubernetes e2e Suite") + var r []ginkgo.Reporter + if reportDir != "" { + // TODO: When we start using parallel tests we need to change this to "junit_%d.xml", + // see ginkgo docs for more details. + r = append(r, reporters.NewJUnitReporter(path.Join(reportDir, "junit.xml"))) + } + // Run the existing tests with output to console + JUnit for Jenkins + ginkgo.RunSpecsWithDefaultAndCustomReporters(&passed, "Kubernetes e2e Suite", r) if !passed { glog.Fatalf("At least one test failed")