Skip to content

Commit e23edf5

Browse files
mknyszekgopherbot
authored andcommitted
runtime: don't re-read metrics before check in TestReadMetricsSched
The two remaining popular flakes in TestReadMetricsSched are with waiting and not-in-go goroutines. I believe the reason for both of these is pollution due to other goroutines in the test binary, and we can be a little bit more robust to them. In particular, both of these tests spin until there's a particular condition met in the metrics. Then they both immediately re-read the metrics. The metrics being checked are not guaranteed to stay that way in the re-read. For example, for the waiting case, it's possible for >1000 to be waiting, but then some leftover goroutines from a previous test wake up off of some condition, causing the number to dip again on the re-read. This is supported by the fact that in some of these failures, the test takes very little time to execute (the condition that there are at least 1000 waiting goroutines is almost immediately satisfied) but it still fails (the re-read causes us to notice that there are <1000 waiting goroutines). This change makes the test more robust by not performing this re-read. This means more possible false negatives, but the error cases we're looking for (bad metrics) should still show up with some reasonable probability when something *is* truly wrong. For #75049. Change-Id: Idc3a8030bed8da51f24322efe15f3ff13da05623 Reviewed-on: https://go-review.googlesource.com/c/go/+/705875 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 177cd8d commit e23edf5

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/runtime/metrics_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,6 @@ func TestReadMetricsSched(t *testing.T) {
17601760
metrics.Read(s[:])
17611761
return s[notInGo].Value.Uint64() >= count
17621762
})
1763-
1764-
metrics.Read(s[:])
17651763
logMetrics(t, s[:])
17661764
check(t, &s[notInGo], count, count+generalSlack)
17671765

@@ -1782,8 +1780,6 @@ func TestReadMetricsSched(t *testing.T) {
17821780
metrics.Read(s[:])
17831781
return s[waiting].Value.Uint64() >= waitingCount
17841782
})
1785-
1786-
metrics.Read(s[:])
17871783
logMetrics(t, s[:])
17881784
check(t, &s[waiting], waitingCount, waitingCount+waitingSlack)
17891785

0 commit comments

Comments
 (0)