Atlas › Test

normalizes_test_names

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

Package
go.temporal.io/server/tools/flakereport
Suite / test hierarchy
TestSelectTopFlakyTests/normalizes_test_names
Test
normalizes_test_names
Introduced at
normalizes_test_names Frontier kind: Test frontier
Covered ranges
12
Covered lines
44
Covered files
2

Covered source

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

go.temporal.io/server/tools/flakereport/bisect.go 37 covered LOC · 10 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 {
393 return candidates[i].rate > candidates[j].rate
396 })
397
398 > n := len(candidates) bisect.go
399 > if cfg.TopN > 0 && cfg.TopN < n {
400 n = cfg.TopN
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 7 covered LOC · 2 ranges

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 parser.go
128 }
129 }