From 507621e0da4c91c83f37c03aed602410b8ca7a4b Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 18 Mar 2025 15:26:49 -0700 Subject: [PATCH 1/2] implement WithFeatureGate label proposal Ginkgo label changes: - Feature:Alpha => Alpha - Feature:Beta => Beta - Feature:OffByDefault mirrored to labels from test name - BetaOffByDefault label added --- test/e2e/framework/ginkgowrapper.go | 26 +++++++++++++------ .../framework/internal/unittests/bugs/bugs.go | 6 +++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/test/e2e/framework/ginkgowrapper.go b/test/e2e/framework/ginkgowrapper.go index 2371f9330ec..ccc045ba791 100644 --- a/test/e2e/framework/ginkgowrapper.go +++ b/test/e2e/framework/ginkgowrapper.go @@ -210,12 +210,16 @@ func registerInSuite(ginkgoCall func(string, ...interface{}) bool, args []interf addLabel(fullLabel) if arg.alphaBetaLevel != "" { texts = append(texts, fmt.Sprintf("[%[1]s]", arg.alphaBetaLevel)) - ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:"+arg.alphaBetaLevel)) + ginkgoArgs = append(ginkgoArgs, ginkgo.Label(arg.alphaBetaLevel)) } if arg.offByDefault { texts = append(texts, "[Feature:OffByDefault]") - // TODO: consider this once we have a plan to update the alpha/beta job filters - // ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:OffByDefault")) + ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:OffByDefault")) + // Alphas are always off by default but we may want to select + // betas based on defaulted-ness. + if arg.alphaBetaLevel == "Beta" { + ginkgoArgs = append(ginkgoArgs, ginkgo.Label("BetaOffByDefault")) + } } if fullLabel == "Serial" { ginkgoArgs = append(ginkgoArgs, ginkgo.Serial) @@ -374,12 +378,18 @@ func withFeature(name Feature) interface{} { // on the current stability level of the feature, to emulate historic // usage of those tags. // -// In addition, [Feature:Alpha] resp. [Feature:Beta] get added to support -// skipping a test with a dependency on an alpha or beta feature gate in -// jobs which use the traditional \[Feature:.*\] skip regular expression. +// For label filtering, Alpha resp. Beta get added to the Ginkgo labels. // -// For label filtering, Feature:Alpha resp. Feature:Beta get added to the -// Ginkgo labels. +// [Feature:OffByDefault] gets added to support skipping a test with +// a dependency on an alpha or beta feature gate in jobs which use the +// traditional \[Feature:.*\] skip regular expression. +// +// Feature:OffByDefault is also available for label filtering. +// +// BetaOffByDefault is also added *only as a label* when the feature gate is +// an off by default beta feature. This can be used to include/exclude based +// on beta + defaulted-ness. Alpha has no equivalent because all alphas are +// off by default. // // If the test can run in any cluster that has alpha resp. beta features and // API groups enabled, then annotating it with just WithFeatureGate is diff --git a/test/e2e/framework/internal/unittests/bugs/bugs.go b/test/e2e/framework/internal/unittests/bugs/bugs.go index d162ce6b05b..9412abc2c86 100644 --- a/test/e2e/framework/internal/unittests/bugs/bugs.go +++ b/test/e2e/framework/internal/unittests/bugs/bugs.go @@ -129,12 +129,14 @@ ERROR: some/relative/path/buggy.go:200: with spaces // Used by unittests/list-labels. ListLabelsOutput = `The following labels can be used with 'ginkgo run --label-filter': + Alpha + Beta + BetaOffByDefault Conformance Disruptive Environment:Linux Environment:no-such-env - Feature:Alpha - Feature:Beta + Feature:OffByDefault Feature:feature-foo Feature:no-such-feature FeatureGate:TestAlphaFeature From 798ce5bde252d6a1b807450ee6d126bdadd1b066 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 19 Mar 2025 15:36:47 -0700 Subject: [PATCH 2/2] e2e framework: add BetaDefaultOff feature gate testcase --- test/e2e/framework/internal/unittests/bugs/bugs.go | 8 +++++--- .../internal/unittests/bugs/features/features.go | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/e2e/framework/internal/unittests/bugs/bugs.go b/test/e2e/framework/internal/unittests/bugs/bugs.go index 9412abc2c86..3023f22687f 100644 --- a/test/e2e/framework/internal/unittests/bugs/bugs.go +++ b/test/e2e/framework/internal/unittests/bugs/bugs.go @@ -80,6 +80,7 @@ func Describe() { framework.WithFeatureGate("no-such-feature-gate"), framework.WithFeatureGate(features.Alpha), framework.WithFeatureGate(features.Beta), + framework.WithFeatureGate(features.BetaDefaultOff), framework.WithFeatureGate(features.GA), framework.WithConformance(), framework.WithNodeConformance(), @@ -116,14 +117,14 @@ ERROR: bugs.go:71: trailing or leading spaces are unnecessary and need to be rem ERROR: bugs.go:76: WithFeature: unknown feature "no-such-feature" ERROR: bugs.go:78: WithEnvironment: unknown environment "no-such-env" ERROR: bugs.go:80: WithFeatureGate: the feature gate "no-such-feature-gate" is unknown -ERROR: bugs.go:106: SIG label must be lowercase, no spaces and no sig- prefix, got instead: "123" +ERROR: bugs.go:107: SIG label must be lowercase, no spaces and no sig- prefix, got instead: "123" ERROR: buggy/buggy.go:100: hello world ERROR: some/relative/path/buggy.go:200: with spaces ` // Used by unittests/list-tests. It's sorted by test name, not source code location. ListTestsOutput = `The following spec names can be used with 'ginkgo run --focus/skip': - ../bugs/bugs.go:100: [sig-testing] abc space1 space2 [Feature:no-such-feature] [Feature:feature-foo] [Environment:no-such-env] [Environment:Linux] [FeatureGate:no-such-feature-gate] [Feature:OffByDefault] [FeatureGate:TestAlphaFeature] [Alpha] [Feature:OffByDefault] [FeatureGate:TestBetaFeature] [Beta] [FeatureGate:TestGAFeature] [Conformance] [NodeConformance] [Slow] [Serial] [Disruptive] [custom-label] xyz x [foo] should [bar] - ../bugs/bugs.go:95: [sig-testing] abc space1 space2 [Feature:no-such-feature] [Feature:feature-foo] [Environment:no-such-env] [Environment:Linux] [FeatureGate:no-such-feature-gate] [Feature:OffByDefault] [FeatureGate:TestAlphaFeature] [Alpha] [Feature:OffByDefault] [FeatureGate:TestBetaFeature] [Beta] [FeatureGate:TestGAFeature] [Conformance] [NodeConformance] [Slow] [Serial] [Disruptive] [custom-label] xyz y [foo] should [bar] + ../bugs/bugs.go:101: [sig-testing] abc space1 space2 [Feature:no-such-feature] [Feature:feature-foo] [Environment:no-such-env] [Environment:Linux] [FeatureGate:no-such-feature-gate] [Feature:OffByDefault] [FeatureGate:TestAlphaFeature] [Alpha] [Feature:OffByDefault] [FeatureGate:TestBetaFeature] [Beta] [FeatureGate:TestBetaDefaultOffFeature] [Beta] [Feature:OffByDefault] [FeatureGate:TestGAFeature] [Conformance] [NodeConformance] [Slow] [Serial] [Disruptive] [custom-label] xyz x [foo] should [bar] + ../bugs/bugs.go:96: [sig-testing] abc space1 space2 [Feature:no-such-feature] [Feature:feature-foo] [Environment:no-such-env] [Environment:Linux] [FeatureGate:no-such-feature-gate] [Feature:OffByDefault] [FeatureGate:TestAlphaFeature] [Alpha] [Feature:OffByDefault] [FeatureGate:TestBetaFeature] [Beta] [FeatureGate:TestBetaDefaultOffFeature] [Beta] [Feature:OffByDefault] [FeatureGate:TestGAFeature] [Conformance] [NodeConformance] [Slow] [Serial] [Disruptive] [custom-label] xyz y [foo] should [bar] ` @@ -140,6 +141,7 @@ ERROR: some/relative/path/buggy.go:200: with spaces Feature:feature-foo Feature:no-such-feature FeatureGate:TestAlphaFeature + FeatureGate:TestBetaDefaultOffFeature FeatureGate:TestBetaFeature FeatureGate:TestGAFeature FeatureGate:no-such-feature-gate diff --git a/test/e2e/framework/internal/unittests/bugs/features/features.go b/test/e2e/framework/internal/unittests/bugs/features/features.go index 7b789e69ddb..75b9a11d707 100644 --- a/test/e2e/framework/internal/unittests/bugs/features/features.go +++ b/test/e2e/framework/internal/unittests/bugs/features/features.go @@ -24,9 +24,10 @@ import ( ) const ( - Alpha featuregate.Feature = "TestAlphaFeature" - Beta featuregate.Feature = "TestBetaFeature" - GA featuregate.Feature = "TestGAFeature" + Alpha featuregate.Feature = "TestAlphaFeature" + Beta featuregate.Feature = "TestBetaFeature" + BetaDefaultOff featuregate.Feature = "TestBetaDefaultOffFeature" + GA featuregate.Feature = "TestGAFeature" ) func init() { @@ -41,6 +42,9 @@ var testFeatureGates = map[featuregate.Feature]featuregate.VersionedSpecs{ {Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Alpha}, {Version: version.MustParse("1.28"), Default: true, PreRelease: featuregate.Beta}, }, + BetaDefaultOff: { + {Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Beta}, + }, GA: { {Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Alpha}, {Version: version.MustParse("1.28"), Default: true, PreRelease: featuregate.Beta},