From 46c7604ee57584330ec49610bfaa07cd2942eb46 Mon Sep 17 00:00:00 2001 From: Xin Zhang Date: Tue, 3 Dec 2024 09:51:06 +0800 Subject: [PATCH] Upgrade ginkgo to v2.11.0 (#2284) Signed-off-by: nce3xin <249424562@qq.com> --- go.mod | 6 +- go.sum | 6 +- test/e2e/README.md | 4 +- test/e2e/e2e.go | 32 +------- test/e2e/e2e_test.go | 2 +- test/e2e/framework/framework.go | 4 +- test/e2e/framework/ginkgowrapper/wrapper.go | 7 +- test/e2e/framework/kubectl/kubectl_utils.go | 2 +- test/e2e/framework/log.go | 2 +- test/e2e/framework/log/logger.go | 2 +- test/e2e/framework/log_test.go | 85 +-------------------- test/e2e/framework/node/resource.go | 2 +- test/e2e/framework/nodes_util.go | 2 +- test/e2e/framework/pod/delete.go | 2 +- test/e2e/framework/pod/resource.go | 2 +- test/e2e/framework/pod/wait.go | 2 +- test/e2e/framework/pods.go | 2 +- test/e2e/framework/psp.go | 2 +- test/e2e/framework/skipper/skipper.go | 7 +- test/e2e/framework/test_context.go | 10 ++- test/e2e/framework/util.go | 2 +- test/e2e/quota/framework.go | 2 +- test/e2e/quota/multi_tree.go | 2 +- test/e2e/quota/quota.go | 2 +- test/e2e/quota/quota_guaranteed.go | 2 +- test/e2e/reporters/progress.go | 4 +- test/e2e/reporters/testDetails.go | 4 +- test/e2e/scheduling/deviceshare.go | 2 +- test/e2e/scheduling/framework.go | 2 +- test/e2e/scheduling/helper.go | 2 +- test/e2e/scheduling/hostport.go | 2 +- test/e2e/scheduling/nodenumaresource.go | 2 +- test/e2e/scheduling/preemption.go | 2 +- test/e2e/scheduling/reservation.go | 2 +- test/e2e/slocontroller/batchresource.go | 2 +- test/e2e/slocontroller/cpunormalization.go | 2 +- test/e2e/slocontroller/framework.go | 2 +- 37 files changed, 61 insertions(+), 160 deletions(-) diff --git a/go.mod b/go.mod index c813924bb..c2714b35e 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.1 github.com/mohae/deepcopy v0.0.0-20170603005431-491d3605edfb github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9 - github.com/onsi/ginkgo v1.16.5 + github.com/onsi/ginkgo/v2 v2.11.0 github.com/onsi/gomega v1.27.10 github.com/opencontainers/runc v1.1.7 github.com/openkruise/kruise-api v1.5.0 @@ -72,9 +72,11 @@ require ( github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/cel-go v0.16.1 // indirect github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/pprof v0.0.0-20220829040838-70bd9ae97f40 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect @@ -175,7 +177,6 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect @@ -231,7 +232,6 @@ require ( gopkg.in/gcfg.v1 v1.2.3 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.28.3 // indirect diff --git a/go.sum b/go.sum index 2dd091144..7cd2878e1 100644 --- a/go.sum +++ b/go.sum @@ -757,6 +757,7 @@ github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20220829040838-70bd9ae97f40 h1:ykKxL12NZd3JmWZnyqarJGsF73M9Xhtrik/FEtEeFRE= +github.com/google/pprof v0.0.0-20220829040838-70bd9ae97f40/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -1007,7 +1008,6 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -1019,8 +1019,6 @@ github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= @@ -1034,6 +1032,7 @@ github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzm github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -1857,7 +1856,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= diff --git a/test/e2e/README.md b/test/e2e/README.md index ad36d2a13..8f69e5d34 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -45,7 +45,7 @@ import ( // test/e2e/lifecycle/framework.go package lifecycle -import "github.com/onsi/ginkgo" +import "github.com/onsi/ginkgo/v2" // SIGDescribe annotates the test with the SIG label. func SIGDescribe(text string, body func()) bool { @@ -58,7 +58,7 @@ func SIGDescribe(text string, body func()) bool { package bootstrap import ( - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/koordinator-sh/koordinator/test/e2e/lifecycle" ) var _ = lifecycle.SIGDescribe("[Feature:BootstrapTokens]", func() { diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index e00e84adf..a56b802e7 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -23,15 +23,12 @@ import ( "fmt" "os" "os/exec" - "path" "path/filepath" "strings" "testing" "time" - "github.com/onsi/ginkgo" - "github.com/onsi/ginkgo/config" - "github.com/onsi/ginkgo/reporters" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" @@ -51,8 +48,6 @@ import ( e2emanifest "github.com/koordinator-sh/koordinator/test/e2e/framework/manifest" e2enode "github.com/koordinator-sh/koordinator/test/e2e/framework/node" e2epod "github.com/koordinator-sh/koordinator/test/e2e/framework/pod" - e2ereporters "github.com/koordinator-sh/koordinator/test/e2e/reporters" - // ensure auth plugins are loaded _ "k8s.io/client-go/plugin/pkg/client/auth" @@ -96,29 +91,8 @@ func RunE2ETests(t *testing.T) { gomega.RegisterFailHandler(framework.Fail) - // Run tests through the Ginkgo runner with output to console + JUnit for Jenkins - var r []ginkgo.Reporter - if framework.TestContext.ReportDir != "" { - // TODO: we should probably only be trying to create this directory once - // rather than once-per-Ginkgo-node. - if err := os.MkdirAll(framework.TestContext.ReportDir, 0755); err != nil { - klog.Errorf("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)))) - } - } - - // Stream the progress to stdout and optionally a URL accepting progress updates. - r = append(r, e2ereporters.NewProgressReporter(framework.TestContext.ProgressReportURL)) - - // The DetailsRepoerter will output details about every test (name, files, lines, etc) which helps - // when documenting our tests. - if len(framework.TestContext.SpecSummaryOutput) > 0 { - r = append(r, e2ereporters.NewDetailsReporterFile(framework.TestContext.SpecSummaryOutput)) - } - - klog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunID, config.GinkgoConfig.ParallelNode) - ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r) + klog.Infof("Starting e2e run %q", framework.RunID) + ginkgo.RunSpecs(t, "Kubernetes e2e suite") } // Run a test container to try and contact the Kubernetes api-server from a pod, wait for it diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 148a1a7d3..55ae77aaa 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -31,7 +31,7 @@ import ( // the ginkgo test runner will not detect that this // directory contains a Ginkgo test suite. // See https://github.com/kubernetes/kubernetes/issues/74827 - // "github.com/onsi/ginkgo" + // "github.com/onsi/ginkgo/v2" "k8s.io/component-base/version" diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index e44f836bf..258124176 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -48,7 +48,7 @@ import ( "k8s.io/client-go/restmapper" scaleclient "k8s.io/client-go/scale" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" koordinatorclientset "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" @@ -634,7 +634,7 @@ func (kc *KubeConfig) FindCluster(name string) *KubeCluster { // ConformanceIt is wrapper function for ginkgo It. Adds "[Conformance]" tag and makes static analysis easier. func ConformanceIt(text string, body interface{}, timeout ...float64) bool { - return ginkgo.It(text+" [Conformance]", body, timeout...) + return ginkgo.It(text+" [Conformance]", body, timeout) } // KoordinatorDescribe is a wrapper function for ginkgo describe. Adds namespacing. diff --git a/test/e2e/framework/ginkgowrapper/wrapper.go b/test/e2e/framework/ginkgowrapper/wrapper.go index 52ba5c0a9..e360d636c 100644 --- a/test/e2e/framework/ginkgowrapper/wrapper.go +++ b/test/e2e/framework/ginkgowrapper/wrapper.go @@ -27,7 +27,7 @@ import ( "runtime/debug" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" ) // FailurePanic is the value that will be panicked from Fail. @@ -39,7 +39,10 @@ type FailurePanic struct { } // String makes FailurePanic look like the old Ginkgo panic when printed. -func (FailurePanic) String() string { return ginkgo.GINKGO_PANIC } +func (FailurePanic) String() string { + ginkgo.Fail("Test failed due to panic", 1) + return "panic" +} // Fail wraps ginkgo.Fail so that it panics with more useful // information about the failure. This function will panic with a diff --git a/test/e2e/framework/kubectl/kubectl_utils.go b/test/e2e/framework/kubectl/kubectl_utils.go index 88301f013..56509772c 100644 --- a/test/e2e/framework/kubectl/kubectl_utils.go +++ b/test/e2e/framework/kubectl/kubectl_utils.go @@ -35,7 +35,7 @@ import ( e2elog "github.com/koordinator-sh/koordinator/test/e2e/framework/log" e2epod "github.com/koordinator-sh/koordinator/test/e2e/framework/pod" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" ) const ( diff --git a/test/e2e/framework/log.go b/test/e2e/framework/log.go index 0d7f6a8cf..3bf92e825 100644 --- a/test/e2e/framework/log.go +++ b/test/e2e/framework/log.go @@ -24,7 +24,7 @@ import ( "runtime/debug" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" // TODO: Remove the following imports (ref: https://github.com/kubernetes/kubernetes/issues/81245) e2eginkgowrapper "github.com/koordinator-sh/koordinator/test/e2e/framework/ginkgowrapper" diff --git a/test/e2e/framework/log/logger.go b/test/e2e/framework/log/logger.go index 32bf99546..e3b5fe9cd 100644 --- a/test/e2e/framework/log/logger.go +++ b/test/e2e/framework/log/logger.go @@ -23,7 +23,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" e2eginkgowrapper "github.com/koordinator-sh/koordinator/test/e2e/framework/ginkgowrapper" ) diff --git a/test/e2e/framework/log_test.go b/test/e2e/framework/log_test.go index d084efb20..fbb95a658 100644 --- a/test/e2e/framework/log_test.go +++ b/test/e2e/framework/log_test.go @@ -20,16 +20,10 @@ package framework_test import ( "errors" "regexp" - "sort" - "strings" "testing" - "github.com/onsi/ginkgo" - "github.com/onsi/ginkgo/config" - "github.com/onsi/ginkgo/reporters" - "github.com/onsi/gomega" - "github.com/koordinator-sh/koordinator/test/e2e/framework" + "github.com/onsi/ginkgo/v2" ) // The line number of the following code is checked in TestFailureOutput below. @@ -43,9 +37,9 @@ import ( // // -func runTests(t *testing.T, reporter ginkgo.Reporter) { +func runTests(t *testing.T) { // This source code line will be part of the stack dump comparison. - ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Logging Suite", []ginkgo.Reporter{reporter}) + ginkgo.RunSpecs(t, "Logging Suite") } var _ = ginkgo.Describe("log", func() { @@ -73,63 +67,6 @@ var _ = ginkgo.Describe("log", func() { }) }) -func TestFailureOutput(t *testing.T) { - // Run the Ginkgo suite with output collected by a custom - // reporter in adddition to the default one. To see what the full - // Ginkgo report looks like, run this test with "go test -v". - config.DefaultReporterConfig.FullTrace = true - gomega.RegisterFailHandler(framework.Fail) - fakeT := &testing.T{} - reporter := reporters.NewFakeReporter() - runTests(fakeT, reporter) - - // Now check the output. - actual := normalizeReport(*reporter) - - // output from AfterEach - commonOutput := "\n\nINFO: after\nFAIL: true is never false either\nExpected\n : true\nto equal\n : false\n\nFull Stack Trace\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.6()\n\tlog_test.go:71\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n\n" - - // Sorted by name! - expected := suiteResults{ - testResult{ - name: "[Top Level] log asserts", - output: "INFO: before\nFAIL: false is never true\nExpected\n : false\nto equal\n : true\n\nFull Stack Trace\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.3()\n\tlog_test.go:60\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput, - failure: "false is never true\nExpected\n : false\nto equal\n : true", - stack: "github.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.3()\n\tlog_test.go:60\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n", - }, - testResult{ - name: "[Top Level] log equal", - output: "INFO: before\nFAIL: of course it's not equal...\nExpected\n : 0\nto equal\n : 1\n\nFull Stack Trace\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.5()\n\tlog_test.go:67\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput, - failure: "of course it's not equal...\nExpected\n : 0\nto equal\n : 1", - stack: "github.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.5()\n\tlog_test.go:67\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n", - }, - testResult{ - name: "[Top Level] log error", - output: "INFO: before\nFAIL: hard-coded error\nUnexpected error:\n <*errors.errorString>: {\n s: \"an error with a long, useless description\",\n }\n an error with a long, useless description\noccurred\n\nFull Stack Trace\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.4()\n\tlog_test.go:64\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput, - failure: "hard-coded error\nUnexpected error:\n <*errors.errorString>: {\n s: \"an error with a long, useless description\",\n }\n an error with a long, useless description\noccurred", - stack: "github.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.4()\n\tlog_test.go:64\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n", - }, - testResult{ - name: "[Top Level] log fails", - output: "INFO: before\nFAIL: I'm failing.\n\nFull Stack Trace\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47" + commonOutput, - failure: "I'm failing.", - stack: "github.com/koordinator-sh/koordinator/test/e2e/framework_test.glob..func1.2()\n\tlog_test.go:57\ngithub.com/koordinator-sh/koordinator/test/e2e/framework_test.runTests()\n\tlog_test.go:47\n", - }, - } - // Compare individual fields. Comparing the slices leads to unreadable error output when there is any mismatch. - framework.ExpectEqual(len(actual), len(expected), "%d entries in %v", len(expected), actual) - for i, a := range actual { - b := expected[i] - framework.ExpectEqual(a.name, b.name, "name in %d", i) - framework.ExpectEqual(a.output, b.output, "output in %d", i) - framework.ExpectEqual(a.failure, b.failure, "failure in %d", i) - // There may be additional stack entries from the "testing" package at the - // end. We ignore those in the comparison because the line number in them - // varies. - framework.ExpectEqual(a.stack, b.stack, "stack in %d: %s", i, a.stack) - } -} - type testResult struct { name string // output written to GinkgoWriter during test. @@ -143,22 +80,6 @@ type testResult struct { type suiteResults []testResult -func normalizeReport(report reporters.FakeReporter) suiteResults { - var results suiteResults - for _, spec := range report.SpecSummaries { - results = append(results, testResult{ - name: strings.Join(spec.ComponentTexts, " "), - output: normalizeLocation(stripAddresses(stripTimes(spec.CapturedOutput))), - failure: stripAddresses(stripTimes(spec.Failure.Message)), - stack: normalizeLocation(spec.Failure.Location.FullStackTrace), - }) - } - sort.Slice(results, func(i, j int) bool { - return strings.Compare(results[i].name, results[j].name) < 0 - }) - return results -} - // timePrefix matches "Jul 17 08:08:25.950: " at the beginning of each line. var timePrefix = regexp.MustCompile(`(?m)^[[:alpha:]]{3} +[[:digit:]]{1,2} +[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}.[[:digit:]]{3}: `) diff --git a/test/e2e/framework/node/resource.go b/test/e2e/framework/node/resource.go index 305e367d5..e25ab3e86 100644 --- a/test/e2e/framework/node/resource.go +++ b/test/e2e/framework/node/resource.go @@ -25,7 +25,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" diff --git a/test/e2e/framework/nodes_util.go b/test/e2e/framework/nodes_util.go index c0edec8fe..d93ee6e84 100644 --- a/test/e2e/framework/nodes_util.go +++ b/test/e2e/framework/nodes_util.go @@ -24,7 +24,7 @@ import ( "sync" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/wait" diff --git a/test/e2e/framework/pod/delete.go b/test/e2e/framework/pod/delete.go index e1cc6b27f..57224c679 100644 --- a/test/e2e/framework/pod/delete.go +++ b/test/e2e/framework/pod/delete.go @@ -22,7 +22,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/test/e2e/framework/pod/resource.go b/test/e2e/framework/pod/resource.go index f6e6783fd..ad697059d 100644 --- a/test/e2e/framework/pod/resource.go +++ b/test/e2e/framework/pod/resource.go @@ -24,7 +24,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index 96c81a11f..951fc3121 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -26,7 +26,7 @@ import ( "text/tabwriter" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/test/e2e/framework/pods.go b/test/e2e/framework/pods.go index a40dae2c3..c55a62bbb 100644 --- a/test/e2e/framework/pods.go +++ b/test/e2e/framework/pods.go @@ -34,7 +34,7 @@ import ( v1core "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/kubectl/pkg/util/podutils" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" // TODO: Remove the following imports (ref: https://github.com/kubernetes/kubernetes/issues/81245) diff --git a/test/e2e/framework/psp.go b/test/e2e/framework/psp.go index 62075b8a4..649c1c875 100644 --- a/test/e2e/framework/psp.go +++ b/test/e2e/framework/psp.go @@ -34,7 +34,7 @@ import ( imageutils "github.com/koordinator-sh/koordinator/test/utils/image" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" // TODO: Remove the following imports (ref: https://github.com/kubernetes/kubernetes/issues/81245) e2eauth "github.com/koordinator-sh/koordinator/test/e2e/framework/auth" diff --git a/test/e2e/framework/skipper/skipper.go b/test/e2e/framework/skipper/skipper.go index 9a9365142..068da8961 100644 --- a/test/e2e/framework/skipper/skipper.go +++ b/test/e2e/framework/skipper/skipper.go @@ -27,7 +27,7 @@ import ( "runtime/debug" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -69,7 +69,10 @@ type SkipPanic struct { } // String makes SkipPanic look like the old Ginkgo panic when printed. -func (SkipPanic) String() string { return ginkgo.GINKGO_PANIC } +func (SkipPanic) String() string { + ginkgo.Fail("Test failed due to panic", 1) + return "panic" +} // Skip wraps ginkgo.Skip so that it panics with more useful // information about why the test is being skipped. This function will diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 37c8e5ce8..6c76d4d28 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -22,13 +22,13 @@ import ( "errors" "flag" "fmt" + "github.com/onsi/ginkgo/v2" "math" "os" "sort" "strings" "time" - "github.com/onsi/ginkgo/config" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" @@ -284,14 +284,16 @@ func (tc TestContextType) ClusterIsIPv6() bool { // options themselves, copy flags from test/e2e/framework/config // as shown in HandleFlags. func RegisterCommonFlags(flags *flag.FlagSet) { + suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() + // Turn on verbose by default to get spec names - config.DefaultReporterConfig.Verbose = true + reporterConfig.Verbose = true // Turn on EmitSpecProgress to get spec progress (especially on interrupt) - config.GinkgoConfig.EmitSpecProgress = true + suiteConfig.EmitSpecProgress = true // Randomize specs as well as suites - config.GinkgoConfig.RandomizeAllSpecs = true + suiteConfig.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.") diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index f44a398bf..92c77596c 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -36,7 +36,7 @@ import ( "syscall" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" gomegatypes "github.com/onsi/gomega/types" diff --git a/test/e2e/quota/framework.go b/test/e2e/quota/framework.go index cd3572913..2ef2c0bac 100644 --- a/test/e2e/quota/framework.go +++ b/test/e2e/quota/framework.go @@ -16,7 +16,7 @@ limitations under the License. package quota -import "github.com/onsi/ginkgo" +import "github.com/onsi/ginkgo/v2" // SIGDescribe describes SIG information func SIGDescribe(text string, body func()) bool { diff --git a/test/e2e/quota/multi_tree.go b/test/e2e/quota/multi_tree.go index 65c51d800..9a2b9552f 100644 --- a/test/e2e/quota/multi_tree.go +++ b/test/e2e/quota/multi_tree.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/test/e2e/quota/quota.go b/test/e2e/quota/quota.go index e0bf0db07..c8ad8cebc 100644 --- a/test/e2e/quota/quota.go +++ b/test/e2e/quota/quota.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/test/e2e/quota/quota_guaranteed.go b/test/e2e/quota/quota_guaranteed.go index 229aefeab..1c77949d4 100644 --- a/test/e2e/quota/quota_guaranteed.go +++ b/test/e2e/quota/quota_guaranteed.go @@ -22,7 +22,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/test/e2e/reporters/progress.go b/test/e2e/reporters/progress.go index da75e4e8d..50ee18c43 100644 --- a/test/e2e/reporters/progress.go +++ b/test/e2e/reporters/progress.go @@ -27,8 +27,8 @@ import ( "k8s.io/klog/v2" - "github.com/onsi/ginkgo/config" - "github.com/onsi/ginkgo/types" + "github.com/onsi/ginkgo/v2/config" + "github.com/onsi/ginkgo/v2/types" ) // ProgressReporter is a ginkgo reporter which tracks the total number of tests to be run/passed/failed/skipped. diff --git a/test/e2e/reporters/testDetails.go b/test/e2e/reporters/testDetails.go index 871491142..c3f7761d4 100644 --- a/test/e2e/reporters/testDetails.go +++ b/test/e2e/reporters/testDetails.go @@ -23,8 +23,8 @@ import ( "os" "path/filepath" - "github.com/onsi/ginkgo/config" - "github.com/onsi/ginkgo/types" + "github.com/onsi/ginkgo/v2/config" + "github.com/onsi/ginkgo/v2/types" "k8s.io/klog/v2" ) diff --git a/test/e2e/scheduling/deviceshare.go b/test/e2e/scheduling/deviceshare.go index 468b4ed61..99414d191 100644 --- a/test/e2e/scheduling/deviceshare.go +++ b/test/e2e/scheduling/deviceshare.go @@ -22,7 +22,7 @@ import ( "sort" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" diff --git a/test/e2e/scheduling/framework.go b/test/e2e/scheduling/framework.go index bc376e453..4054719b3 100644 --- a/test/e2e/scheduling/framework.go +++ b/test/e2e/scheduling/framework.go @@ -16,7 +16,7 @@ limitations under the License. package scheduling -import "github.com/onsi/ginkgo" +import "github.com/onsi/ginkgo/v2" // SIGDescribe describes SIG information func SIGDescribe(text string, body func()) bool { diff --git a/test/e2e/scheduling/helper.go b/test/e2e/scheduling/helper.go index 638642eb4..17d82c7d0 100644 --- a/test/e2e/scheduling/helper.go +++ b/test/e2e/scheduling/helper.go @@ -24,7 +24,7 @@ import ( nrtv1alpha1 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha1" nrtclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/test/e2e/scheduling/hostport.go b/test/e2e/scheduling/hostport.go index 6e93dddd0..545841322 100644 --- a/test/e2e/scheduling/hostport.go +++ b/test/e2e/scheduling/hostport.go @@ -20,7 +20,7 @@ import ( "context" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" diff --git a/test/e2e/scheduling/nodenumaresource.go b/test/e2e/scheduling/nodenumaresource.go index 959533b8d..e62ca2911 100644 --- a/test/e2e/scheduling/nodenumaresource.go +++ b/test/e2e/scheduling/nodenumaresource.go @@ -24,7 +24,7 @@ import ( "time" nrtclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" diff --git a/test/e2e/scheduling/preemption.go b/test/e2e/scheduling/preemption.go index e942d4f75..8858d76e1 100644 --- a/test/e2e/scheduling/preemption.go +++ b/test/e2e/scheduling/preemption.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/e2e/scheduling/reservation.go b/test/e2e/scheduling/reservation.go index 15caa6fee..b0b243398 100644 --- a/test/e2e/scheduling/reservation.go +++ b/test/e2e/scheduling/reservation.go @@ -23,7 +23,7 @@ import ( "sort" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" diff --git a/test/e2e/slocontroller/batchresource.go b/test/e2e/slocontroller/batchresource.go index 898e4a8ea..7d0a327f1 100644 --- a/test/e2e/slocontroller/batchresource.go +++ b/test/e2e/slocontroller/batchresource.go @@ -20,7 +20,7 @@ import ( "context" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" diff --git a/test/e2e/slocontroller/cpunormalization.go b/test/e2e/slocontroller/cpunormalization.go index aaf634dac..f15dad1de 100644 --- a/test/e2e/slocontroller/cpunormalization.go +++ b/test/e2e/slocontroller/cpunormalization.go @@ -24,7 +24,7 @@ import ( topov1alpha1 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha1" nrtclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" diff --git a/test/e2e/slocontroller/framework.go b/test/e2e/slocontroller/framework.go index b45004478..ea2347745 100644 --- a/test/e2e/slocontroller/framework.go +++ b/test/e2e/slocontroller/framework.go @@ -16,7 +16,7 @@ limitations under the License. package slocontroller -import "github.com/onsi/ginkgo" +import "github.com/onsi/ginkgo/v2" // SIGDescribe describes SIG information func SIGDescribe(text string, body func()) bool {