@@ -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,66 @@ 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+ resp = context . clusterTestUtils . ClusterReplicate ( replicaNodeIndex , primaryId , failEx : false , logger : context . logger ) ;
583+ else
584+ resp = context . clusterTestUtils . ReplicaOf ( replicaNodeIndex , primaryNodeIndex , failEx : false , logger : context . logger ) ;
585+ ClassicAssert . IsTrue ( resp . StartsWith ( "PRIMARY-ERR" ) ) ;
586+ }
587+
588+ [ Test , Order ( 13 ) ]
589+ [ Category ( "REPLICATION" ) ]
590+ public void ClusterReplicateFails ( )
591+ {
592+ const string UserName = "temp-user" ;
593+ const string Password = "temp-password" ;
594+
595+ const string ClusterUserName = "cluster-user" ;
596+ const string ClusterPassword = "cluster-password" ;
597+
598+ // Setup a cluster (mimicking the style in which this bug was first found)
599+ ServerCredential clusterCreds = new ( ClusterUserName , ClusterPassword , IsAdmin : true , UsedForClusterAuth : true , IsClearText : true ) ;
600+ ServerCredential userCreds = new ( UserName , Password , IsAdmin : true , UsedForClusterAuth : false , IsClearText : true ) ;
601+
602+ context . GenerateCredentials ( [ userCreds , clusterCreds ] ) ;
603+ context . CreateInstances ( 2 , disableObjects : true , disablePubSub : true , enableAOF : true , clusterCreds : clusterCreds , useAcl : true , FastAofTruncate : true , CommitFrequencyMs : - 1 , asyncReplay : false ) ;
604+ var primaryEndpoint = ( IPEndPoint ) context . endpoints . First ( ) ;
605+ var replicaEndpoint = ( IPEndPoint ) context . endpoints . Last ( ) ;
606+
607+ ClassicAssert . AreNotEqual ( primaryEndpoint , replicaEndpoint , "Should have different endpoints for nodes" ) ;
608+
609+ using var primaryConnection = ConnectionMultiplexer . Connect ( $ "{ primaryEndpoint . Address } :{ primaryEndpoint . Port } ,user={ UserName } ,password={ Password } ") ;
610+ var primaryServer = primaryConnection . GetServer ( primaryEndpoint ) ;
611+
612+ ClassicAssert . AreEqual ( "OK" , ( string ) primaryServer . Execute ( "CLUSTER" , [ "ADDSLOTSRANGE" , "0" , "16383" ] , flags : CommandFlags . NoRedirect ) ) ;
613+ ClassicAssert . AreEqual ( "OK" , ( string ) primaryServer . Execute ( "CLUSTER" , [ "MEET" , replicaEndpoint . Address . ToString ( ) , replicaEndpoint . Port . ToString ( ) ] , flags : CommandFlags . NoRedirect ) ) ;
614+
615+ using var replicaConnection = ConnectionMultiplexer . Connect ( $ "{ replicaEndpoint . Address } :{ replicaEndpoint . Port } ,user={ UserName } ,password={ Password } ") ;
616+ var replicaServer = replicaConnection . GetServer ( replicaEndpoint ) ;
617+
618+ // Try to replicate from a server that doesn't exist
619+ var exc = Assert . Throws < RedisServerException > ( ( ) => replicaServer . Execute ( "CLUSTER" , [ "REPLICATE" , Guid . NewGuid ( ) . ToString ( ) ] , flags : CommandFlags . NoRedirect ) ) ;
620+ ClassicAssert . IsTrue ( exc . Message . StartsWith ( "ERR I don't know about node " ) ) ;
621+ }
562622 }
563623}
0 commit comments