Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: deflakey TestLeaseGrantTimeToLiveExpired
The following change can reproduce the issue #17504 by `TESTCASE=TestLeaseGrantTimeToLiveExpired/PeerAutoTLS make test-e2e`. We can retry it to reduce flakey possibility, if there is leader change. ```diff diff --git a/tests/common/lease_test.go b/tests/common/lease_test.go index afb27c330..dea8459dc 100644 --- a/tests/common/lease_test.go +++ b/tests/common/lease_test.go @@ -16,6 +16,7 @@ package common import ( "context" + "sync" "testing" "time" @@ -139,6 +140,18 @@ func TestLeaseGrantTimeToLiveExpired(t *testing.T) { require.NoError(t, err) require.Equal(t, int64(1), getResp.Count) + var wg sync.WaitGroup + defer wg.Wait() + + wg.Add(1) + go func() { + defer wg.Done() + time.Sleep(1000 * time.Millisecond) + clus.(interface { + MoveLeader(ctx context.Context, t testing.TB, i int) error + }).MoveLeader(ctx, t, (clus.WaitLeader(t)+1)%len(clus.Members())) + }() + time.Sleep(3 * time.Second) ttlResp, err := cc.TimeToLive(ctx, leaseResp.ID, config.LeaseOption{}) ``` Signed-off-by: Wei Fu <fuweid89@gmail.com>
- Loading branch information