Skip to content

Commit

Permalink
br: fix register_test failed error for flaky test (#46991)
Browse files Browse the repository at this point in the history
close #46848
  • Loading branch information
Leavrth authored Feb 7, 2024
1 parent 9553bc6 commit dee790b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions br/pkg/utils/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package utils

import (
"context"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -115,8 +116,12 @@ func TestTaskRegisterFailedGrant(t *testing.T) {
t.Log(task.MessageToUser())
require.Equal(t, "/tidb/brie/import/restore/test", task.Key)
}

require.NoError(t, register.Close(ctx))
require.True(t, len(list.Tasks) > 0)
err = register.Close(ctx)
// for flaky test, the lease would expire
if err != nil && !strings.Contains(err.Error(), "requested lease not found") {
require.NoError(t, err)
}
}

func TestTaskRegisterFailedReput(t *testing.T) {
Expand Down Expand Up @@ -153,6 +158,10 @@ func TestTaskRegisterFailedReput(t *testing.T) {
t.Log(task.MessageToUser())
require.Equal(t, "/tidb/brie/import/restore/test", task.Key)
}

require.NoError(t, register.Close(ctx))
require.True(t, len(list.Tasks) > 0)
err = register.Close(ctx)
// for flaky test, the lease would expire
if err != nil && !strings.Contains(err.Error(), "requested lease not found") {
require.NoError(t, err)
}
}

0 comments on commit dee790b

Please sign in to comment.