mirror of https://github.com/golang/go.git
runtime/trace: fix flaky test for SetMinAge
This change fixes the flaky test which expects setting SetMinAge to a small ammount. It expects two sync events but should realistically expect up to 3. Change-Id: Ibd02fe55ebca99eb880025eb968fcebae9cb09c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/675597 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
db55b83ce4
commit
db3e02994c
|
|
@ -170,7 +170,7 @@ func TestFlightRecorderLog(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFlightRecorderOneGeneration(t *testing.T) {
|
func TestFlightRecorderGenerationCount(t *testing.T) {
|
||||||
test := func(t *testing.T, fr *trace.FlightRecorder) {
|
test := func(t *testing.T, fr *trace.FlightRecorder) {
|
||||||
tr := testFlightRecorder(t, fr, func(snapshot func()) {
|
tr := testFlightRecorder(t, fr, func(snapshot func()) {
|
||||||
// Sleep to let a few generations pass.
|
// Sleep to let a few generations pass.
|
||||||
|
|
@ -184,7 +184,7 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
|
||||||
t.Fatalf("unexpected error creating trace reader: %v", err)
|
t.Fatalf("unexpected error creating trace reader: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there are exactly two Sync events: at the start and end.
|
// Make sure there are Sync events: at the start and end.
|
||||||
var syncs []int
|
var syncs []int
|
||||||
evs := 0
|
evs := 0
|
||||||
for {
|
for {
|
||||||
|
|
@ -200,13 +200,18 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
|
||||||
}
|
}
|
||||||
evs++
|
evs++
|
||||||
}
|
}
|
||||||
if ends := []int{0, evs - 1}; !slices.Equal(syncs, ends) {
|
const wantMaxSyncs = 3
|
||||||
t.Errorf("expected two sync events (one at each end of the trace), found %d at %d instead of %d",
|
if len(syncs) > wantMaxSyncs {
|
||||||
len(syncs), syncs[:min(len(syncs), 5)], ends)
|
t.Errorf("expected at most %d sync events, found %d at %d",
|
||||||
|
wantMaxSyncs, len(syncs), syncs)
|
||||||
|
}
|
||||||
|
ends := []int{syncs[0], syncs[len(syncs)-1]}
|
||||||
|
if wantEnds := []int{0, evs - 1}; !slices.Equal(wantEnds, ends) {
|
||||||
|
t.Errorf("expected a sync event at each end of the trace, found sync events at %d instead of %d",
|
||||||
|
ends, wantEnds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Run("SetMinAge", func(t *testing.T) {
|
t.Run("MinAge", func(t *testing.T) {
|
||||||
t.Skip("issue 63185: flaky test")
|
|
||||||
fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{MinAge: time.Millisecond})
|
fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{MinAge: time.Millisecond})
|
||||||
test(t, fr)
|
test(t, fr)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue