'Test to validate that metrics can be scopped to invdividual clusters
@since 3.6.0
@jira_ticket PYTHON-561
@expected_result metrics should be scopped to a cluster level
@test_category metrics'

@local
def test_metrics_per_cluster(self):

    cluster2 = Cluster(metrics_enabled=True, protocol_version=PROTOCOL_VERSION, default_retry_policy=FallthroughRetryPolicy())
    cluster2.connect(self.ks_name, wait_for_all_pools=True)
    self.assertEqual(len(cluster2.metadata.all_hosts()), 3)
    query = SimpleStatement('SELECT    *    FROM    {0}.{0}'.format(self.ks_name), consistency_level=ConsistencyLevel.ALL)
    self.session.execute(query)
    get_node(1).pause()
    try:
        query = SimpleStatement('INSERT    INTO    {0}.{0}    (k,    v)    VALUES    (2,    2)'.format(self.ks_name), consistency_level=ConsistencyLevel.ALL)
        with self.assertRaises(WriteTimeout):
            self.session.execute(query, timeout=None)
    finally:
        get_node(1).resume()
    cluster2.metrics.set_stats_name('cluster2-metrics')
    stats_cluster1 = self.cluster.metrics.get_stats()
    stats_cluster2 = cluster2.metrics.get_stats()
    self.assertEqual(1, self.cluster.metrics.stats.write_timeouts)
    self.assertEqual(0, cluster2.metrics.stats.write_timeouts)
    self.assertNotEqual(0.0, self.cluster.metrics.request_timer['mean'])
    self.assertEqual(0.0, cluster2.metrics.request_timer['mean'])
    self.assertNotEqual(0.0, stats_cluster1['request_timer']['mean'])
    self.assertEqual(0.0, stats_cluster2['request_timer']['mean'])
    self.assertEqual(0.0, scales.getStats()['cluster2-metrics']['request_timer']['mean'])
    cluster2.shutdown()
