Atlas › Test

limits_to_TopN_results

Exact test identity: go.temporal.io/server/tools/flakereport/TestSelectTopFlakyTests/limits_to_TopN_results

Package
go.temporal.io/server/tools/flakereport
Suite / test hierarchy
TestSelectTopFlakyTests/limits_to_TopN_results
Test
limits_to_TopN_results
Introduced at
bisect.go ×2 Frontier kind: Joint frontier
Covered ranges
14
Covered lines
47
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/flakereport/bisect.go 41 covered LOC · 13 ranges

Open complete file

352 // selectTopFlakyTests selects the top-N flakiest tests that meet minimum signal thresholds.
353 // allRuns is the full set of test runs. Returns normalized test names sorted by failure rate desc.
354 > func selectTopFlakyTests(allRuns []TestRun, cfg BisectConfig) []string { bisect.go
355 > type testStats struct {
356 > fails int
357 > total int
358 > }
359 > stats := make(map[string]*testStats)
360 > for _, run := range allRuns {
361 > if run.Skipped {
362 continue
363 }
364 > name := normalizeTestName(run.Name) bisect.go
365 > if stats[name] == nil {
366 > stats[name] = &testStats{}
367 > }
368 > stats[name].total++
369 > if run.Failed {
370 > stats[name].fails++
371 > }
372 }
373
374 > type ranked struct { bisect.go
375 > name string
376 > rate float64
377 > fails int
378 > }
379 > var candidates []ranked
380 > for name, s := range stats {
381 > if s.fails < cfg.MinFailures || s.total < cfg.MinRuns { bisect.go
382 continue
383 }
384 > candidates = append(candidates, ranked{ bisect.go
385 > name: name,
386 > rate: float64(s.fails) / float64(s.total),
387 > fails: s.fails,
388 > })
389 }
390
391 > sort.Slice(candidates, func(i, j int) bool { bisect.go
392 > if candidates[i].rate != candidates[j].rate { bisect.go
393 return candidates[i].rate > candidates[j].rate
394 }
395 > return candidates[i].fails > candidates[j].fails bisect.go
396 })
397
398 > n := len(candidates) bisect.go
399 > if cfg.TopN > 0 && cfg.TopN < n {
400 > n = cfg.TopN bisect.go
401 > }
402
403 > names := make([]string, n) bisect.go
404 > for i := range names {
405 > names[i] = candidates[i].name bisect.go
406 > }
407 > return names bisect.go
408 }
409
go.temporal.io/server/tools/flakereport/parser.go 6 covered LOC · 1 range

Open complete file

119 // normalizeTestName strips all trailing parenthesized suffixes from test names,
120 // e.g. "(retry 1)", "(final)", "(timeout)".
121 > func normalizeTestName(name string) string { parser.go
122 > for {
123 > stripped := trailingSuffixRegex.ReplaceAllString(name, "")
124 > if stripped == name {
125 > return name
126 > }
127 name = stripped
128 }