Atlas › Test

TestClassifyFailures

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

Package
go.temporal.io/server/tools/flakereport
Suite / test hierarchy
TestClassifyFailures
Test
TestClassifyFailures
Introduced at
parser.go ×5 Frontier kind: Joint frontier
Covered ranges
7
Covered lines
38
Covered files
1

Covered source

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

go.temporal.io/server/tools/flakereport/parser.go 38 covered LOC · 7 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 }
130
131 // groupFailuresByTest groups failures by normalized test name
132 > func groupFailuresByTest(failures []TestFailure) map[string][]TestFailure { parser.go
133 > grouped := make(map[string][]TestFailure)
134 >
135 > for _, failure := range failures {
136 > normalizedName := normalizeTestName(failure.Name)
137 > grouped[normalizedName] = append(grouped[normalizedName], failure)
138 > }
139
140 > return grouped parser.go
141 }
142
158 // classifyFailure returns "timeout", "crash", or "flaky" based on the test name.
159 // Uses Contains (not HasSuffix) so it works on both raw and normalized names.
160 > func classifyFailure(name string) string { parser.go
161 > lower := strings.ToLower(name)
162 > if strings.Contains(lower, "(timeout)") {
163 > return "timeout"
164 > }
165 > if strings.Contains(lower, "(crash)") {
166 > return "crash"
167 > }
168 > return "flaky"
169 }
170
172 // Classifies using the raw failure name (not the normalized key) since
173 // normalizeTestName strips suffixes like "(timeout)".
174 > func classifyFailures(grouped map[string][]TestFailure) (flaky, timeout, crash map[string][]TestFailure) { parser.go
175 > flaky = make(map[string][]TestFailure)
176 > timeout = make(map[string][]TestFailure)
177 > crash = make(map[string][]TestFailure)
178 >
179 > for testName, failures := range grouped {
180 > switch classifyFailure(failures[0].Name) {
181 > case "timeout":
182 > timeout[testName] = failures
183 > case "crash":
184 > crash[testName] = failures
185 > case "flaky":
186 > flaky[testName] = failures
187 default:
188 panic("unknown failure classification: " + classifyFailure(failures[0].Name)) //nolint:forbidigo
190 }
191
192 > return flaky, timeout, crash parser.go
193 }
194