@@ -31,6 +31,7 @@ import (
31
31
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
32
32
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/plan"
33
33
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
34
+ "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness"
34
35
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb"
35
36
"github.com/cockroachdb/cockroach/pkg/raft/raftpb"
36
37
"github.com/cockroachdb/cockroach/pkg/raft/tracker"
@@ -399,29 +400,36 @@ func TestReplicateQueueUpReplicateOddVoters(t *testing.T) {
399
400
400
401
tc .AddAndStartServer (t , base.TestServerArgs {})
401
402
402
- if err := tc .Servers [0 ].GetStores ().(* kvserver.Stores ).VisitStores (func (s * kvserver.Store ) error {
403
- return s .ForceReplicationScanAndProcess ()
404
- }); err != nil {
405
- t .Fatal (err )
406
- }
407
- // After the initial splits have been performed, all of the resulting ranges
408
- // should be present in replicate queue purgatory (because we only have a
409
- // single store in the test and thus replication cannot succeed).
410
- expected , err := tc .Servers [0 ].ExpectedInitialRangeCount ()
411
- if err != nil {
412
- t .Fatal (err )
413
- }
403
+ // NB: the following usually succeeds on the first attempt. However, it's
404
+ // also possible for s2 to initially enter "suspect" status, in which case
405
+ // there is a default 30s timeout (which we lower below) and we may need to
406
+ // retry a few times as the replicate queue won't add replicas to purgatory
407
+ // unless s2 is available as a replication target.
408
+ liveness .TimeAfterNodeSuspect .Override (context .Background (), & tc .Servers [0 ].ClusterSettings ().SV , time .Second )
409
+ testutils .SucceedsSoon (t , func () error {
410
+ if err := tc .Servers [0 ].GetStores ().(* kvserver.Stores ).VisitStores (func (s * kvserver.Store ) error {
411
+ return s .ForceReplicationScanAndProcess ()
412
+ }); err != nil {
413
+ t .Fatal (err )
414
+ }
415
+ // After the initial splits have been performed, all of the resulting ranges
416
+ // should be present in replicate queue purgatory (because we only have a
417
+ // single store in the test and thus replication cannot succeed).
418
+ expected , err := tc .Servers [0 ].ExpectedInitialRangeCount ()
419
+ require .NoError (t , err )
420
+
421
+ var store * kvserver.Store
422
+ _ = tc .Servers [0 ].GetStores ().(* kvserver.Stores ).VisitStores (func (s * kvserver.Store ) error {
423
+ store = s
424
+ return nil
425
+ })
414
426
415
- var store * kvserver. Store
416
- _ = tc . Servers [ 0 ]. GetStores ().( * kvserver. Stores ). VisitStores ( func ( s * kvserver. Store ) error {
417
- store = s
427
+ if n := store . ReplicateQueuePurgatoryLength (); expected != n {
428
+ return errors . Errorf ( "expected %d replicas in purgatory, but found %d" , expected , n )
429
+ }
418
430
return nil
419
431
})
420
432
421
- if n := store .ReplicateQueuePurgatoryLength (); expected != n {
422
- t .Fatalf ("expected %d replicas in purgatory, but found %d" , expected , n )
423
- }
424
-
425
433
tc .AddAndStartServer (t , base.TestServerArgs {})
426
434
427
435
// Now wait until the replicas have been up-replicated to the
0 commit comments