def test_stores_cluster_level_metrics_on_attach(self, metrics_store_add_meta_info): nodes_stats = { "nodes": { "FCFjozkeTiOpN-SI88YEcg": { "name": "rally0", "host": "127.0.0.1" } } } nodes_info = { "nodes": { "FCFjozkeTiOpN-SI88YEcg": { "name": "rally0", "host": "127.0.0.1", "os": { "name": "Mac OS X", "version": "10.11.4", "available_processors": 8 }, "jvm": { "version": "1.8.0_74", "vm_vendor": "Oracle Corporation" } } } } cluster_info = { "version": { "build_hash": "abc123" } } client = Client(SubClient(nodes_stats), SubClient(nodes_info), cluster_info) cfg = self.create_config() metrics_store = metrics.EsMetricsStore(cfg) env_device = telemetry.ExternalEnvironmentInfo(cfg, client, metrics_store) t = telemetry.Telemetry(cfg, metrics_store, devices=[env_device]) t.attach_to_cluster(cluster.Cluster([], t)) calls = [ mock.call(metrics.MetaInfoScope.cluster, None, "source_revision", "abc123"), mock.call(metrics.MetaInfoScope.node, "rally0", "node_name", "rally0"), mock.call(metrics.MetaInfoScope.node, "rally0", "host_name", "127.0.0.1"), mock.call(metrics.MetaInfoScope.node, "rally0", "os_name", "Mac OS X"), mock.call(metrics.MetaInfoScope.node, "rally0", "os_version", "10.11.4"), mock.call(metrics.MetaInfoScope.node, "rally0", "cpu_logical_cores", 8), mock.call(metrics.MetaInfoScope.node, "rally0", "jvm_vendor", "Oracle Corporation"), mock.call(metrics.MetaInfoScope.node, "rally0", "jvm_version", "1.8.0_74") ] metrics_store_add_meta_info.assert_has_calls(calls)
def test_stores_cluster_level_metrics_on_attach( self, cluster_info, metrics_store_add_meta_info): cluster_info.return_value = {"version": {"build_hash": "abc123"}} cfg = self.create_config() metrics_store = metrics.EsMetricsStore(cfg) env_device = telemetry.EnvironmentInfo(cfg, metrics_store) t = telemetry.Telemetry(cfg, metrics_store, devices=[env_device]) t.attach_to_cluster( cluster.Cluster([{ "host": "::1:9200" }], [], metrics_store, t, client_factory_class=MockClientFactory)) metrics_store_add_meta_info.assert_called_with( metrics.MetaInfoScope.cluster, None, "source_revision", "abc123")
def start(self, track, setup, metrics_store): if self._servers: logger.warn( "There are still referenced servers on startup. Did the previous shutdown succeed?" ) num_nodes = setup.candidate.nodes first_http_port = self._config.opts("provisioning", "node.http.port") t = telemetry.Telemetry(self._config, metrics_store) c = cluster.Cluster([{ "host": "localhost", "port": first_http_port }], [ self._start_node(node, setup, metrics_store) for node in range(num_nodes) ], metrics_store) t.attach_to_cluster(c) return c
def test_stores_cluster_level_metrics_on_attach( self, nodes_info, cluster_info, metrics_store_add_meta_info): nodes_info.return_value = { "nodes": { "FCFjozkeTiOpN-SI88YEcg": { "name": "rally0", "host": "127.0.0.1", "os": { "name": "Mac OS X", "version": "10.11.4", "available_processors": 8 }, "jvm": { "version": "1.8.0_74", "vm_vendor": "Oracle Corporation" } } } } cluster_info.return_value = {"version": {"build_hash": "abc123"}} cfg = self.create_config() metrics_store = metrics.EsMetricsStore(cfg) env_device = telemetry.EnvironmentInfo(cfg, metrics_store) t = telemetry.Telemetry(cfg, metrics_store, devices=[env_device]) t.attach_to_cluster( cluster.Cluster([{ "host": "::1:9200" }], [], {}, metrics_store, t, client_factory_class=MockClientFactory)) calls = [ mock.call(metrics.MetaInfoScope.cluster, None, "source_revision", "abc123"), mock.call(metrics.MetaInfoScope.node, "rally0", "jvm_vendor", "Oracle Corporation"), mock.call(metrics.MetaInfoScope.node, "rally0", "jvm_version", "1.8.0_74") ] metrics_store_add_meta_info.assert_has_calls(calls)
def create(self, hosts, nodes, client_options, metrics_store, telemetry): return cluster.Cluster(hosts, nodes, client_options, metrics_store, telemetry)
def start_engine_external(self, track, setup): # for now we just support a hardcoded default return cluster.Cluster([{ "host": "localhost", "port": "9200" }], [], self._metrics_store)