@@ -103,7 +103,7 @@ def test_tuple_for_contact_points(self):
103103
104104 def test_on_add_clears_in_progress_flag_when_later_session_add_fails (self ):
105105 cluster = Cluster (protocol_version = 4 )
106- host = Host ("127.0.0.1" , SimpleConvictionPolicy , host_id = uuid .uuid4 ())
106+ host = Host ("127.0.0.1" , SimpleConvictionPolicy , datacenter = "dc1" , rack = "rack1" , host_id = uuid .uuid4 ())
107107 successful_session = Mock ()
108108 successful_session .add_or_renew_pool .return_value = Future ()
109109 successful_session .update_created_pools .return_value = set ()
@@ -116,6 +116,8 @@ def test_on_add_clears_in_progress_flag_when_later_session_add_fails(self):
116116 cluster .on_add (host , refresh_nodes = False )
117117
118118 assert not host ._currently_handling_node_addition
119+ load_balancer = cluster .profile_manager .default .load_balancing_policy
120+ assert host not in list (load_balancer .make_query_plan ())
119121
120122 with pytest .raises (RuntimeError ):
121123 cluster .on_add (host , refresh_nodes = False )
@@ -124,6 +126,26 @@ def test_on_add_clears_in_progress_flag_when_later_session_add_fails(self):
124126 finally :
125127 cluster .shutdown ()
126128
129+ def test_on_add_excludes_host_from_query_plan_when_pool_future_fails (self ):
130+ cluster = Cluster (protocol_version = 4 )
131+ host = Host ("127.0.0.1" , SimpleConvictionPolicy , datacenter = "dc1" , rack = "rack1" , host_id = uuid .uuid4 ())
132+ failed_future = Future ()
133+ session = Mock ()
134+ session .add_or_renew_pool .return_value = failed_future
135+ session .update_created_pools .return_value = set ()
136+ cluster .sessions = [session ]
137+
138+ try :
139+ cluster .on_add (host , refresh_nodes = False )
140+
141+ failed_future .set_result (False )
142+
143+ load_balancer = cluster .profile_manager .default .load_balancing_policy
144+ assert host not in list (load_balancer .make_query_plan ())
145+ assert host .is_up is False
146+ finally :
147+ cluster .shutdown ()
148+
127149 def test_on_add_waits_for_all_session_pool_futures_before_marking_host_up (self ):
128150 cluster = Cluster (protocol_version = 4 )
129151 host = Host ("127.0.0.1" , SimpleConvictionPolicy , host_id = uuid .uuid4 ())
0 commit comments