Atlas › Test

TestBuildObservations

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

Package
go.temporal.io/server/tools/flakereport
Suite / test hierarchy
TestBuildObservations
Test
TestBuildObservations
Introduced at
bisect.go ×4 Frontier kind: Joint frontier
Covered ranges
13
Covered lines
48
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 · 11 ranges

Open complete file

66 // commitOrder lists SHAs from oldest to newest.
67 // Runs whose SHA is not in commitOrder are skipped (e.g. from force-pushes or unrelated branches).
68 > func buildObservations(testName string, runs []TestRun, commitOrderSlice []string, runToSHA map[int64]string) []CommitObservation { bisect.go
69 > // Build commit index map: SHA → index
70 > commitIdx := make(map[string]int, len(commitOrderSlice))
71 > for i, sha := range commitOrderSlice {
72 > commitIdx[sha] = i
73 > }
74
75 // Aggregate pass/fail counts per commit SHA for this test
76 > type counts struct{ passes, fails int } bisect.go
77 > bySHA := make(map[string]*counts)
78 >
79 > for _, run := range runs {
80 > if run.Skipped {
81 > continue bisect.go
82 }
83 > if normalizeTestName(run.Name) != testName { bisect.go
84 > continue bisect.go
85 }
86 > sha, ok := runToSHA[run.RunID] bisect.go
87 > if !ok || sha == "" {
88 > continue bisect.go
89 }
90 > if _, inOrder := commitIdx[sha]; !inOrder { bisect.go
91 > continue bisect.go
92 }
93 > if bySHA[sha] == nil { bisect.go
94 > bySHA[sha] = &counts{}
95 > }
96 > if run.Failed {
97 > bySHA[sha].fails++
98 > } else {
99 > bySHA[sha].passes++
100 > }
101 }
102
103 // Convert to slice and sort by commit index
104 > obs := make([]CommitObservation, 0, len(bySHA)) bisect.go
105 > for sha, c := range bySHA {
106 > obs = append(obs, CommitObservation{
107 > CommitSHA: sha,
108 > CommitIdx: commitIdx[sha],
109 > Prior: 1.0, // uniform prior; adjusted by heuristics if enabled
110 > Passes: c.passes,
111 > Fails: c.fails,
112 > })
113 > }
114 > sort.Slice(obs, func(i, j int) bool {
115 > return obs[i].CommitIdx < obs[j].CommitIdx
116 > })
117 > return obs
118 }
119
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 }