Merge pull request #30107 from Random-Liu/fix-node-e2e-junit

Automatic merge from submit-queue

Node E2E: Change the node e2e junit file name to junit_{image-name}{test-node-number}.xml

Fixes https://github.com/kubernetes/kubernetes/issues/30103.

Reuse the `report-prefix` in e2e test framework. Now the junit file will be like: `junit_{image-name}{test-node-number}.xml`.

Mark P2 to fix the test result.

/cc @rmmh
pull/6/head
Kubernetes Submit Queue 2016-08-04 23:02:50 -07:00 committed by GitHub
commit e4f70cb83f
4 changed files with 16 additions and 16 deletions

View File

@ -106,6 +106,7 @@ func RegisterCommonFlags() {
flag.BoolVar(&TestContext.DumpLogsOnFailure, "dump-logs-on-failure", true, "If set to true test will dump data about the namespace in which test was running.")
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.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
}
// Register flags specific to the cluster e2e test suite.
@ -123,7 +124,6 @@ func RegisterClusterFlags() {
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.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.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
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.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, trusty, or coreos).")

View File

@ -42,6 +42,7 @@ import (
"github.com/golang/glog"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
more_reporters "github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
)
@ -70,7 +71,6 @@ var e2es *e2eService
var context SharedContext
var prePullImages = flag.Bool("prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.")
var junitFileNumber = flag.Int("junit-file-number", 1, "Used to create junit filename - e.g. junit_01.xml.")
func init() {
framework.RegisterCommonFlags()
@ -89,7 +89,7 @@ func TestE2eNode(t *testing.T) {
glog.Errorf("Failed creating report directory: %v", err)
} else {
// Configure a junit reporter to write to the directory
junitFile := fmt.Sprintf("junit_%02d.xml", *junitFileNumber)
junitFile := fmt.Sprintf("junit_%s%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
junitPath := path.Join(*reportDir, junitFile)
reporters = append(reporters, more_reporters.NewJUnitReporter(junitPath))
}

View File

@ -146,7 +146,7 @@ func CreateTestArchive() (string, error) {
}
// Returns the command output, whether the exit was ok, and any errors
func RunRemote(archive string, host string, cleanup bool, junitFileNumber int, setupNode bool, testArgs string) (string, bool, error) {
func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string, setupNode bool, testArgs string) (string, bool, error) {
if setupNode {
uname, err := user.Current()
if err != nil {
@ -214,7 +214,7 @@ func RunRemote(archive string, host string, cleanup bool, junitFileNumber int, s
// Run the tests
cmd = getSshCommand(" && ",
fmt.Sprintf("cd %s", tmp),
fmt.Sprintf("timeout -k 30s %ds ./ginkgo %s ./e2e_node.test -- --logtostderr --v 2 --build-services=false --stop-services=%t --node-name=%s --report-dir=%s/results --junit-file-number=%d %s", *testTimeoutSeconds, *ginkgoFlags, cleanup, host, tmp, junitFileNumber, testArgs),
fmt.Sprintf("timeout -k 30s %ds ./ginkgo %s ./e2e_node.test -- --logtostderr --v 2 --build-services=false --stop-services=%t --node-name=%s --report-dir=%s/results --report-prefix=%s %s", *testTimeoutSeconds, *ginkgoFlags, cleanup, host, tmp, junitFilePrefix, testArgs),
)
aggErrs := []error{}

View File

@ -194,19 +194,19 @@ func main() {
running := 0
for shortName := range gceImages.images {
imageConfig := gceImages.images[shortName]
running++
fmt.Printf("Initializing e2e tests using image %s.\n", shortName)
go func(image *internalGCEImage, junitFileNum int) {
results <- testImage(image, junitFileNum)
}(&imageConfig, running)
running++
go func(image *internalGCEImage, junitFilePrefix string) {
results <- testImage(image, junitFilePrefix)
}(&imageConfig, shortName)
}
if *hosts != "" {
for _, host := range strings.Split(*hosts, ",") {
fmt.Printf("Initializing e2e tests using host %s.\n", host)
running++
go func(host string, junitFileNum int) {
results <- testHost(host, *cleanup, junitFileNum, *setupNode)
}(host, running)
go func(host string, junitFilePrefix string) {
results <- testHost(host, *cleanup, junitFilePrefix, *setupNode)
}(host, host)
}
}
@ -267,7 +267,7 @@ func getImageMetadata(input string) *compute.Metadata {
}
// Run tests in archive against host
func testHost(host string, deleteFiles bool, junitFileNum int, setupNode bool) *TestResult {
func testHost(host string, deleteFiles bool, junitFilePrefix string, setupNode bool) *TestResult {
instance, err := computeService.Instances.Get(*project, *zone, host).Do()
if err != nil {
return &TestResult{
@ -297,7 +297,7 @@ func testHost(host string, deleteFiles bool, junitFileNum int, setupNode bool) *
}
}
output, exitOk, err := e2e_node.RunRemote(path, host, deleteFiles, junitFileNum, setupNode, *testArgs)
output, exitOk, err := e2e_node.RunRemote(path, host, deleteFiles, junitFilePrefix, setupNode, *testArgs)
return &TestResult{
output: output,
err: err,
@ -308,7 +308,7 @@ func testHost(host string, deleteFiles bool, junitFileNum int, setupNode bool) *
// Provision a gce instance using image and run the tests in archive against the instance.
// Delete the instance afterward.
func testImage(image *internalGCEImage, junitFileNum int) *TestResult {
func testImage(image *internalGCEImage, junitFilePrefix string) *TestResult {
host, err := createInstance(image)
if *deleteInstances {
defer deleteInstance(image.image)
@ -322,7 +322,7 @@ func testImage(image *internalGCEImage, junitFileNum int) *TestResult {
// Only delete the files if we are keeping the instance and want it cleaned up.
// If we are going to delete the instance, don't bother with cleaning up the files
deleteFiles := !*deleteInstances && *cleanup
return testHost(host, deleteFiles, junitFileNum, *setupNode)
return testHost(host, deleteFiles, junitFilePrefix, *setupNode)
}
// Provision a gce instance using image