mirror of https://github.com/k3s-io/k3s
kubeadm-e2e-JUnitReporter
parent
e47fc04adc
commit
0c4031f3a6
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue