Skip to content

DNM - Testing only - Filter non network tests #29811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: release-4.19
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 84 additions & 71 deletions pkg/test/ginkgo/cmd_runsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"os/signal"
"path/filepath"
"sort"
"strings"
"sync"
"syscall"
"time"

"github.com/onsi/ginkgo/v2"
configv1 "github.com/openshift/api/config/v1"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -246,15 +243,31 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon

// this ensures the tests are always run in random order to avoid
// any intra-tests dependencies
suiteConfig, _ := ginkgo.GinkgoConfiguration()
r := rand.New(rand.NewSource(suiteConfig.RandomSeed))
r.Shuffle(len(tests), func(i, j int) { tests[i], tests[j] = tests[j], tests[i] })
//suiteConfig, _ := ginkgo.GinkgoConfiguration()
//r := rand.New(rand.NewSource(suiteConfig.RandomSeed))
//r.Shuffle(len(tests), func(i, j int) { tests[i], tests[j] = tests[j], tests[i] })

tests = suite.Filter(tests)
if len(tests) == 0 {
return fmt.Errorf("suite %q does not contain any tests", suite.Name)
}

if strings.Contains(suite.Name, "conformance") {
filteredTests := []*testCase{}
for _, test := range tests {
checkName := strings.ToLower(test.name)
if strings.Contains(checkName, "network") {
filteredTests = append(filteredTests, test)
}
}

tests = filteredTests
}

if len(tests) == 0 {
return fmt.Errorf("Filtered suite %q does not contain any tests", suite.Name)
}

logrus.Infof("Found %d filtered tests", len(tests))

count := o.Count
Expand Down Expand Up @@ -500,71 +513,71 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
pass, fail, skip, failing := summarizeTests(tests)

// attempt to retry failures to do flake detection
if fail > 0 && fail <= suite.MaximumAllowedFlakes {
var retries []*testCase

// Make a copy of the all failing tests (subject to the max allowed flakes) so we can have
// a list of tests to retry.
for _, test := range failing {
retry := test.Retry()
retries = append(retries, retry)
if len(retries) > suite.MaximumAllowedFlakes {
break
}
}

logrus.Warningf("Retry count: %d", len(retries))

// Run the tests in the retries list.
q := newParallelTestQueue(testRunnerContext)
q.Execute(testCtx, retries, parallelism, testOutputConfig, abortFn)

var flaky, skipped []string
var repeatFailures []*testCase
for _, test := range retries {
if test.success {
flaky = append(flaky, test.name)
} else if test.skipped {
skipped = append(skipped, test.name)
} else {
repeatFailures = append(repeatFailures, test)
}
}

// Add the list of retries into the list of all tests.
for _, retry := range retries {
if retry.flake {
// Retry tests that flaked are omitted so that the original test is counted as a failure.
fmt.Fprintf(o.Out, "Ignoring retry that returned a flake, original failure is authoritative for test: %s\n", retry.name)
continue
}
tests = append(tests, retry)
}
if len(flaky) > 0 {
failing = repeatFailures
sort.Strings(flaky)
fmt.Fprintf(o.Out, "Flaky tests:\n\n%s\n\n", strings.Join(flaky, "\n"))
}
if len(skipped) > 0 {
// If a retry test got skipped, it means we very likely failed a precondition in the first failure, so
// we need to remove the failure case.
var withoutPreconditionFailures []*testCase
testLoop:
for _, t := range tests {
for _, st := range skipped {
if t.name == st && t.failed {
continue testLoop
}
withoutPreconditionFailures = append(withoutPreconditionFailures, t)
}
}
tests = withoutPreconditionFailures
failing = repeatFailures
sort.Strings(skipped)
fmt.Fprintf(o.Out, "Skipped tests that failed a precondition:\n\n%s\n\n", strings.Join(skipped, "\n"))

}
}
//if fail > 0 && fail <= suite.MaximumAllowedFlakes {
// var retries []*testCase
//
// // Make a copy of the all failing tests (subject to the max allowed flakes) so we can have
// // a list of tests to retry.
// for _, test := range failing {
// retry := test.Retry()
// retries = append(retries, retry)
// if len(retries) > suite.MaximumAllowedFlakes {
// break
// }
// }
//
// logrus.Warningf("Retry count: %d", len(retries))
//
// // Run the tests in the retries list.
// q := newParallelTestQueue(testRunnerContext)
// q.Execute(testCtx, retries, parallelism, testOutputConfig, abortFn)
//
// var flaky, skipped []string
// var repeatFailures []*testCase
// for _, test := range retries {
// if test.success {
// flaky = append(flaky, test.name)
// } else if test.skipped {
// skipped = append(skipped, test.name)
// } else {
// repeatFailures = append(repeatFailures, test)
// }
// }
//
// // Add the list of retries into the list of all tests.
// for _, retry := range retries {
// if retry.flake {
// // Retry tests that flaked are omitted so that the original test is counted as a failure.
// fmt.Fprintf(o.Out, "Ignoring retry that returned a flake, original failure is authoritative for test: %s\n", retry.name)
// continue
// }
// tests = append(tests, retry)
// }
// if len(flaky) > 0 {
// failing = repeatFailures
// sort.Strings(flaky)
// fmt.Fprintf(o.Out, "Flaky tests:\n\n%s\n\n", strings.Join(flaky, "\n"))
// }
// if len(skipped) > 0 {
// // If a retry test got skipped, it means we very likely failed a precondition in the first failure, so
// // we need to remove the failure case.
// var withoutPreconditionFailures []*testCase
// testLoop:
// for _, t := range tests {
// for _, st := range skipped {
// if t.name == st && t.failed {
// continue testLoop
// }
// withoutPreconditionFailures = append(withoutPreconditionFailures, t)
// }
// }
// tests = withoutPreconditionFailures
// failing = repeatFailures
// sort.Strings(skipped)
// fmt.Fprintf(o.Out, "Skipped tests that failed a precondition:\n\n%s\n\n", strings.Join(skipped, "\n"))
//
// }
//}

// monitor the cluster while the tests are running and report any detected anomalies
var syntheticTestResults []*junitapi.JUnitTestCase
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/ginkgo/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *testSuiteRunnerImpl) RunOneTest(ctx context.Context, test *testCase) {
defer recordTestResultInMonitor(testRunResult, r.testOutput.monitorRecorder)

// log the results to systemout
r.testSuiteProgress.LogTestStart(r.testOutput.out, test.name)
r.testSuiteProgress.LogTestStart(r.testOutput.out, time.Now().Format(time.RFC3339)+"_"+test.name)
defer r.testSuiteProgress.TestEnded(test.name, testRunResult)
defer recordTestResultInLogWithoutOverlap(testRunResult, r.testOutput.testOutputLock, r.testOutput.out, r.testOutput.includeSuccessfulOutput)

Expand Down