From 31fbeb4b331e5c74a597672a7303a874c3ab83fe Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 27 Dec 2024 11:26:27 +0800 Subject: [PATCH] redo(ticdc): Fix RedoLogWriter unit test (#11853) (#11937) close pingcap/tiflow#11852 --- cdc/redo/writer/memory/mem_log_writer_test.go | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/cdc/redo/writer/memory/mem_log_writer_test.go b/cdc/redo/writer/memory/mem_log_writer_test.go index 12f34ce11e8..5914328b4a1 100644 --- a/cdc/redo/writer/memory/mem_log_writer_test.go +++ b/cdc/redo/writer/memory/mem_log_writer_test.go @@ -106,12 +106,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