@@ -923,6 +923,46 @@ TEST_F(SessionUnitTest, DefaultConsistencyExecutionProfileNotUpdated) {
923923 close (&session);
924924}
925925
926+ TEST_F (SessionUnitTest, RemoteDCNodeRecovery) {
927+ mockssandra::SimpleCluster cluster (simple (), 1 , 1 ); // 1 local DC node and 1 remote DC node
928+ ASSERT_EQ (cluster.start_all (), 0 );
929+
930+ ExecutionProfile profile;
931+ Config config;
932+ config.set_constant_reconnect (100 ); // Faster reconnect time to handle node outages
933+ config.contact_points ().push_back (Address (" 127.0.0.1" , 9042 ));
934+ config.set_load_balancing_policy (new DCAwarePolicy (" dc1" , 1 ));
935+
936+ Session session;
937+ connect (config, &session);
938+
939+ cluster.stop (1 ); // Force using the remote node
940+
941+ cluster.stop (2 ); // Force the remote node down and up
942+ cluster.start (2 );
943+
944+ bool remote_dc_node_recovered = false ;
945+
946+ // Wait for the remote DC node to become available
947+ for (int i = 0 ; i < 20 ; ++i) { // Around 2 seconds
948+ QueryRequest::Ptr request (new QueryRequest (" blah" , 0 ));
949+ request->set_consistency (CASS_CONSISTENCY_ONE); // Don't use a LOCAL consistency
950+ request->set_record_attempted_addresses (true );
951+ ResponseFuture::Ptr future = session.execute (Request::ConstPtr (request));
952+ EXPECT_TRUE (future->wait_for (WAIT_FOR_TIME));
953+ if (!future->error () && !future->attempted_addresses ().empty () &&
954+ Address (" 127.0.0.2" , 9042 ) == future->attempted_addresses ()[0 ]) {
955+ remote_dc_node_recovered = true ;
956+ break ;
957+ }
958+ test::Utils::msleep (100 );
959+ }
960+
961+ EXPECT_TRUE (remote_dc_node_recovered);
962+
963+ close (&session);
964+ }
965+
926966TEST_F (SessionUnitTest, DbaasDetectionUpdateDefaultConsistency) {
927967 mockssandra::SimpleRequestHandlerBuilder builder;
928968 builder.on (mockssandra::OPCODE_OPTIONS).execute (new SupportedDbaasOptions ());
0 commit comments