From 1b50c470b099c1da713fcb520448542d5c51daa9 Mon Sep 17 00:00:00 2001 From: zhaoxinyu Date: Thu, 21 Jul 2022 15:17:50 +0800 Subject: [PATCH] fix an unstable ut --- cdc/owner/feed_state_manager_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cdc/owner/feed_state_manager_test.go b/cdc/owner/feed_state_manager_test.go index 21fba6c2e60..e2881e875e2 100644 --- a/cdc/owner/feed_state_manager_test.go +++ b/cdc/owner/feed_state_manager_test.go @@ -488,8 +488,8 @@ func TestChangefeedNotRetry(t *testing.T) { func TestBackoffStopsUnexpectedly(t *testing.T) { ctx := cdcContext.NewBackendContext4Test(true) - // after 2000ms, the backoff will stop - manager := newFeedStateManager4Test(100, 100, 2000, 1.0) + // after 4000ms, the backoff will stop + manager := newFeedStateManager4Test(500, 500, 4000, 1.0) state := orchestrator.NewChangefeedReactorState(etcd.DefaultCDCClusterID, ctx.ChangefeedVars().ID) tester := orchestrator.NewReactorStateTester(t, state, nil) @@ -506,7 +506,7 @@ func TestBackoffStopsUnexpectedly(t *testing.T) { manager.Tick(state) tester.MustApplyPatches() - for i := 1; i <= 30; i++ { + for i := 1; i <= 10; i++ { require.Equal(t, state.Info.State, model.StateNormal) require.True(t, manager.ShouldRunning()) state.PatchTaskPosition(ctx.GlobalVars().CaptureInfo.ID, @@ -520,10 +520,10 @@ func TestBackoffStopsUnexpectedly(t *testing.T) { tester.MustApplyPatches() manager.Tick(state) tester.MustApplyPatches() - // after round 20, the maxElapsedTime of backoff will exceed 2000ms, + // after round 8, the maxElapsedTime of backoff will exceed 4000ms, // and NextBackOff() will return -1, so the changefeed state will // never turn into error state. - if i >= 20 { + if i >= 8 { require.True(t, manager.ShouldRunning()) require.Equal(t, state.Info.State, model.StateNormal) } else { @@ -532,9 +532,9 @@ func TestBackoffStopsUnexpectedly(t *testing.T) { require.Equal(t, state.Info.AdminJobType, model.AdminStop) require.Equal(t, state.Status.AdminJobType, model.AdminStop) } - // 100ms is the backoff interval, so sleep 100ms and after a manager tick, + // 500ms is the backoff interval, so sleep 500ms and after a manager tick, // the changefeed will turn into normal state - time.Sleep(100 * time.Millisecond) + time.Sleep(500 * time.Millisecond) manager.Tick(state) tester.MustApplyPatches() }