Skip to content

featuregate analyzer: use 1 week lookback if possible #2009

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

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
26 changes: 18 additions & 8 deletions tools/codegen/cmd/featuregate-test-analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
requiredNumberOfTests = 5

// all variant should run at least this many times
requiredNumberOfTestRunsPerVariantInTwoWeeks = 14
requiredNumberOfTestRunsPerVariant = 14

// required pass rate.
// nearly all current tests pass 99% of the time, but in a two week window we lack enough data to say.
Expand Down Expand Up @@ -248,8 +248,8 @@ func checkIfTestingIsSufficient(featureGate string, testingResults map[JobVarian
errs = append(errs, fmt.Errorf("error: only %d tests found, need at least %d for %q on %v", len(testedVariant.TestResults), requiredNumberOfTests, featureGate, jobVariant))
}
for _, testResults := range testedVariant.TestResults {
if testResults.TotalRuns < requiredNumberOfTestRunsPerVariantInTwoWeeks {
errs = append(errs, fmt.Errorf("error: %q only has %d runs, need at least %d runs for %q on %v", testResults.TestName, testResults.TotalRuns, requiredNumberOfTestRunsPerVariantInTwoWeeks, featureGate, jobVariant))
if testResults.TotalRuns < requiredNumberOfTestRunsPerVariant {
errs = append(errs, fmt.Errorf("error: %q only has %d runs, need at least %d runs for %q on %v", testResults.TestName, testResults.TotalRuns, requiredNumberOfTestRunsPerVariant, featureGate, jobVariant))
}
if testResults.TotalRuns == 0 {
continue
Expand Down Expand Up @@ -312,7 +312,7 @@ func writeTestingMarkDown(testingResults map[JobVariant]*TestingResults, md *uti
failString := ""
passPercent := float32(testResults.SuccessfulRuns) / float32(testResults.TotalRuns)
switch {
case testResults.TotalRuns < requiredNumberOfTestRunsPerVariantInTwoWeeks:
case testResults.TotalRuns < requiredNumberOfTestRunsPerVariant:
failString = "FAIL <br/> "
case passPercent < requiredPassRateOfTestsPerVariant:
failString = "FAIL <br/> "
Expand Down Expand Up @@ -628,10 +628,20 @@ func listTestResultForVariant(featureGate string, jobVariant JobVariant) (*Testi
}
}

testResults.TotalRuns += currTest.CurrentRuns + currTest.PreviousRuns
testResults.SuccessfulRuns += currTest.CurrentSuccesses + currTest.PreviousSuccesses
testResults.FailedRuns += currTest.CurrentFailures + currTest.PreviousFailures
testResults.FlakedRuns += currTest.CurrentFlakes + currTest.PreviousFlakes
// Try to find enough test results in the last week, but if we have to we can extend
// the window to two weeks.
if currTest.CurrentRuns >= requiredNumberOfTestRunsPerVariant {
testResults.TotalRuns = currTest.CurrentRuns
testResults.SuccessfulRuns = currTest.CurrentSuccesses
testResults.FailedRuns = currTest.CurrentFailures
testResults.FlakedRuns = currTest.CurrentFlakes
} else {
fmt.Printf("Insufficient results in last 7 days, increasing lookback to 2 weeks...")
testResults.TotalRuns += currTest.CurrentRuns + currTest.PreviousRuns
testResults.SuccessfulRuns += currTest.CurrentSuccesses + currTest.PreviousSuccesses
testResults.FailedRuns += currTest.CurrentFailures + currTest.PreviousFailures
testResults.FlakedRuns += currTest.CurrentFlakes + currTest.PreviousFlakes
}
testNameToResults[currTest.Name] = testResults
}
}
Expand Down