Skip to content

Commit fad1dc6

Browse files
qmuntalgopherbot
authored andcommitted
runtime: don't artificially limit TestReadMetricsSched
TestReadMetricsSched/running can take some time to enter in steady state on busy systems. We currently only allow 1 second for that, we should let it run unlimitedly until success or the test time's out. Fixes #75049 Change-Id: I452059e1837caf12a2d2d9cae1f70a0ef2d4f518 Reviewed-on: https://go-review.googlesource.com/c/go/+/702295 Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent b1f3e38 commit fad1dc6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/runtime/metrics_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,15 +1632,13 @@ func TestReadMetricsSched(t *testing.T) {
16321632
checkEq := func(t *testing.T, s *metrics.Sample, value uint64) {
16331633
check(t, s, value, value)
16341634
}
1635-
spinUntil := func(f func() bool, timeout time.Duration) bool {
1636-
start := time.Now()
1637-
for time.Since(start) < timeout {
1635+
spinUntil := func(f func() bool) bool {
1636+
for {
16381637
if f() {
16391638
return true
16401639
}
1641-
time.Sleep(time.Millisecond)
1640+
time.Sleep(50 * time.Millisecond)
16421641
}
1643-
return false
16441642
}
16451643

16461644
// Check base values.
@@ -1693,12 +1691,12 @@ func TestReadMetricsSched(t *testing.T) {
16931691
t.Run("running", func(t *testing.T) {
16941692
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(count + 4))
16951693
// It can take a little bit for the scheduler to
1696-
// distribute the goroutines to Ps, so retry for a
1697-
// while.
1694+
// distribute the goroutines to Ps, so retry until
1695+
// we see the count we expect or the test times out.
16981696
spinUntil(func() bool {
16991697
metrics.Read(s[:])
17001698
return s[running].Value.Uint64() >= count
1701-
}, time.Second)
1699+
})
17021700
logMetrics(t, s[:])
17031701
check(t, &s[running], count, count+4)
17041702
check(t, &s[threads], count, count+4+threadsSlack)
@@ -1761,7 +1759,7 @@ func TestReadMetricsSched(t *testing.T) {
17611759
spinUntil(func() bool {
17621760
metrics.Read(s[:])
17631761
return s[notInGo].Value.Uint64() >= count
1764-
}, time.Second)
1762+
})
17651763

17661764
metrics.Read(s[:])
17671765
logMetrics(t, s[:])
@@ -1783,7 +1781,7 @@ func TestReadMetricsSched(t *testing.T) {
17831781
spinUntil(func() bool {
17841782
metrics.Read(s[:])
17851783
return s[waiting].Value.Uint64() >= waitingCount
1786-
}, time.Second)
1784+
})
17871785

17881786
metrics.Read(s[:])
17891787
logMetrics(t, s[:])

0 commit comments

Comments
 (0)