1
0
mirror of https://github.com/golang/go synced 2024-11-21 16:34:42 -07:00

runtime/pprof: continued attempt to deflake the VMInfo test.

This PR will use test.Skip to bypass a test run for which the vmmap
subprocess appears to hang before the test times out.
In addition it catches a different error message from vmmap that can
occur due to transient resource shortages and triggers a retry for
this additional case.

Fixes #62352

Change-Id: I3ae749e5cd78965c45b1b7c689b896493aa37ba0
Reviewed-on: https://go-review.googlesource.com/c/go/+/560935
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cosmos Nicolaou 2024-02-02 17:12:27 -08:00 committed by Cherry Mui
parent 992f63583a
commit 8ac0a7c512

View File

@ -17,6 +17,7 @@ import (
"strconv"
"strings"
"testing"
"time"
)
func TestVMInfo(t *testing.T) {
@ -56,18 +57,35 @@ func TestVMInfo(t *testing.T) {
}
}
type mapping struct {
hi, lo uint64
err error
}
func useVMMapWithRetry(t *testing.T) (hi, lo uint64, err error) {
var retryable bool
for {
hi, lo, retryable, err = useVMMap(t)
if err == nil {
return hi, lo, nil
ch := make(chan mapping)
go func() {
for {
hi, lo, retryable, err = useVMMap(t)
if err == nil {
ch <- mapping{hi, lo, nil}
return
}
if !retryable {
ch <- mapping{0, 0, err}
return
}
t.Logf("retrying vmmap after error: %v", err)
}
if !retryable {
return 0, 0, err
}
t.Logf("retrying vmmap after error: %v", err)
}()
select {
case m := <-ch:
return m.hi, m.lo, m.err
case <-time.After(time.Minute):
t.Skip("vmmap taking too long")
}
return 0, 0, fmt.Errorf("unreachable")
}
func useVMMap(t *testing.T) (hi, lo uint64, retryable bool, err error) {