mirror of https://github.com/k3s-io/k3s
Merge pull request #10574 from ixdy/coredump-always
e2e: call coreDump always when a report dir is specifiedpull/6/head
commit
b27da05ce6
|
@ -19,6 +19,7 @@ package e2e
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -32,7 +33,6 @@ import (
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/ginkgo/config"
|
"github.com/onsi/ginkgo/config"
|
||||||
"github.com/onsi/ginkgo/reporters"
|
"github.com/onsi/ginkgo/reporters"
|
||||||
"github.com/onsi/ginkgo/types"
|
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,22 +49,6 @@ 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.")
|
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() {
|
func init() {
|
||||||
// Turn on verbose by default to get spec names
|
// Turn on verbose by default to get spec names
|
||||||
config.DefaultReporterConfig.Verbose = true
|
config.DefaultReporterConfig.Verbose = true
|
||||||
|
@ -102,6 +86,12 @@ func TestE2E(t *testing.T) {
|
||||||
util.ReallyCrash = true
|
util.ReallyCrash = true
|
||||||
util.InitLogs()
|
util.InitLogs()
|
||||||
defer util.FlushLogs()
|
defer util.FlushLogs()
|
||||||
|
if *reportDir != "" {
|
||||||
|
if err := os.MkdirAll(*reportDir, 0755); err != nil {
|
||||||
|
glog.Errorf("Failed creating report directory: %v", err)
|
||||||
|
}
|
||||||
|
defer coreDump(*reportDir)
|
||||||
|
}
|
||||||
|
|
||||||
if testContext.Provider == "" {
|
if testContext.Provider == "" {
|
||||||
glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.")
|
glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.")
|
||||||
|
@ -137,19 +127,13 @@ func TestE2E(t *testing.T) {
|
||||||
// test pods from running, and tests that ensure all pods are running and
|
// test pods from running, and tests that ensure all pods are running and
|
||||||
// ready will fail).
|
// ready will fail).
|
||||||
if err := waitForPodsRunningReady(api.NamespaceDefault, testContext.MinStartupPods, podStartupTimeout); err != nil {
|
if err := waitForPodsRunningReady(api.NamespaceDefault, testContext.MinStartupPods, podStartupTimeout); err != nil {
|
||||||
glog.Fatalf("Error waiting for all pods to be running and ready: %v", err)
|
t.Errorf("Error waiting for all pods to be running and ready: %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// Run tests through the Ginkgo runner with output to console + JUnit for Jenkins
|
// Run tests through the Ginkgo runner with output to console + JUnit for Jenkins
|
||||||
var r []ginkgo.Reporter
|
var r []ginkgo.Reporter
|
||||||
if *reportDir != "" {
|
if *reportDir != "" {
|
||||||
r = append(r, reporters.NewJUnitReporter(path.Join(*reportDir, fmt.Sprintf("junit_%02d.xml", config.GinkgoConfig.ParallelNode))))
|
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)
|
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue