Skip to content

Commit 63bd581

Browse files
authored
Merge pull request kubernetes#130908 from BenTheElder/test-labels-match
Implement WithFeatureGate label proposal
2 parents 1704c52 + 798ce5b commit 63bd581

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

test/e2e/framework/ginkgowrapper.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,16 @@ func registerInSuite(ginkgoCall func(string, ...interface{}) bool, args []interf
210210
addLabel(fullLabel)
211211
if arg.alphaBetaLevel != "" {
212212
texts = append(texts, fmt.Sprintf("[%[1]s]", arg.alphaBetaLevel))
213-
ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:"+arg.alphaBetaLevel))
213+
ginkgoArgs = append(ginkgoArgs, ginkgo.Label(arg.alphaBetaLevel))
214214
}
215215
if arg.offByDefault {
216216
texts = append(texts, "[Feature:OffByDefault]")
217-
// TODO: consider this once we have a plan to update the alpha/beta job filters
218-
// ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:OffByDefault"))
217+
ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:OffByDefault"))
218+
// Alphas are always off by default but we may want to select
219+
// betas based on defaulted-ness.
220+
if arg.alphaBetaLevel == "Beta" {
221+
ginkgoArgs = append(ginkgoArgs, ginkgo.Label("BetaOffByDefault"))
222+
}
219223
}
220224
if fullLabel == "Serial" {
221225
ginkgoArgs = append(ginkgoArgs, ginkgo.Serial)
@@ -374,12 +378,18 @@ func withFeature(name Feature) interface{} {
374378
// on the current stability level of the feature, to emulate historic
375379
// usage of those tags.
376380
//
377-
// In addition, [Feature:Alpha] resp. [Feature:Beta] get added to support
378-
// skipping a test with a dependency on an alpha or beta feature gate in
379-
// jobs which use the traditional \[Feature:.*\] skip regular expression.
381+
// For label filtering, Alpha resp. Beta get added to the Ginkgo labels.
380382
//
381-
// For label filtering, Feature:Alpha resp. Feature:Beta get added to the
382-
// Ginkgo labels.
383+
// [Feature:OffByDefault] gets added to support skipping a test with
384+
// a dependency on an alpha or beta feature gate in jobs which use the
385+
// traditional \[Feature:.*\] skip regular expression.
386+
//
387+
// Feature:OffByDefault is also available for label filtering.
388+
//
389+
// BetaOffByDefault is also added *only as a label* when the feature gate is
390+
// an off by default beta feature. This can be used to include/exclude based
391+
// on beta + defaulted-ness. Alpha has no equivalent because all alphas are
392+
// off by default.
383393
//
384394
// If the test can run in any cluster that has alpha resp. beta features and
385395
// API groups enabled, then annotating it with just WithFeatureGate is

test/e2e/framework/internal/unittests/bugs/bugs.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func Describe() {
8080
framework.WithFeatureGate("no-such-feature-gate"),
8181
framework.WithFeatureGate(features.Alpha),
8282
framework.WithFeatureGate(features.Beta),
83+
framework.WithFeatureGate(features.BetaDefaultOff),
8384
framework.WithFeatureGate(features.GA),
8485
framework.WithConformance(),
8586
framework.WithNodeConformance(),
@@ -116,28 +117,31 @@ ERROR: bugs.go:71: trailing or leading spaces are unnecessary and need to be rem
116117
ERROR: bugs.go:76: WithFeature: unknown feature "no-such-feature"
117118
ERROR: bugs.go:78: WithEnvironment: unknown environment "no-such-env"
118119
ERROR: bugs.go:80: WithFeatureGate: the feature gate "no-such-feature-gate" is unknown
119-
ERROR: bugs.go:106: SIG label must be lowercase, no spaces and no sig- prefix, got instead: "123"
120+
ERROR: bugs.go:107: SIG label must be lowercase, no spaces and no sig- prefix, got instead: "123"
120121
ERROR: buggy/buggy.go:100: hello world
121122
ERROR: some/relative/path/buggy.go:200: with spaces
122123
`
123124
// Used by unittests/list-tests. It's sorted by test name, not source code location.
124125
ListTestsOutput = `The following spec names can be used with 'ginkgo run --focus/skip':
125-
../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]
126-
../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]
126+
../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]
127+
../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]
127128
128129
`
129130

130131
// Used by unittests/list-labels.
131132
ListLabelsOutput = `The following labels can be used with 'ginkgo run --label-filter':
133+
Alpha
134+
Beta
135+
BetaOffByDefault
132136
Conformance
133137
Disruptive
134138
Environment:Linux
135139
Environment:no-such-env
136-
Feature:Alpha
137-
Feature:Beta
140+
Feature:OffByDefault
138141
Feature:feature-foo
139142
Feature:no-such-feature
140143
FeatureGate:TestAlphaFeature
144+
FeatureGate:TestBetaDefaultOffFeature
141145
FeatureGate:TestBetaFeature
142146
FeatureGate:TestGAFeature
143147
FeatureGate:no-such-feature-gate

test/e2e/framework/internal/unittests/bugs/features/features.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import (
2424
)
2525

2626
const (
27-
Alpha featuregate.Feature = "TestAlphaFeature"
28-
Beta featuregate.Feature = "TestBetaFeature"
29-
GA featuregate.Feature = "TestGAFeature"
27+
Alpha featuregate.Feature = "TestAlphaFeature"
28+
Beta featuregate.Feature = "TestBetaFeature"
29+
BetaDefaultOff featuregate.Feature = "TestBetaDefaultOffFeature"
30+
GA featuregate.Feature = "TestGAFeature"
3031
)
3132

3233
func init() {
@@ -41,6 +42,9 @@ var testFeatureGates = map[featuregate.Feature]featuregate.VersionedSpecs{
4142
{Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Alpha},
4243
{Version: version.MustParse("1.28"), Default: true, PreRelease: featuregate.Beta},
4344
},
45+
BetaDefaultOff: {
46+
{Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Beta},
47+
},
4448
GA: {
4549
{Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Alpha},
4650
{Version: version.MustParse("1.28"), Default: true, PreRelease: featuregate.Beta},

0 commit comments

Comments
 (0)