From 8fbec7dbfdb9a1077c4f0a34fd4f1c62b6b627b2 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Fri, 18 Oct 2024 20:57:18 +0000 Subject: [PATCH] kv: wait for leaseholder to apply lease upgrade in TestStoreCapacityAfterSplit Fixes #132911. This commit deflakes TestStoreCapacityAfterSplit. Release note: None --- pkg/kv/kvserver/client_split_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/kv/kvserver/client_split_test.go b/pkg/kv/kvserver/client_split_test.go index eb94e395ff18..1fd454f4a9b7 100644 --- a/pkg/kv/kvserver/client_split_test.go +++ b/pkg/kv/kvserver/client_split_test.go @@ -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 {