'Test to validate removing certain hosts from the query plan with
HostFilterPolicy
@since 3.8
@jira_ticket PYTHON-961
@expected_result the excluded hosts are ignored
@test_category policy'

def test_black_list_with_host_filter_policy(self):

    use_singledc()
    keyspace = 'test_black_list_with_hfp'
    ignored_address = (IP_FORMAT % 2)
    hfp = HostFilterPolicy(child_policy=RoundRobinPolicy(), predicate=(lambda host: (host.address != ignored_address)))
    cluster = Cluster(((IP_FORMAT % 1),), load_balancing_policy=hfp, protocol_version=PROTOCOL_VERSION, topology_event_refresh_window=0, status_event_refresh_window=0)
    self.addCleanup(cluster.shutdown)
    session = cluster.connect()
    self._wait_for_nodes_up([1, 2, 3])
    self.assertNotIn(ignored_address, [h.address for h in hfp.make_query_plan()])
    create_schema(cluster, session, keyspace)
    self._insert(session, keyspace)
    self._query(session, keyspace)
    first_node_count = self.coordinator_stats.get_query_count(1)
    third_node_count = self.coordinator_stats.get_query_count(3)
    self.assertEqual((first_node_count + third_node_count), 12)
    self.assertTrue(((first_node_count == 8) or (first_node_count == 4)))
    self.coordinator_stats.assert_query_count_equals(self, 2, 0)
    force_stop(2)
    self._wait_for_nodes_down([2])
    self.assertFalse(cluster.metadata._hosts[ignored_address].is_currently_reconnecting())
