mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Generate JUnit XML for Jenkins from the Go e2e tests
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.
This commit is contained in:
parent
1c028de03a
commit
bd79d00e22
3
.gitignore
vendored
3
.gitignore
vendored
@ -26,6 +26,9 @@ Session.vim
|
||||
*.test
|
||||
/hack/.test-cmd-auth
|
||||
|
||||
# JUnit test output from ginkgo e2e tests
|
||||
/junit*.xml
|
||||
|
||||
# Mercurial files
|
||||
**/.hg
|
||||
**/.hg*
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user