From 4298299535aebb2b217c042e2a8e38aededd4392 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Mon, 12 Aug 2019 16:44:39 -0700 Subject: [PATCH] Output junit to ARTIFACTS for testgrid --- hack/run-e2e-test | 2 +- tests/e2e/suite_test.go | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hack/run-e2e-test b/hack/run-e2e-test index cf5e269793..66c7e5de19 100755 --- a/hack/run-e2e-test +++ b/hack/run-e2e-test @@ -98,7 +98,7 @@ helm install --name aws-ebs-csi-driver \ # Run the test go get -u github.com/onsi/ginkgo/ginkgo export KUBECONFIG=$HOME/.kube/config -ginkgo -p -nodes=$NODES -v --focus="$FOCUS" tests/e2e +ginkgo -p -nodes=$NODES -v --focus="$FOCUS" tests/e2e -- -report-dir=$ARTIFACTS TEST_PASS=$? echo "Removing driver" diff --git a/tests/e2e/suite_test.go b/tests/e2e/suite_test.go index f842542011..68a25416d8 100644 --- a/tests/e2e/suite_test.go +++ b/tests/e2e/suite_test.go @@ -15,12 +15,19 @@ limitations under the License. package e2e import ( + "fmt" + "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/reporters" + "log" "os" + "path" "path/filepath" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/kubernetes/test/e2e/framework" ) @@ -39,5 +46,17 @@ func init() { func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "AWS EBS CSI Driver End-to-End Tests") + + // Run tests through the Ginkgo runner with output to console + JUnit for Jenkins + var r []Reporter + if framework.TestContext.ReportDir != "" { + if err := os.MkdirAll(framework.TestContext.ReportDir, 0755); err != nil { + log.Fatalf("Failed creating report directory: %v", err) + } else { + r = append(r, reporters.NewJUnitReporter(path.Join(framework.TestContext.ReportDir, fmt.Sprintf("junit_%v%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)))) + } + } + log.Printf("Starting e2e run %q on Ginkgo node %d", uuid.NewUUID(), config.GinkgoConfig.ParallelNode) // TODO use framework.RunID like upstream + + RunSpecsWithDefaultAndCustomReporters(t, "AWS EBS CSI Driver End-to-End Tests", r) }