You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #76540 reports failures in this test from the leaked goroutine
count being too small. The test makes an effort to wait for the
goroutines to leak, but there's no guarantee.
This change instead changes TestGoroutineLeakProfileConcurrency to wait
for the number of leaked goroutines to reach at least the minimum
expected before proceeding. This deflakes this particular issue.
The downside of this change is that a failure to detect leaked
goroutines due to a bug will lead to a timeout instead of an instant
failure, but this change makes an effort to log and report that it was
waiting for the goroutines to leak and timed out for that reason, so at
least the failure is more obvious.
Overall, this is still better than random flakes.
While we're here, I also make some minor stylistic changes and document
the helper functions a little more. I also noticed that checkFrames was
using the wrong *testing.T, so this change fixes that too.
Fixes#76540.
Change-Id: I0508855dc39b91f8c6b72d059ce88dbfc68fe748
Reviewed-on: https://go-review.googlesource.com/c/go/+/729280
Reviewed-by: Cherry Mui <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
t.Errorf("leaked goroutine stack expected %s as the location[%d].Line[%d] but found %s (%s:%d)", expectedFunctionName, i, j, location.Line[j].Function.Name, location.Line[j].Function.Filename, location.Line[j].Line)
1612
-
}
1613
-
}
1614
-
1615
-
// We use this helper to count the total number of leaked goroutines in the profile.
1616
-
//
1617
-
// NOTE(vsaioc): This value should match for the number of leaks produced in this test,
1618
-
// but other tests could also leak goroutines, in which case we would have a mismatch
1619
-
// when bulk-running tests.
1620
-
//
1621
-
// The two mismatching outcomes are therefore:
1622
-
// - More leaks than expected, which is a correctness issue with other tests.
1623
-
// In this case, this test effectively checks other tests wrt
1624
-
// goroutine leaks during bulk executions (e.g., running all.bash).
1625
-
//
1626
-
// - Fewer leaks than expected; this is an unfortunate symptom of scheduling
1627
-
// non-determinism, which may occur once in a blue moon. We make
1628
-
// a best-effort attempt to allow the expected leaks to occur, by yielding
t.Fatalf("goroutineleak profile does not contain 'goroutineleak profile: total ': %s\nparts: %v", s, parts)
1635
-
return
1636
-
}
1637
-
1638
-
parts=whiteSpace.Split(parts[1], -1)
1639
-
1640
-
count, err:=strconv.ParseInt(parts[0], 10, 64)
1641
-
iferr!=nil {
1642
-
t.Fatalf("goroutineleak profile count is not a number: %s\nerror: %v", s, err)
1643
-
}
1644
-
1645
-
// Check that the total number of leaked goroutines is exactly the expected number.
1646
-
ifcount!=int64(number) {
1647
-
t.Errorf("goroutineleak profile does not contain exactly %d leaked goroutines: %d", number, count)
1626
+
iflocation.Line[j].Function.Name!=funcName {
1627
+
t.Errorf("leaked goroutine stack expected %s as location[%d].Line[%d] but found %s (%s:%d)", funcName, i, j, location.Line[j].Function.Name, location.Line[j].Function.Filename, location.Line[j].Line)
1648
1628
}
1649
1629
}
1650
1630
1631
+
// checkLeakStack hooks into profile parsing and performs validation, looking for specific stacks for
0 commit comments