implement WithFeatureGate label proposal

Ginkgo label changes:
- Feature:Alpha => Alpha
- Feature:Beta => Beta
- Feature:OffByDefault mirrored to labels from test name
- BetaOffByDefault label added
This commit is contained in:
Benjamin Elder 2025-03-18 15:26:49 -07:00
parent 67bdb110b4
commit 507621e0da
2 changed files with 22 additions and 10 deletions

View File

@ -210,12 +210,16 @@ func registerInSuite(ginkgoCall func(string, ...interface{}) bool, args []interf
addLabel(fullLabel) addLabel(fullLabel)
if arg.alphaBetaLevel != "" { if arg.alphaBetaLevel != "" {
texts = append(texts, fmt.Sprintf("[%[1]s]", 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 { if arg.offByDefault {
texts = append(texts, "[Feature: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" { if fullLabel == "Serial" {
ginkgoArgs = append(ginkgoArgs, ginkgo.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 // on the current stability level of the feature, to emulate historic
// usage of those tags. // usage of those tags.
// //
// In addition, [Feature:Alpha] resp. [Feature:Beta] get added to support // For label filtering, Alpha resp. Beta get added to the Ginkgo labels.
// 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, Feature:Alpha resp. Feature:Beta get added to the // [Feature:OffByDefault] gets added to support skipping a test with
// Ginkgo labels. // 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 // 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 // API groups enabled, then annotating it with just WithFeatureGate is

View File

@ -129,12 +129,14 @@ ERROR: some/relative/path/buggy.go:200: with spaces
// Used by unittests/list-labels. // Used by unittests/list-labels.
ListLabelsOutput = `The following labels can be used with 'ginkgo run --label-filter': ListLabelsOutput = `The following labels can be used with 'ginkgo run --label-filter':
Alpha
Beta
BetaOffByDefault
Conformance Conformance
Disruptive Disruptive
Environment:Linux Environment:Linux
Environment:no-such-env Environment:no-such-env
Feature:Alpha Feature:OffByDefault
Feature:Beta
Feature:feature-foo Feature:feature-foo
Feature:no-such-feature Feature:no-such-feature
FeatureGate:TestAlphaFeature FeatureGate:TestAlphaFeature