Skip to content

Commit

Permalink
assert over back off time
Browse files Browse the repository at this point in the history
Signed-off-by: hillium <yujuncen@pingcap.com>
  • Loading branch information
YuJuncen authored and ti-chi-bot committed Apr 28, 2023
1 parent 7dbaf5b commit 1c9d29a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions br/pkg/utils/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"sync"
"testing"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/utils"
Expand All @@ -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"))
Expand All @@ -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)
}

0 comments on commit 1c9d29a

Please sign in to comment.