From 1c9d29a82eeeec41f037111b6dba4455b661ace2 Mon Sep 17 00:00:00 2001 From: hillium Date: Thu, 20 Apr 2023 18:03:41 +0800 Subject: [PATCH] assert over back off time Signed-off-by: hillium --- br/pkg/utils/retry_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/br/pkg/utils/retry_test.go b/br/pkg/utils/retry_test.go index 482c8db7f4897..eeef8c61c0480 100644 --- a/br/pkg/utils/retry_test.go +++ b/br/pkg/utils/retry_test.go @@ -6,6 +6,7 @@ import ( "context" "sync" "testing" + "time" "github.com/pingcap/errors" "github.com/pingcap/tidb/br/pkg/utils" @@ -16,6 +17,7 @@ import ( func TestRetryAdapter(t *testing.T) { req := require.New(t) + begin := time.Now() bo := utils.AdaptTiKVBackoffer(context.Background(), 200, errors.New("everything is alright")) // This should sleep for 100ms. bo.Inner().Backoff(tikv.BoTiKVRPC(), errors.New("TiKV is in a deep dream")) @@ -42,4 +44,6 @@ func TestRetryAdapter(t *testing.T) { bo.RequestBackOff(150) req.ErrorContains(bo.BackOff(), "everything is alright", "total = %d / %d", bo.TotalSleepInMS(), bo.MaxSleepInMS()) + + req.Greater(time.Since(begin), 200*time.Millisecond) }