mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #30114 from Random-Liu/use-framework-report-dir
Automatic merge from submit-queue Use report-dir in test framework instead. We already have `report-dir` option in framework test context. The node e2e framework should use it as well. /cc @ronnielai
This commit is contained in:
commit
4d70d9f3de
@ -109,6 +109,7 @@ func RegisterCommonFlags() {
|
|||||||
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
|
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
|
||||||
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")
|
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")
|
||||||
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
||||||
|
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register flags specific to the cluster e2e test suite.
|
// Register flags specific to the cluster e2e test suite.
|
||||||
@ -125,7 +126,6 @@ func RegisterClusterFlags() {
|
|||||||
flag.StringVar(&TestContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")
|
flag.StringVar(&TestContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")
|
||||||
flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
|
flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
|
||||||
flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
|
flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
|
||||||
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
|
||||||
flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")
|
flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")
|
||||||
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker or rkt).")
|
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker or rkt).")
|
||||||
flag.StringVar(&TestContext.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, trusty, or coreos).")
|
flag.StringVar(&TestContext.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, trusty, or coreos).")
|
||||||
|
@ -83,14 +83,15 @@ func TestE2eNode(t *testing.T) {
|
|||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
reporters := []Reporter{}
|
reporters := []Reporter{}
|
||||||
if *reportDir != "" {
|
reportDir := framework.TestContext.ReportDir
|
||||||
|
if reportDir != "" {
|
||||||
// Create the directory if it doesn't already exists
|
// Create the directory if it doesn't already exists
|
||||||
if err := os.MkdirAll(*reportDir, 0755); err != nil {
|
if err := os.MkdirAll(reportDir, 0755); err != nil {
|
||||||
glog.Errorf("Failed creating report directory: %v", err)
|
glog.Errorf("Failed creating report directory: %v", err)
|
||||||
} else {
|
} else {
|
||||||
// Configure a junit reporter to write to the directory
|
// Configure a junit reporter to write to the directory
|
||||||
junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
|
junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
|
||||||
junitPath := path.Join(*reportDir, junitFile)
|
junitPath := path.Join(reportDir, junitFile)
|
||||||
reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
|
reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
var serverStartTimeout = flag.Duration("server-start-timeout", time.Second*120, "Time to wait for each server to become healthy.")
|
var serverStartTimeout = flag.Duration("server-start-timeout", time.Second*120, "Time to wait for each server to become healthy.")
|
||||||
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 e2eService struct {
|
type e2eService struct {
|
||||||
killCmds []*killCmd
|
killCmds []*killCmd
|
||||||
@ -113,12 +114,12 @@ func (es *e2eService) start() error {
|
|||||||
// Since we scp files from the remote directory, symlinks will be treated as normal files and file contents will be copied over.
|
// Since we scp files from the remote directory, symlinks will be treated as normal files and file contents will be copied over.
|
||||||
func (es *e2eService) getLogFiles() {
|
func (es *e2eService) getLogFiles() {
|
||||||
// Nothing to do if report dir is not specified.
|
// Nothing to do if report dir is not specified.
|
||||||
if *reportDir == "" {
|
if framework.TestContext.ReportDir == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
journaldFound := isJournaldAvailable()
|
journaldFound := isJournaldAvailable()
|
||||||
for targetFileName, logFileData := range es.logFiles {
|
for targetFileName, logFileData := range es.logFiles {
|
||||||
targetLink := path.Join(*reportDir, targetFileName)
|
targetLink := path.Join(framework.TestContext.ReportDir, targetFileName)
|
||||||
if journaldFound {
|
if journaldFound {
|
||||||
// Skip log files that do not have an equivalent in journald based machines.
|
// Skip log files that do not have an equivalent in journald based machines.
|
||||||
if len(logFileData.journalctlCommand) == 0 {
|
if len(logFileData.journalctlCommand) == 0 {
|
||||||
@ -298,7 +299,7 @@ func (es *e2eService) startServer(cmd *healthCheckCommand) error {
|
|||||||
defer close(cmdErrorChan)
|
defer close(cmdErrorChan)
|
||||||
|
|
||||||
// Create the output filename
|
// Create the output filename
|
||||||
outPath := path.Join(*reportDir, cmd.outputFilename)
|
outPath := path.Join(framework.TestContext.ReportDir, cmd.outputFilename)
|
||||||
outfile, err := os.Create(outPath)
|
outfile, err := os.Create(outPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmdErrorChan <- fmt.Errorf("Failed to create file %s for `%s` %v.", outPath, cmd, err)
|
cmdErrorChan <- fmt.Errorf("Failed to create file %s for `%s` %v.", outPath, cmd, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user