Skip to content

Commit cad3ab4

Browse files
Merge pull request #1116 from kuiwang02/enhancefilter
OCPQE-29415:enhance filters to add more suites
2 parents 0b07ab9 + b4b2caa commit cad3ab4

File tree

2 files changed

+118
-17
lines changed

2 files changed

+118
-17
lines changed

tests-extension/cmd/main.go

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
_ "github.com/openshift/operator-framework-olm/tests-extension/test/qe/specs"
2323
exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util"
24+
"github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/filters"
2425
)
2526

2627
func main() {
@@ -53,8 +54,7 @@ func main() {
5354
Name: "olmv0/parallel",
5455
Parents: []string{"openshift/conformance/parallel"},
5556
Qualifiers: []string{
56-
`((!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))) &&
57-
!(name.contains("[Serial]") || name.contains("[Slow]"))`,
57+
filters.BasedStandardTests(`!(name.contains("[Serial]") || name.contains("[Slow]"))`),
5858
},
5959
})
6060

@@ -67,8 +67,7 @@ func main() {
6767
Name: "olmv0/serial",
6868
Parents: []string{"openshift/conformance/serial"},
6969
Qualifiers: []string{
70-
`((!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))) &&
71-
(name.contains("[Serial]") && !name.contains("[Disruptive]") && !name.contains("[Slow]"))`,
70+
filters.BasedStandardTests(`(name.contains("[Serial]") && !name.contains("[Disruptive]") && !name.contains("[Slow]"))`),
7271
// refer to https://github.com/openshift/origin/blob/main/pkg/testsuites/standard_suites.go#L456
7372
},
7473
})
@@ -82,8 +81,7 @@ func main() {
8281
Name: "olmv0/slow",
8382
Parents: []string{"openshift/optional/slow"},
8483
Qualifiers: []string{
85-
`((!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))) &&
86-
name.contains("[Slow]")`,
84+
filters.BasedStandardTests(`name.contains("[Slow]")`),
8785
},
8886
})
8987

