Skip to content

Commit

Permalink
kv: wait for leaseholder to apply lease upgrade in TestStoreCapacityA…
Browse files Browse the repository at this point in the history
…fterSplit

Fixes #132911.

This commit deflakes TestStoreCapacityAfterSplit.

Release note: None
  • Loading branch information
nvanbenschoten committed Oct 18, 2024
1 parent a8135cb commit 8fbec7d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/kv/kvserver/client_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3267,7 +3267,23 @@ func TestStoreCapacityAfterSplit(t *testing.T) {
key := tc.ScratchRange(t)
desc := tc.AddVotersOrFatal(t, key, tc.Target(1))
tc.TransferRangeLeaseOrFatal(t, desc, tc.Target(1))
tc.WaitForLeaseUpgrade(ctx, t, desc)

// Wait for the lease transfer to be applied on the new leaseholder and then
// to be upgraded from an expiration-based lease.
testutils.SucceedsSoon(t, func() error {
repl, err := s.GetReplica(desc.RangeID)
if err != nil {
return err
}
l, _ := repl.GetLease()
if !l.OwnedBy(s.StoreID()) {
return errors.Errorf("lease transfer not applied on leaseholder")
}
if l.Type() == roachpb.LeaseExpiration {
return errors.Errorf("lease still an expiration based lease")
}
return nil
})

cap, err := s.Capacity(ctx, false /* useCached */)
if err != nil {
Expand Down

0 comments on commit 8fbec7d

Please sign in to comment.