Skip to content

Commit db3e029

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent db55b83 commit db3e029

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/runtime/trace/flightrecorder_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func TestFlightRecorderLog(t *testing.T) {
170170
}
171171
}
172172

173-
func TestFlightRecorderOneGeneration(t *testing.T) {
173+
func TestFlightRecorderGenerationCount(t *testing.T) {
174174
test := func(t *testing.T, fr *trace.FlightRecorder) {
175175
tr := testFlightRecorder(t, fr, func(snapshot func()) {
176176
// Sleep to let a few generations pass.
@@ -184,7 +184,7 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
184184
t.Fatalf("unexpected error creating trace reader: %v", err)
185185
}
186186

187-
// Make sure there are exactly two Sync events: at the start and end.
187+
// Make sure there are Sync events: at the start and end.
188188
var syncs []int
189189
evs := 0
190190
for {
@@ -200,13 +200,18 @@ func TestFlightRecorderOneGeneration(t *testing.T) {
200200
}
201201
evs++
202202
}
203-
if ends := []int{0, evs - 1}; !slices.Equal(syncs, ends) {
204-
t.Errorf("expected two sync events (one at each end of the trace), found %d at %d instead of %d",
205-
len(syncs), syncs[:min(len(syncs), 5)], ends)
203+
const wantMaxSyncs = 3
204+
if len(syncs) > wantMaxSyncs {
205+
t.Errorf("expected at most %d sync events, found %d at %d",
206+
wantMaxSyncs, len(syncs), syncs)
207+
}
208+
ends := []int{syncs[0], syncs[len(syncs)-1]}
209+
if wantEnds := []int{0, evs - 1}; !slices.Equal(wantEnds, ends) {
210+
t.Errorf("expected a sync event at each end of the trace, found sync events at %d instead of %d",
211+
ends, wantEnds)
206212
}
207213
}
208-
t.Run("SetMinAge", func(t *testing.T) {
209-
t.Skip("issue 63185: flaky test")
214+
t.Run("MinAge", func(t *testing.T) {
210215
fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{MinAge: time.Millisecond})
211216
test(t, fr)
212217
})

0 commit comments

Comments
 (0)