@@ -94,7 +92,7 @@ func main() {
9492
ext.AddSuite(e.Suite{
9593
Name: "olmv0/all",
9694
Qualifiers: []string{
97-
`(!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))`,
95+
filters.BasedStandardTests(``),
9896
},
9997
})
10098

@@ -103,7 +101,7 @@ func main() {
103101
ext.AddSuite(e.Suite{
104102
Name: "olmv0/extended",
105103
Qualifiers: []string{
106-
`labels.exists(l, l=="Extended")`,
104+
filters.BasedExtendedTests(``),
107105
},
108106
})
109107

@@ -112,7 +110,7 @@ func main() {
112110
ext.AddSuite(e.Suite{
113111
Name: "olmv0/extended/releasegate",
114112
Qualifiers: []string{
115-
`labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate")`,
113+
filters.BasedExtendedReleaseGateTests(``),
116114
},
117115
})
118116

@@ -121,45 +119,88 @@ func main() {
121119
ext.AddSuite(e.Suite{
122120
Name: "olmv0/extended/candidate",
123121
Qualifiers: []string{
124-
`labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate")`,
122+
filters.BasedExtendedCandidateTests(``),
125123
},
126124
})
127125

126+
//
127+
// Categorization of Extended Candidate Tests:
128+
// ===========================================
129+
// The extended/candidate tests are categorized by test purpose and characteristics:
130+
//
131+
// 1. By Test Type:
132+
// - function: Functional tests that verify feature behavior and business logic
133+
// - stress: Stress tests that verify system behavior under resource pressure and load
134+
//
135+
// Relationship: candidate = function + stress + (other specialized test types)
136+
137+
// Extended Candidate Function Suite: Extended functional tests that don't meet OpenShift CI requirements
138+
// Contains extended tests that are not for openshift-tests and exclude stress tests
139+
ext.AddSuite(e.Suite{
140+
Name: "olmv1/extended/candidate/function",
141+
Qualifiers: []string{
142+
filters.BasedExtendedCandidateFuncTests(``),
143+
},
144+
})
145+
146+
//
147+
// Categorization of Extended Candidate Functional Tests:
148+
// =====================================================
149+
// The extended/candidate/function tests are categorized using two complementary approaches:
150+
//
151+
// 1. By Execution Model:
152+
// - parallel: Tests that can run concurrently (excludes [Serial] and [Slow])
153+
// - serial: Tests that must run one at a time ([Serial] but not [Slow])
154+
// - slow: Tests that take significant time to execute ([Slow])
155+
//
156+
// 2. By Execution Speed:
157+
// - fast: All non-slow functional tests (includes both parallel and serial, excludes [Slow])
158+
// - slow: Tests marked as [Slow] (same as above)
159+
//
160+
// Relationship: function = parallel + serial + slow = fast + slow
161+
128162
// Extended Candidate Suite Parallel Suite: extended tests that can run in parallel
129163
// Contains extended tests that can run concurrently (excludes Serial, Slow, and StressTest)
130164
ext.AddSuite(e.Suite{
131165
Name: "olmv0/extended/candidate/parallel",
132166
Qualifiers: []string{
133-
`(labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate") && !labels.exists(l, l=="StressTest")) &&
134-
!(name.contains("[Serial]") || name.contains("[Slow]"))`,
167+
filters.BasedExtendedCandidateFuncTests(`!(name.contains("[Serial]") || name.contains("[Slow]"))`),
135168
},
136169
})
137170
// Extended Candidate Serial Suite: extended tests that must run one at a time
138171
// Contains extended tests marked as [Serial] (includes Disruptive tests since not used for openshift-tests)
139172
ext.AddSuite(e.Suite{
140173
Name: "olmv0/extended/candidate/serial",
141174
Qualifiers: []string{
142-
`(labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate") && !labels.exists(l, l=="StressTest")) &&
143-
(name.contains("[Serial]") && !name.contains("[Slow]"))`,
175+
filters.BasedExtendedCandidateFuncTests(`(name.contains("[Serial]") && !name.contains("[Slow]"))`),
144176
// it is not used for openshift-tests, so it does not exclude Disruptive, so that we could use
145177
// olmv0/extended/candidate/serial to run all serial case including Disruptive cases
146178
},
147179
})
180+
181+
// Extended Candidate Fast Suite: extended functional tests excluding slow cases
182+
// Contains all extended functional tests that are not marked as [Slow] (includes both Serial and Parallel)
183+
// This provides a comprehensive functional test coverage with reasonable execution time
184+
ext.AddSuite(e.Suite{
185+
Name: "olmv1/extended/candidate/fast",
186+
Qualifiers: []string{
187+
filters.BasedExtendedCandidateFuncTests(`!name.contains("[Slow]")`),
188+
},
189+
})
148190
// Extended Candidate Slow Suite: extended tests that take significant time to run
149191
// Contains extended tests marked as [Slow] (long-running tests not suitable for fast CI)
150192
ext.AddSuite(e.Suite{
151193
Name: "olmv0/extended/candidate/slow",
152194
Qualifiers: []string{
153-
`(labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate") && !labels.exists(l, l=="StressTest")) &&
154-
name.contains("[Slow]")`,
195+
filters.BasedExtendedCandidateFuncTests(`name.contains("[Slow]")`),
155196
},
156197
})
157198
// Extended Candidate Stress Suite: extended stress tests
158199
// Contains extended tests designed for stress testing and resource exhaustion scenarios
159200
ext.AddSuite(e.Suite{
160201
Name: "olmv0/extended/candidate/stress",
161202
Qualifiers: []string{
162-
`labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate") && labels.exists(l, l=="StressTest")`,
203+
filters.BasedExtendedCandidateTests(`labels.exists(l, l=="StressTest")`),
163204
},
164205
})
165206

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Package filters provides utilities for generating test suite qualifiers
2+
// used in the OpenShift OLMv1 test extension framework.
3+
package filters
4+
5+
import (
6+
"fmt"
7+
"strings"
8+
)
9+
10+
// and combines multiple filters using logical AND operator.
11+
// Returns a parenthesized expression joining all filters with " && ".
12+
func and(filters ...string) string {
13+
return fmt.Sprintf("(%s)", strings.Join(filters, " && "))
14+
}
15+
16+
// buildFilter combines a base filter with an optional additional filter.
17+
// If additionalFilter is empty, returns only the base filter wrapped in parentheses.
18+
// Otherwise, combines both filters using logical AND.
19+
func buildFilter(baseFilter, additionalFilter string) string {
20+
if additionalFilter == "" {
21+
return fmt.Sprintf("(%s)", baseFilter)
22+
}
23+
return and(fmt.Sprintf("(%s)", baseFilter), fmt.Sprintf("(%s)", additionalFilter))
24+
}
25+
26+
// BasedStandardTests generates a qualifier for standard tests.
27+
// Includes: non-Extended tests OR Extended tests marked as ReleaseGate.
28+
// Additional filter can be applied to further narrow the selection.
29+
func BasedStandardTests(filter string) string {
30+
standardFilter := `(!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))`
31+
return buildFilter(standardFilter, filter)
32+
}
33+
// BasedExtendedTests generates a qualifier for all extended tests.
34+
// Includes: all tests marked with "Extended" label.
35+
// Additional filter can be applied to further narrow the selection.
36+
func BasedExtendedTests(filter string) string {
37+
extendedFilter := `labels.exists(l, l=="Extended")`
38+
return buildFilter(extendedFilter, filter)
39+
}
40+
// BasedExtendedReleaseGateTests generates a qualifier for extended release gate tests.
41+
// Includes: Extended tests that are also marked as ReleaseGate.
42+
// Additional filter can be applied to further narrow the selection.
43+
func BasedExtendedReleaseGateTests(filter string) string {
44+
extendedReleaseGateFilter := `labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate")`
45+
return buildFilter(extendedReleaseGateFilter, filter)
46+
}
47+
// BasedExtendedCandidateTests generates a qualifier for extended candidate tests.
48+
// Includes: Extended tests that are NOT marked as ReleaseGate.
49+
// Additional filter can be applied to further narrow the selection.
50+
func BasedExtendedCandidateTests(filter string) string {
51+
extendedCandidateFilter := `labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate")`
52+
return buildFilter(extendedCandidateFilter, filter)
53+
}
54+
// BasedExtendedCandidateFuncTests generates a qualifier for extended candidate functional tests.
55+
// Includes: Extended tests that are NOT ReleaseGate and NOT StressTest.
56+
// Additional filter can be applied to further narrow the selection.
57+
func BasedExtendedCandidateFuncTests(filter string) string {
58+
extendedCandidateFuncFilter := `labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate") && !labels.exists(l, l=="StressTest")`
59+
return buildFilter(extendedCandidateFuncFilter, filter)
60+
}

0 commit comments

Comments
 (0)