diff --git a/cdc/redo/writer/memory/mem_log_writer_test.go b/cdc/redo/writer/memory/mem_log_writer_test.go index b72b106e92b..e8a21aea4bb 100644 --- a/cdc/redo/writer/memory/mem_log_writer_test.go +++ b/cdc/redo/writer/memory/mem_log_writer_test.go @@ -101,12 +101,30 @@ func testWriteEvents(t *testing.T, events []writer.RedoEvent) { functions := map[string]func(error){ "WriteEvents": func(expected error) { - err := lw.WriteEvents(ctx, events...) - require.ErrorIs(t, errors.Cause(err), expected) + if expected == nil { + err := lw.WriteEvents(ctx, events...) + require.NoError(t, err) + } else { + require.Eventually( + t, func() bool { + err := lw.WriteEvents(ctx, events...) + return errors.Is(errors.Cause(err), expected) + }, time.Second*2, time.Microsecond*10, + ) + } }, "FlushLog": func(expected error) { - err := lw.FlushLog(ctx) - require.ErrorIs(t, errors.Cause(err), expected) + if expected == nil { + err := lw.FlushLog(ctx) + require.NoError(t, err) + } else { + require.Eventually( + t, func() bool { + err := lw.WriteEvents(ctx, events...) + return errors.Is(errors.Cause(err), expected) + }, time.Second*2, time.Microsecond*10, + ) + } }, } firstCall := true