'Tests that changes to execution profiles correctly impact our cluster\'s pooling
@since 3.5
@jira_ticket PYTHON-569
@expected_result pools should be correctly updated as EP\'s are added and removed
@test_category config_profiles'

@local
def test_profile_pool_management(self):

    node1 = ExecutionProfile(load_balancing_policy=HostFilterPolicy(RoundRobinPolicy(), (lambda host: (host.address == '127.0.0.1'))))
    node2 = ExecutionProfile(load_balancing_policy=HostFilterPolicy(RoundRobinPolicy(), (lambda host: (host.address == '127.0.0.2'))))
    with Cluster(execution_profiles={EXEC_PROFILE_DEFAULT: node1, 'node2': node2}) as cluster:
        session = cluster.connect(wait_for_all_pools=True)
        pools = session.get_pool_state()
        self.assertGreater(len(cluster.metadata.all_hosts()), 2)
        self.assertEqual(set((h.address for h in pools)), set(('127.0.0.1', '127.0.0.2')))
        node3 = ExecutionProfile(load_balancing_policy=HostFilterPolicy(RoundRobinPolicy(), (lambda host: (host.address == '127.0.0.3'))))
        cluster.add_execution_profile('node3', node3)
        pools = session.get_pool_state()
        self.assertEqual(set((h.address for h in pools)), set(('127.0.0.1', '127.0.0.2', '127.0.0.3')))
