From 7fd2319ca77d8f2c3f0e00853998d86687d1c39b Mon Sep 17 00:00:00 2001 From: Random-Liu Date: Thu, 4 Aug 2016 15:50:35 -0700 Subject: [PATCH] Change the node e2e junit file name to junit_{image-name}{test-node-number}.xml --- test/e2e/framework/test_context.go | 2 +- test/e2e_node/e2e_node_suite_test.go | 4 ++-- test/e2e_node/e2e_remote.go | 4 ++-- test/e2e_node/runner/run_e2e.go | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 25b4d065121..2f0d5b6cf0d 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -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).") diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index 2a93ab938bb..1bd79019e33 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -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)) } diff --git a/test/e2e_node/e2e_remote.go b/test/e2e_node/e2e_remote.go index f5d6d455563..cd2da3fc0cc 100644 --- a/test/e2e_node/e2e_remote.go +++ b/test/e2e_node/e2e_remote.go @@ -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{} diff --git a/test/e2e_node/runner/run_e2e.go b/test/e2e_node/runner/run_e2e.go index 4d6612e905d..489d39a4830 100644 --- a/test/e2e_node/runner/run_e2e.go +++ b/test/e2e_node/runner/run_e2e.go @@ -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