diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index d2cc23a090e..a82e99b0a76 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -104,10 +104,6 @@ func RunE2ETests(t *testing.T) { defer logs.FlushLogs() progressReporter = e2ereporters.NewProgressReporter(framework.TestContext.ProgressReportURL) gomega.RegisterFailHandler(framework.Fail) - // Disable skipped tests unless they are explicitly requested. - if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" { - config.GinkgoConfig.SkipString = `\[Flaky\]|\[Feature:.+\]` - } // Run tests through the Ginkgo runner with output to console + JUnit for Jenkins var r []ginkgo.Reporter @@ -121,8 +117,9 @@ func RunE2ETests(t *testing.T) { } } - klog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunID, config.GinkgoConfig.ParallelNode) - ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r) + suiteConfig, reporterConfig := framework.CreateGinkgoConfig() + klog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunID, suiteConfig.ParallelProcess) + ginkgo.RunSpecs(t, "Kubernetes e2e suite", suiteConfig, reporterConfig) } // getDefaultClusterIPFamily obtains the default IP family of the cluster diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 53fbd523495..6ce9d55865f 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -28,7 +28,8 @@ import ( "strings" "time" - "github.com/onsi/ginkgo/v2/config" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" @@ -276,15 +277,6 @@ func (tc TestContextType) ClusterIsIPv6() bool { // options themselves, copy flags from test/e2e/framework/config // as shown in HandleFlags. func RegisterCommonFlags(flags *flag.FlagSet) { - // Turn on verbose by default to get spec names - config.DefaultReporterConfig.Verbose = true - - // Turn on EmitSpecProgress to get spec progress (especially on interrupt) - config.GinkgoConfig.EmitSpecProgress = true - - // Randomize specs as well as suites - config.GinkgoConfig.RandomizeAllSpecs = true - flags.StringVar(&TestContext.GatherKubeSystemResourceUsageData, "gather-resource-usage", "false", "If set to 'true' or 'all' framework will be monitoring resource usage of system all add-ons in (some) e2e tests, if set to 'master' framework will be monitoring master node only, if set to 'none' of 'false' monitoring will be turned off.") flags.BoolVar(&TestContext.GatherLogsSizes, "gather-logs-sizes", false, "If set to true framework will be monitoring logs sizes on all machines running e2e tests.") flags.IntVar(&TestContext.MaxNodesToGather, "max-nodes-to-gather-from", 20, "The maximum number of nodes to gather extended info from on test failure.") @@ -327,6 +319,22 @@ func RegisterCommonFlags(flags *flag.FlagSet) { flags.IntVar(&TestContext.SnapshotControllerHTTPPort, "snapshot-controller-http-port", 0, "The port to use for snapshot controller HTTP communication.") } +func CreateGinkgoConfig() (types.SuiteConfig, types.ReporterConfig) { + // fetch the current config + suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() + // Turn on EmitSpecProgress to get spec progress (especially on interrupt) + suiteConfig.EmitSpecProgress = true + // Randomize specs as well as suites + suiteConfig.RandomizeAllSpecs = true + // Turn on verbose by default to get spec names + reporterConfig.Verbose = true + // Disable skipped tests unless they are explicitly requested. + if len(suiteConfig.FocusStrings) == 0 && len(suiteConfig.SkipStrings) == 0 { + suiteConfig.SkipStrings = []string{`\[Flaky\]|\[Feature:.+\]`} + } + return suiteConfig, reporterConfig +} + // RegisterClusterFlags registers flags specific to the cluster e2e test suite. func RegisterClusterFlags(flags *flag.FlagSet) { flags.BoolVar(&TestContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.") diff --git a/test/e2e_kubeadm/e2e_kubeadm_suite_test.go b/test/e2e_kubeadm/e2e_kubeadm_suite_test.go index 2bfb4f5258f..6b32cd9550f 100644 --- a/test/e2e_kubeadm/e2e_kubeadm_suite_test.go +++ b/test/e2e_kubeadm/e2e_kubeadm_suite_test.go @@ -59,5 +59,6 @@ func TestE2E(t *testing.T) { reporters = append(reporters, morereporters.NewJUnitReporter(junitPath)) } } - ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "E2EKubeadm suite", reporters) + suiteConfig, reporterConfig := framework.CreateGinkgoConfig() + ginkgo.RunSpecs(t, "E2EKubeadm suite", suiteConfig, reporterConfig) } diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index 7220dda1d97..747cb85f05f 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -192,7 +192,8 @@ func TestE2eNode(t *testing.T) { reporters = append(reporters, morereporters.NewJUnitReporter(junitPath)) } } - ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "E2eNode Suite", reporters) + suiteConfig, reporterConfig := framework.CreateGinkgoConfig() + ginkgo.RunSpecs(t, "E2eNode Suite", suiteConfig, reporterConfig) } // Setup the kubelet on the node