From: Carlos Amedee Date: Thu, 22 May 2025 17:33:28 +0000 (-0400) Subject: runtime/trace: fix flaky test for SetMinAge X-Git-Tag: go1.25rc1~77 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=db3e02994c98f1d6dc00f7df807579c4619885c7;p=gostls13.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 LUCI-TryBot-Result: Go LUCI --- diff --git a/src/runtime/trace/flightrecorder_test.go b/src/runtime/trace/flightrecorder_test.go index 075215db00..61cb03dcf6 100644 --- a/src/runtime/trace/flightrecorder_test.go +++ b/src/runtime/trace/flightrecorder_test.go @@ -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) { tr := testFlightRecorder(t, fr, func(snapshot func()) { // 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) } - // 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 evs := 0 for { @@ -200,13 +200,18 @@ func TestFlightRecorderOneGeneration(t *testing.T) { } evs++ } - if ends := []int{0, evs - 1}; !slices.Equal(syncs, ends) { - t.Errorf("expected two sync events (one at each end of the trace), found %d at %d instead of %d", - len(syncs), syncs[:min(len(syncs), 5)], ends) + const wantMaxSyncs = 3 + if len(syncs) > wantMaxSyncs { + 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.Skip("issue 63185: flaky test") + t.Run("MinAge", func(t *testing.T) { fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{MinAge: time.Millisecond}) test(t, fr) })