Skip to content

Commit 83d9db8

Browse files
committedSep 20, 2017
Make focus and skip a lot easier to use in extended tests
Now: ginkgo ... -focus=Suite:openshift/conformance/parallel ginkgo ... -focus=Suite:openshift/conformance/serial Both ginkgo ... -focus=Suite:openshift/conformance Kubernetes ginkgo ... -focus=Suite:k8s
1 parent 063ae07 commit 83d9db8

File tree

1 file changed

+56
-32
lines changed

1 file changed

+56
-32
lines changed
 

Diff for: ‎test/extended/util/test.go

+56-32
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/onsi/ginkgo"
1515
"github.com/onsi/ginkgo/config"
1616
"github.com/onsi/ginkgo/reporters"
17+
"github.com/onsi/ginkgo/types"
1718
"github.com/onsi/gomega"
1819

1920
apierrs "k8s.io/apimachinery/pkg/api/errors"
@@ -53,7 +54,7 @@ func InitTest() {
5354

5455
e2e.RegisterCommonFlags()
5556
e2e.RegisterClusterFlags()
56-
flag.StringVar(&syntheticSuite, "suite", "", "Optional suite selector to filter which tests are run.")
57+
flag.StringVar(&syntheticSuite, "suite", "", "DEPRECATED: Optional suite selector to filter which tests are run. Use focus.")
5758

5859
extendedOutputDir := filepath.Join(os.TempDir(), "openshift-extended-tests")
5960
os.MkdirAll(extendedOutputDir, 0777)
@@ -103,16 +104,55 @@ func ExecuteTest(t *testing.T, suite string) {
103104
defer e2e.CoreDump(reportDir)
104105
}
105106

106-
// Disable density test unless it's explicitly requested.
107+
switch syntheticSuite {
108+
case "parallel.conformance.openshift.io":
109+
if len(config.GinkgoConfig.FocusString) > 0 {
110+
config.GinkgoConfig.FocusString += "|"
111+
}
112+
config.GinkgoConfig.FocusString = "\\[Suite:openshift/conformance/parallel\\]"
113+
case "serial.conformance.openshift.io":
114+
if len(config.GinkgoConfig.FocusString) > 0 {
115+
config.GinkgoConfig.FocusString += "|"
116+
}
117+
config.GinkgoConfig.FocusString = "\\[Suite:openshift/conformance/serial\\]"
118+
}
107119
if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" {
108120
config.GinkgoConfig.SkipString = "Skipped"
109121
}
122+
110123
gomega.RegisterFailHandler(ginkgo.Fail)
111124

112125
if reportDir != "" {
113126
r = append(r, reporters.NewJUnitReporter(path.Join(reportDir, fmt.Sprintf("%s_%02d.xml", reportFileName, config.GinkgoConfig.ParallelNode))))
114127
}
115128

129+
ginkgo.WalkTests(func(name string, node types.TestNode) {
130+
isSerial := serialTestsFilter.MatchString(name)
131+
if isSerial {
132+
if !strings.Contains(name, "[Serial]") {
133+
node.SetText(node.Text() + " [Serial]")
134+
}
135+
}
136+
137+
if !excludedTestsFilter.MatchString(name) {
138+
include := conformanceTestsFilter.MatchString(name)
139+
switch {
140+
case !include:
141+
// do nothing
142+
case isSerial:
143+
node.SetText(node.Text() + " [Suite:openshift/conformance/serial]")
144+
case include:
145+
node.SetText(node.Text() + " [Suite:openshift/conformance/parallel]")
146+
}
147+
}
148+
if strings.Contains(node.CodeLocation().FileName, "/origin/test/") && !strings.Contains(node.Text(), "[Suite:openshift") {
149+
node.SetText(node.Text() + " [Suite:openshift]")
150+
}
151+
if strings.Contains(node.CodeLocation().FileName, "/kubernetes/test/e2e/") {
152+
node.SetText(node.Text() + " [Suite:k8s]")
153+
}
154+
})
155+
116156
if quiet {
117157
r = append(r, NewSimpleReporter())
118158
ginkgo.RunSpecsWithCustomReporters(t, suite, r)
@@ -210,7 +250,6 @@ func createTestingNS(baseName string, c kclientset.Interface, labels map[string]
210250
var (
211251
excludedTests = []string{
212252
`\[Skipped\]`,
213-
`\[Disruptive\]`,
214253
`\[Slow\]`,
215254
`\[Flaky\]`,
216255
`\[Compatibility\]`,
@@ -311,7 +350,10 @@ var (
311350
}
312351
excludedTestsFilter = regexp.MustCompile(strings.Join(excludedTests, `|`))
313352

314-
parallelConformanceTests = []string{
353+
// The list of tests to run for the OpenShift conformance suite. Any test
354+
// in this group which cannot be run in parallel must be identified with the
355+
// [Serial] tag or added to the serialTests filter.
356+
conformanceTests = []string{
315357
`\[Conformance\]`,
316358
`Services.*NodePort`,
317359
`ResourceQuota should`,
@@ -327,7 +369,7 @@ var (
327369
`Job should run a job to completion when tasks succeed`,
328370
`Variable Expansion`,
329371
`init containers`,
330-
`Clean up pods on node kubelet`,
372+
`Clean up pods on node kubelet`, // often catches issues
331373
`\[Feature\:SecurityContext\]`,
332374
`should create a LimitRange with defaults`,
333375
`Generated release_1_2 clientset`,
@@ -336,46 +378,28 @@ var (
336378
`ImageLookup`,
337379
`DNS for pods for Hostname and Subdomain Annotation`,
338380
}
339-
parallelConformanceTestsFilter = regexp.MustCompile(strings.Join(parallelConformanceTests, `|`))
381+
conformanceTestsFilter = regexp.MustCompile(strings.Join(conformanceTests, `|`))
340382

341-
serialConformanceTests = []string{
383+
// Identifies any tests that by nature must be run in isolation. Every test in this
384+
// category will be given the [Serial] tag if it does not already have it.
385+
serialTests = []string{
342386
`\[Serial\]`,
387+
`\[Disruptive\]`,
343388
`\[Feature:ManualPerformance\]`, // requires isolation
344-
`Service endpoints latency`, // requires low latency
345389
`\[Feature:HighDensityPerformance\]`, // requires no other namespaces
346-
`Clean up pods on node`, // schedules max pods per node
390+
`Service endpoints latency`, // requires low latency
391+
`Clean up pods on node`, // schedules up to max pods per node
347392
}
348-
serialConformanceTestsFilter = regexp.MustCompile(strings.Join(serialConformanceTests, `|`))
393+
serialTestsFilter = regexp.MustCompile(strings.Join(serialTests, `|`))
349394
)
350395

351396
// checkSyntheticInput selects tests based on synthetic skips or focuses
352397
func checkSyntheticInput() {
353-
checkSuiteFocuses()
354398
checkSuiteSkips()
355399
}
356400

357-
// checkSuiteFocuses ensures Origin conformance suite synthetic labels are applied
358-
func checkSuiteFocuses() {
359-
if !strings.Contains(syntheticSuite, "conformance.openshift.io") {
360-
return
361-
}
362-
363-
testName := []byte(ginkgo.CurrentGinkgoTestDescription().FullTestText)
364-
testFocused := false
365-
textExcluded := excludedTestsFilter.Match(testName)
366-
if syntheticSuite == "parallel.conformance.openshift.io" {
367-
testFocused = parallelConformanceTestsFilter.Match(testName)
368-
textExcluded = textExcluded || serialConformanceTestsFilter.Match(testName)
369-
} else if syntheticSuite == "serial.conformance.openshift.io" {
370-
testFocused = serialConformanceTestsFilter.Match(testName)
371-
}
372-
373-
if !testFocused || textExcluded {
374-
ginkgo.Skip("skipping tests not in the Origin conformance suite")
375-
}
376-
}
377-
378401
// checkSuiteSkips ensures Origin/Kubernetes synthetic skip labels are applied
402+
// DEPRECATED: remove in a future release
379403
func checkSuiteSkips() {
380404
switch {
381405
case isOriginTest():

0 commit comments

Comments
 (0)