@@ -291,7 +291,7 @@ public void ClusterCheckpointAcquireTest([Values] bool fastAofTruncate, [Values]
291291 }
292292 }
293293
294- [ Test , Order ( 6 ) , CancelAfter ( testTimeout ) ]
294+ [ Test , Order ( 7 ) , CancelAfter ( testTimeout ) ]
295295 public void ClusterReplicaAttachIntenseWrite ( CancellationToken cancellationToken )
296296 {
297297 var primaryIndex = 0 ;
@@ -369,7 +369,7 @@ public void ClusterReplicaAttachIntenseWrite(CancellationToken cancellationToken
369369 }
370370 }
371371
372- [ Test , Order ( 6 ) , CancelAfter ( testTimeout ) ]
372+ [ Test , Order ( 8 ) , CancelAfter ( testTimeout ) ]
373373 public void ClusterFailedToAddAofSyncTask ( )
374374 {
375375 var primaryIndex = 0 ;
@@ -419,7 +419,7 @@ public void ClusterFailedToAddAofSyncTask()
419419 context . ValidateKVCollectionAgainstReplica ( ref context . kvPairs , replicaIndex ) ;
420420 }
421421
422- [ Test , Order ( 6 ) , CancelAfter ( testTimeout ) ]
422+ [ Test , Order ( 9 ) , CancelAfter ( testTimeout ) ]
423423 public void ClusterReplicaSyncTimeoutTest ( )
424424 {
425425 var primaryIndex = 0 ;
@@ -468,7 +468,7 @@ public void ClusterReplicaSyncTimeoutTest()
468468 }
469469#endif
470470
471- [ Test , CancelAfter ( 60_000 ) ]
471+ [ Test , Order ( 10 ) , CancelAfter ( 60_000 ) ]
472472 public async Task ClusterParallelFailoverOnDistinctShards ( CancellationToken cancellationToken )
473473 {
474474 var nodes_count = 4 ;
@@ -523,8 +523,7 @@ public async Task ClusterParallelFailoverOnDistinctShards(CancellationToken canc
523523 }
524524 }
525525
526-
527- [ Test , CancelAfter ( 60_000 ) ]
526+ [ Test , Order ( 11 ) , CancelAfter ( 60_000 ) ]
528527 public void ClusterMeetFromReplica ( CancellationToken cancellationToken )
529528 {
530529 var nodes_count = 3 ;
@@ -559,5 +558,71 @@ public void ClusterMeetFromReplica(CancellationToken cancellationToken)
559558 Assert . That ( nodes_count , Is . EqualTo ( context . clusterTestUtils . ClusterNodes ( i ) . Nodes . Count ) ) ;
560559 }
561560 }
561+
562+ [ Test , Order ( 12 ) ]
563+ [ Category ( "REPLICATION" ) ]
564+ public void ClusterDontKnowReplicaFailTest ( [ Values ] bool useReplicaOf )
565+ {
566+ var replica_count = 1 ; // Per primary
567+ var primary_count = 1 ;
568+ var nodes_count = primary_count + ( primary_count * replica_count ) ;
569+ ClassicAssert . IsTrue ( primary_count > 0 ) ;
570+ context . CreateInstances ( nodes_count , disableObjects : true , FastAofTruncate : false , OnDemandCheckpoint : false , CommitFrequencyMs : - 1 , enableAOF : true , useTLS : false , asyncReplay : false ) ;
571+ context . CreateConnection ( useTLS : false ) ;
572+
573+ var primaryNodeIndex = 0 ;
574+ var replicaNodeIndex = 1 ;
575+ ClassicAssert . AreEqual ( "OK" , context . clusterTestUtils . AddDelSlotsRange ( 0 , [ ( 0 , 16383 ) ] , true , context . logger ) ) ;
576+ context . clusterTestUtils . SetConfigEpoch ( primaryNodeIndex , 1 , logger : context . logger ) ;
577+ context . clusterTestUtils . SetConfigEpoch ( replicaNodeIndex , 2 , logger : context . logger ) ;
578+
579+ var primaryId = context . clusterTestUtils . ClusterMyId ( primaryNodeIndex , logger : context . logger ) ;
580+ string resp ;
581+ if ( ! useReplicaOf )
582+ {
583+ resp = context . clusterTestUtils . ClusterReplicate ( replicaNodeIndex , primaryId , failEx : false , logger : context . logger ) ;
584+ ClassicAssert . AreEqual ( $ "ERR I don't know about node { primaryId } .", resp ) ;
585+ }
586+ else
587+ {
588+ resp = context . clusterTestUtils . ReplicaOf ( replicaNodeIndex , primaryNodeIndex , failEx : false , logger : context . logger ) ;
589+ ClassicAssert . AreEqual ( $ "ERR I don't know about node { context . clusterTestUtils . GetEndPoint ( primaryNodeIndex ) } .", resp ) ;
590+ }
591+ }
592+
593+ [ Test , Order ( 13 ) ]
594+ [ Category ( "REPLICATION" ) ]
595+ public void ClusterReplicateFails ( )
596+ {
597+ const string UserName = "temp-user" ;
598+ const string Password = "temp-password" ;
599+
600+ const string ClusterUserName = "cluster-user" ;
601+ const string ClusterPassword = "cluster-password" ;
602+
603+ // Setup a cluster (mimicking the style in which this bug was first found)
604+ ServerCredential clusterCreds = new ( ClusterUserName , ClusterPassword , IsAdmin : true , UsedForClusterAuth : true , IsClearText : true ) ;
605+ ServerCredential userCreds = new ( UserName , Password , IsAdmin : true , UsedForClusterAuth : false , IsClearText : true ) ;
606+
607+ context . GenerateCredentials ( [ userCreds , clusterCreds ] ) ;
608+ context . CreateInstances ( 2 , disableObjects : true , disablePubSub : true , enableAOF : true , clusterCreds : clusterCreds , useAcl : true , FastAofTruncate : true , CommitFrequencyMs : - 1 , asyncReplay : false ) ;
609+ var primaryEndpoint = ( IPEndPoint ) context . endpoints . First ( ) ;
610+ var replicaEndpoint = ( IPEndPoint ) context . endpoints . Last ( ) ;
611+
612+ ClassicAssert . AreNotEqual ( primaryEndpoint , replicaEndpoint , "Should have different endpoints for nodes" ) ;
613+
614+ using var primaryConnection = ConnectionMultiplexer . Connect ( $ "{ primaryEndpoint . Address } :{ primaryEndpoint . Port } ,user={ UserName } ,password={ Password } ") ;
615+ var primaryServer = primaryConnection . GetServer ( primaryEndpoint ) ;
616+
617+ ClassicAssert . AreEqual ( "OK" , ( string ) primaryServer . Execute ( "CLUSTER" , [ "ADDSLOTSRANGE" , "0" , "16383" ] , flags : CommandFlags . NoRedirect ) ) ;
618+ ClassicAssert . AreEqual ( "OK" , ( string ) primaryServer . Execute ( "CLUSTER" , [ "MEET" , replicaEndpoint . Address . ToString ( ) , replicaEndpoint . Port . ToString ( ) ] , flags : CommandFlags . NoRedirect ) ) ;
619+
620+ using var replicaConnection = ConnectionMultiplexer . Connect ( $ "{ replicaEndpoint . Address } :{ replicaEndpoint . Port } ,user={ UserName } ,password={ Password } ") ;
621+ var replicaServer = replicaConnection . GetServer ( replicaEndpoint ) ;
622+
623+ // Try to replicate from a server that doesn't exist
624+ var exc = Assert . Throws < RedisServerException > ( ( ) => replicaServer . Execute ( "CLUSTER" , [ "REPLICATE" , Guid . NewGuid ( ) . ToString ( ) ] , flags : CommandFlags . NoRedirect ) ) ;
625+ ClassicAssert . IsTrue ( exc . Message . StartsWith ( "ERR I don't know about node " ) ) ;
626+ }
562627 }
563628}
0 commit comments