@@ -208,9 +208,14 @@ func registerInSuite(ginkgoCall func(string, ...interface{}) bool, args []interf
208
208
case label :
209
209
fullLabel := strings .Join (arg .parts , ":" )
210
210
addLabel (fullLabel )
211
- if arg .extraFeature != "" {
212
- texts = append (texts , fmt .Sprintf ("[%s]" , arg .extraFeature ))
213
- ginkgoArgs = append (ginkgoArgs , ginkgo .Label ("Feature:" + arg .extraFeature ))
211
+ if arg .alphaBetaLevel != "" {
212
+ texts = append (texts , fmt .Sprintf ("[%[1]s]" , arg .alphaBetaLevel ))
213
+ ginkgoArgs = append (ginkgoArgs , ginkgo .Label ("Feature:" + arg .alphaBetaLevel ))
214
+ }
215
+ if arg .offByDefault {
216
+ 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"))
214
219
}
215
220
if fullLabel == "Serial" {
216
221
ginkgoArgs = append (ginkgoArgs , ginkgo .Serial )
@@ -305,6 +310,12 @@ func validateText(location types.CodeLocation, text string, labels []string) {
305
310
// Okay, was also set as label.
306
311
continue
307
312
}
313
+ // TODO: we currently only set this as a text value
314
+ // We should probably reflect it into labels, but that could break some
315
+ // existing jobs and we're still setting on an exact plan
316
+ if tag == "Feature:OffByDefault" {
317
+ continue
318
+ }
308
319
if deprecatedTags .Has (tag ) {
309
320
recordTextBug (location , fmt .Sprintf ("[%s] in plain text is deprecated and must be added through With%s instead" , tag , tag ))
310
321
}
@@ -350,7 +361,8 @@ func withFeature(name Feature) interface{} {
350
361
}
351
362
352
363
// WithFeatureGate specifies that a certain test or group of tests depends on a
353
- // feature gate being enabled. The return value must be passed as additional
364
+ // feature gate and the corresponding API group (if there is one)
365
+ // being enabled. The return value must be passed as additional
354
366
// argument to [framework.It], [framework.Describe], [framework.Context].
355
367
//
356
368
// The feature gate must be listed in
@@ -359,9 +371,15 @@ func withFeature(name Feature) interface{} {
359
371
// also need to be removed.
360
372
//
361
373
// [Alpha] resp. [Beta] get added to the test name automatically depending
362
- // on the current stability level of the feature. Feature:Alpha resp.
363
- // Feature:Beta get added to the Ginkgo labels because this is a special
364
- // requirement for how the cluster needs to be configured.
374
+ // on the current stability level of the feature, to emulate historic
375
+ // usage of those tags.
376
+ //
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.
380
+ //
381
+ // For label filtering, Feature:Alpha resp. Feature:Beta get added to the
382
+ // Ginkgo labels.
365
383
//
366
384
// If the test can run in any cluster that has alpha resp. beta features and
367
385
// API groups enabled, then annotating it with just WithFeatureGate is
@@ -390,7 +408,8 @@ func withFeatureGate(featureGate featuregate.Feature) interface{} {
390
408
}
391
409
392
410
l := newLabel ("FeatureGate" , string (featureGate ))
393
- l .extraFeature = level
411
+ l .offByDefault = ! spec .Default
412
+ l .alphaBetaLevel = level
394
413
return l
395
414
}
396
415
@@ -536,13 +555,19 @@ func withFlaky() interface{} {
536
555
type label struct {
537
556
// parts get concatenated with ":" to build the full label.
538
557
parts []string
539
- // extra is an optional feature name. It gets added as [<extraFeature>]
540
- // to the test name and as Feature:<extraFeature> to the labels.
541
- extraFeature string
542
558
// explanation gets set for each label to help developers
543
559
// who pass a label to a ginkgo function. They need to use
544
560
// the corresponding framework function instead.
545
561
explanation string
562
+
563
+ // TODO: the fields below are only used for FeatureGates, we may want to refactor
564
+
565
+ // alphaBetaLevel is "Alpha", "Beta" or empty for GA features
566
+ // It gets added as [<level>] [Feature:<level>]
567
+ // to the test name and as Feature:<level> to the labels.
568
+ alphaBetaLevel string
569
+ // set based on featuregate default state
570
+ offByDefault bool
546
571
}
547
572
548
573
func newLabel (parts ... string ) label {
@@ -565,7 +590,10 @@ func TagsEqual(a, b interface{}) bool {
565
590
if ! ok {
566
591
return false
567
592
}
568
- if al .extraFeature != bl .extraFeature {
593
+ if al .alphaBetaLevel != bl .alphaBetaLevel {
594
+ return false
595
+ }
596
+ if al .offByDefault != bl .offByDefault {
569
597
return false
570
598
}
571
599
return slices .Equal (al .parts , bl .parts )
0 commit comments