Merge pull request #8852 from brendandburns/core
Add a 'core dump' to failed tests.
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
@@ -66,6 +67,22 @@ var (
|
||||
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.")
|
||||
)
|
||||
|
||||
type failReporter struct {
|
||||
failed bool
|
||||
}
|
||||
|
||||
func (f *failReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
|
||||
}
|
||||
func (f *failReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {}
|
||||
func (f *failReporter) SpecWillRun(specSummary *types.SpecSummary) {}
|
||||
func (f *failReporter) SpecDidComplete(specSummary *types.SpecSummary) {
|
||||
if specSummary.Failed() {
|
||||
f.failed = true
|
||||
}
|
||||
}
|
||||
func (f *failReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {}
|
||||
func (f *failReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {}
|
||||
|
||||
func init() {
|
||||
// Turn on verbose by default to get spec names
|
||||
config.DefaultReporterConfig.Verbose = true
|
||||
@@ -120,7 +137,6 @@ func TestE2E(t *testing.T) {
|
||||
if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" {
|
||||
config.GinkgoConfig.SkipString = "Skipped"
|
||||
}
|
||||
|
||||
gomega.RegisterFailHandler(ginkgo.Fail)
|
||||
|
||||
// Ensure all pods are running and ready before starting tests (otherwise,
|
||||
@@ -135,6 +151,13 @@ func TestE2E(t *testing.T) {
|
||||
var r []ginkgo.Reporter
|
||||
if *reportDir != "" {
|
||||
r = append(r, reporters.NewJUnitReporter(path.Join(*reportDir, fmt.Sprintf("junit_%02d.xml", config.GinkgoConfig.ParallelNode))))
|
||||
failReport := &failReporter{}
|
||||
r = append(r, failReport)
|
||||
defer func() {
|
||||
if failReport.failed {
|
||||
coreDump(*reportDir)
|
||||
}
|
||||
}()
|
||||
}
|
||||
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user