Merge pull request #76282 from fabriziopandini/kubeadm-e2e-JUnitReporter

Add JUnitReporter to kubeadm e2e test
This commit is contained in:
Kubernetes Prow Robot 2019-04-08 17:27:40 -07:00 committed by GitHub
commit 2d0e5c1818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -34,6 +34,8 @@ go_test(
"//staging/src/k8s.io/cluster-bootstrap/token/api:go_default_library",
"//test/e2e/framework:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
"//vendor/github.com/onsi/ginkgo/reporters:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/gopkg.in/yaml.v2:go_default_library",

View File

@ -18,13 +18,17 @@ package e2e_kubeadm
import (
"flag"
"fmt"
"os"
"path/filepath"
"testing"
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/gomega"
"github.com/spf13/pflag"
morereporters "github.com/onsi/ginkgo/reporters"
"k8s.io/kubernetes/test/e2e/framework"
)
@ -42,7 +46,19 @@ func TestMain(m *testing.M) {
}
func TestE2E(t *testing.T) {
reporters := []ginkgo.Reporter{}
gomega.RegisterFailHandler(ginkgo.Fail)
reporters := []ginkgo.Reporter{}
reportDir := framework.TestContext.ReportDir
if reportDir != "" {
// Create the directory if it doesn't already exists
if err := os.MkdirAll(reportDir, 0755); err != nil {
t.Fatalf("Failed creating report directory: %v", err)
} else {
// Configure a junit reporter to write to the directory
junitFile := fmt.Sprintf("junit_%s_%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode)
junitPath := filepath.Join(reportDir, junitFile)
reporters = append(reporters, morereporters.NewJUnitReporter(junitPath))
}
}
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "E2EKubeadm suite", reporters)
}