Skip to content

Commit

Permalink
Generate JUnit XML for Jenkins from the Go e2e tests
Browse files Browse the repository at this point in the history
Use ginkgo's native support for JUnit in order to generate the XML file.

This is a first step in better integration of our e2e tests with
Jenkins. In order to improve the logged information, we will probably
need to have more native ginkgo tests but this step allows us to see
what Jenkins can already do with this information and what we need to
tweak to improve it.

Tested by running the full e2e tests and inspecting the contents of
junit.xml on the top of the tree.

Textual output is still generated on the console to keep the current
goe2e.sh logs available until the full conversion of our Jenkins
instance to use the JUnit XML is completed.
  • Loading branch information
filbranden committed Jan 28, 2015
1 parent 1c028de commit bd79d00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Session.vim
*.test
/hack/.test-cmd-auth

# JUnit test output from ginkgo e2e tests
/junit*.xml

# Mercurial files
**/.hg
**/.hg*
Expand Down
3 changes: 2 additions & 1 deletion cmd/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
13 changes: 11 additions & 2 deletions test/e2e/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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()
Expand All @@ -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")
Expand Down

0 comments on commit bd79d00

Please sign in to comment.