def test_pshard_metrics(self):

        config = {'instances': [
            {'url': 'http://localhost:9200', 'pshard_stats': True, 'hostname': 'foo'}
        ]}
        # Cleaning up everything won't hurt.
        requests.delete('http://localhost:9200/_all/')

        requests.put('http://localhost:9200/testindex/',
                     data='{"settings": {"index": {"number_of_replicas": 1,'
                          '"number_of_shards":5}}}')
        requests.put('http://localhost:9200/testindex/testtype/2',
                     data='{"name": "Jane Doe", "age": 27}')
        requests.put('http://localhost:9200/testindex/testtype/1',
                     data='{"name": "John Doe", "age": 42}')

        # Let's wait for elasticsearch to process what we sent him
        requests.post('http://localhost:9200/_flush?wait_for_ongoing')

        self.run_check(config)

        # Let's populate the dicts of expected metrics
        for k, v in SHARD_LEVEL_METRICS_SUFFIX.iteritems():
            val = (v[0], '_all.primaries.{0}'.format(v[1]), v[2] if len(v) > 2 else None)
            PRIMARY_SHARD_METRICS['elasticsearch.primaries{0}'.format(k)] = val

        for k, v in SHARD_LEVEL_METRICS_POST_1_0_SUFFIX.iteritems():
            val = (v[0], '_all.primaries.{0}'.format(v[1]), v[2] if len(v) > 2 else None)
            PRIMARY_SHARD_METRICS_POST_1_0['elasticsearch.primaries{0}'.format(k)] = val

        pshard_stats_metrics = dict(PRIMARY_SHARD_METRICS)
        if get_es_version() >= [1, 0, 0]:
            pshard_stats_metrics.update(PRIMARY_SHARD_METRICS_POST_1_0)

        for m_name, desc in pshard_stats_metrics.iteritems():
            if desc[0] == "gauge":
                self.assertMetric(m_name, count=1)

        # Our pshard metrics are getting sent, let's check that they're accurate
        # Note: please make sure you don't install Maven on the CI for future
        # elastic search CI integrations. It would make the line below fail :/
        self.assertMetric('elasticsearch.primaries.docs.count', value=2)

        # And let's add the configuration-agnostic metrics to our coverage report
        self.assert_default_metrics(config)
        # This event will be sent because replication doesn't work on one node :)
        self.assertEvent('yellow', exact_match=False)
        self.coverage_report()
Get one element of a set
dataset/ETHPy150Open serverdensity/sd-agent/tests/checks/integration/test_elastic.py/TestElastic.test_pshard_metrics--crossover with--dataset/ETHPy150Open mongodb/mongo-python-driver/test/utils.py/one