mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-24 12:37:39 +00:00
Merge pull request #134708 from pohly/e2e-unified-meta-labels
e2e framework: inject additional labels only once to leaf node
This commit is contained in:
456
test/conformance/testdata/conformance.yaml
vendored
456
test/conformance/testdata/conformance.yaml
vendored
File diff suppressed because it is too large
Load Diff
@@ -254,13 +254,37 @@ func init() {
|
||||
}
|
||||
|
||||
func transformGinkgoNodeArgs(nodeType types.NodeType, offset ginkgo.Offset, text string, args []any) (string, []any, []error) {
|
||||
text, args = expandGinkgoArgs(offset+1, text, args)
|
||||
text, args = expandGinkgoArgs(nodeType == types.NodeTypeIt, offset+1, text, args)
|
||||
return text, args, nil
|
||||
}
|
||||
|
||||
// leafNodeLabels contains labels that
|
||||
// - might get added multiple times while constructing the spec tree and
|
||||
// - only need to be shown once and
|
||||
// - is very likely not considered part of the full test name string.
|
||||
//
|
||||
// Injecting their tag multiple times directly into the text at the place which
|
||||
// triggers their addition, they get only added as label (not visible) and the
|
||||
// text then gets added at the end of the leaf node text (= ginkgo.It name)
|
||||
// based on the previously added labels.
|
||||
//
|
||||
// The initial set contains the labels defined in the E2E framework. Feature
|
||||
// gate stability texts (Alpha, Beta, etc.) get added when we encounter them
|
||||
// to avoid making assumptions about what those strings are.
|
||||
var leafNodeLabels = sets.New[string](
|
||||
"Conformance",
|
||||
"Disruptive",
|
||||
"Feature:OffByDefault",
|
||||
"Flaky",
|
||||
"NodeConformance",
|
||||
"Serial",
|
||||
"Slow",
|
||||
)
|
||||
|
||||
// expandGinkgoArgs concatenates all strings and translates our custom
|
||||
// arguments into something that Ginkgo can handle.
|
||||
func expandGinkgoArgs(offset ginkgo.Offset, text string, args []any) (string, []any) {
|
||||
// arguments into something that Ginkgo can handle. It gets called
|
||||
// through ginkgo.AddTreeConstructionNodeArgsTransformer.
|
||||
func expandGinkgoArgs(leafNode bool, offset ginkgo.Offset, text string, args []any) (string, []any) {
|
||||
var ginkgoArgs []interface{}
|
||||
var texts []string
|
||||
|
||||
@@ -268,9 +292,16 @@ func expandGinkgoArgs(offset ginkgo.Offset, text string, args []any) (string, []
|
||||
texts = append(texts, text)
|
||||
}
|
||||
|
||||
// All labels for a leaf node, from parent and added in this call.
|
||||
allLabels := sets.New[string]()
|
||||
if leafNode {
|
||||
// May only be called during tree construction, i.e. not for the top-level node,
|
||||
// so we have to be a bit careful.
|
||||
allLabels = sets.New[string](ginkgo.CurrentTreeConstructionNodeReport().Labels()...)
|
||||
}
|
||||
addLabel := func(label string) {
|
||||
texts = append(texts, fmt.Sprintf("[%s]", label))
|
||||
ginkgoArgs = append(ginkgoArgs, ginkgo.Label(label))
|
||||
allLabels.Insert(label)
|
||||
}
|
||||
|
||||
haveEmptyStrings := false
|
||||
@@ -279,16 +310,19 @@ func expandGinkgoArgs(offset ginkgo.Offset, text string, args []any) (string, []
|
||||
case label:
|
||||
fullLabel := strings.Join(arg.parts, ":")
|
||||
addLabel(fullLabel)
|
||||
if !leafNodeLabels.Has(fullLabel) {
|
||||
texts = append(texts, fmt.Sprintf("[%s]", fullLabel))
|
||||
}
|
||||
if arg.alphaBetaLevel != "" {
|
||||
texts = append(texts, fmt.Sprintf("[%[1]s]", arg.alphaBetaLevel))
|
||||
ginkgoArgs = append(ginkgoArgs, ginkgo.Label(arg.alphaBetaLevel))
|
||||
leafNodeLabels.Insert(arg.alphaBetaLevel)
|
||||
addLabel(arg.alphaBetaLevel)
|
||||
}
|
||||
if arg.offByDefault {
|
||||
texts = append(texts, "[Feature:OffByDefault]")
|
||||
ginkgoArgs = append(ginkgoArgs, ginkgo.Label("Feature:OffByDefault"))
|
||||
addLabel("Feature:OffByDefault")
|
||||
// Alphas are always off by default but we may want to select
|
||||
// betas based on defaulted-ness.
|
||||
if arg.alphaBetaLevel == "Beta" {
|
||||
// Not embedded in text, only as Ginkgo label!
|
||||
ginkgoArgs = append(ginkgoArgs, ginkgo.Label("BetaOffByDefault"))
|
||||
}
|
||||
}
|
||||
@@ -326,6 +360,25 @@ func expandGinkgoArgs(offset ginkgo.Offset, text string, args []any) (string, []
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that each leaf node text contains all additional labels collected so far.
|
||||
// We get those labels from the set of labels associated with the container node(s).
|
||||
if leafNode {
|
||||
var delayedLabels []string
|
||||
|
||||
for label := range allLabels {
|
||||
if leafNodeLabels.Has(label) {
|
||||
delayedLabels = append(delayedLabels, label)
|
||||
}
|
||||
}
|
||||
|
||||
slices.Sort(delayedLabels)
|
||||
for _, label := range delayedLabels {
|
||||
texts = append(texts, fmt.Sprintf("[%s]", label))
|
||||
// This keeps validateText happy.
|
||||
ginkgoArgs = append(ginkgoArgs, ginkgo.Label(label))
|
||||
}
|
||||
}
|
||||
|
||||
text = strings.Join(texts, " ")
|
||||
return text, ginkgoArgs
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ 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: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]
|
||||
../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] [FeatureGate:TestAlphaFeature] [FeatureGate:TestBetaFeature] [FeatureGate:TestBetaDefaultOffFeature] [FeatureGate:TestGAFeature] [custom-label] xyz x [foo] should [bar] [Alpha] [Beta] [Conformance] [Disruptive] [Feature:OffByDefault] [NodeConformance] [Serial] [Slow]
|
||||
../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] [FeatureGate:TestAlphaFeature] [FeatureGate:TestBetaFeature] [FeatureGate:TestBetaDefaultOffFeature] [FeatureGate:TestGAFeature] [custom-label] xyz y [foo] should [bar] [Alpha] [Beta] [Conformance] [Disruptive] [Feature:OffByDefault] [NodeConformance] [Serial] [Slow]
|
||||
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user