def test_recreate_existing_managed_index(self, es): es.indices.exists.return_value = True index = track.Index(name="test-index", auto_managed=True, types=[ track.Type( name="test-type", mapping={"test-type": "empty-for-test"}) ]) index_settings = {"index.number_of_replicas": 0} expected_body = { "settings": { "index.number_of_replicas": 0 }, "mappings": { "test-type": "empty-for-test" } } driver.setup_index(es, index, index_settings) es.indices.exists.assert_called_with(index="test-index") es.indices.delete.assert_called_with(index="test-index") es.indices.create.assert_called_with(index="test-index", body=expected_body)
def test_store_race(self): from esrally import time schedule = [ track.Task("index #1", track.Operation("index", track.OperationType.Bulk)) ] t = track.Track( name="unittest", indices=[track.Index(name="tests", types=["test-type"])], challenges=[ track.Challenge(name="index", default=True, schedule=schedule) ]) race = metrics.Race(rally_version="0.4.4", environment_name="unittest", trial_id=FileRaceStoreTests.TRIAL_ID, trial_timestamp=FileRaceStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tags={"os": "Linux"}, track=t, track_params={"clients": 12}, challenge=t.default_challenge, car="4gheap", total_laps=12, cluster=FileRaceStoreTests.DictHolder({ "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1" }] }), lap_results=[], results=FileRaceStoreTests.DictHolder({ "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "task": "index #1", "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] })) self.race_store.store_race(race) retrieved_race = self.race_store.find_by_timestamp( timestamp=time.to_iso8601(FileRaceStoreTests.TRIAL_TIMESTAMP)) self.assertEqual(race.trial_timestamp, retrieved_race.trial_timestamp) self.assertEqual(1, len(self.race_store.list()))
def test_recreate_existing_managed_index(self, es): es.indices.exists.return_value = True index = track.Index(name="test-index", auto_managed=True, types=[track.Type(name="test-type", mapping_file=['{"mapping": "empty-for-test"}'])]) index_settings = { "index.number_of_replicas": 0 } driver.setup_index(es, index, index_settings, source=io.StringAsFileSource) es.indices.exists.assert_called_with(index="test-index") es.indices.delete.assert_called_with(index="test-index") es.indices.create.assert_called_with(index="test-index", body=index_settings) es.indices.put_mapping.assert_called_with(index="test-index", doc_type="test-type", body={"mapping": "empty-for-test"})
def test_store_race(self): self.cfg.add(config.Scope.application, "system", "pipeline", "unittest-pipeline") self.cfg.add(config.Scope.application, "system", "user.tag", "") self.cfg.add(config.Scope.application, "benchmarks", "challenge", "index-and-search") self.cfg.add(config.Scope.application, "benchmarks", "car", "defaults") self.cfg.add(config.Scope.application, "benchmarks", "laps", 1) self.cfg.add(config.Scope.application, "launcher", "external.target.hosts", [{"host": "localhost", "port": "9200"}]) self.cfg.add(config.Scope.application, "source", "revision", "latest") self.cfg.add(config.Scope.application, "source", "distribution.version", "5.0.0") index = "tests" type = "test-type" schedule = [ track.Task(track.Operation("index", track.OperationType.Index, None)), track.Task(track.Operation("search-all", track.OperationType.Search, None)), ] t = track.Track(name="unittest", short_description="unittest track", description="unittest track", source_root_url="http://example.org", indices=[track.Index(name=index, types=[track.Type(name=type, mapping_file=None)])], challenges=[ track.Challenge(name="index-and-search", description="Index & Search", index_settings=None, schedule=schedule) ]) self.race_store.store_race(t) expected_doc = { "environment": "unittest-env", "trial-timestamp": "20160131T000000Z", "pipeline": "unittest-pipeline", "revision": "latest", "distribution-version": "5.0.0", "track": "unittest", "laps": 1, "selected-challenge": { "name": "index-and-search", "operations": [ "index", "search-all" ] }, "car": "defaults", "target-hosts": ["localhost:9200"], "user-tag": "" } self.es_mock.index.assert_called_with(index="rally-2016", doc_type="races", item=expected_doc)
def test_setup_auto_managed_index(self, es): es.indices.exists.return_value = False index = track.Index(name="test-index", auto_managed=True, types=[track.Type(name="test-type", mapping_file=['{"test-type": "empty-for-test"}'])]) index_settings = { "index.number_of_replicas": 0 } expected_body = { "settings": { "index.number_of_replicas": 0 }, "mappings": { "test-type": "empty-for-test" } } driver.setup_index(es, index, index_settings, source=io.StringAsFileSource) es.indices.exists.assert_called_with(index="test-index") es.indices.delete.assert_not_called() es.indices.create.assert_called_with(index="test-index", body=expected_body)
def test_store_results(self): # here we need the real thing from esrally import reporter from esrally.mechanic import cluster schedule = [ track.Task(track.Operation("index", track.OperationType.Index)) ] t = track.Track(name="unittest-track", short_description="unittest track", source_root_url="http://example.org", indices=[ track.Index(name="tests", auto_managed=True, types=[ track.Type(name="test-type", mapping_file=None) ]) ], challenges=[ track.Challenge(name="index", description="Index", default=True, index_settings=None, schedule=schedule) ]) c = cluster.Cluster([], [], None) c.distribution_version = "5.0.0" node = c.add_node("localhost", "rally-node-0") node.plugins.append("x-pack") race = metrics.Race( rally_version="0.4.4", environment_name="unittest", trial_timestamp=EsResultsStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tag="let-me-test", track=t, challenge=t.default_challenge, car="4gheap", total_laps=12, cluster=c, lap_results=[], results=reporter.Stats({ "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] })) self.race_store.store_results(race) expected_docs = [{ "environment": "unittest", "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tag": "let-me-test", "track": "unittest-track", "challenge": "index", "car": "4gheap", "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "old_gc_time", "value": { "single": 5 } }, { "environment": "unittest", "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tag": "let-me-test", "track": "unittest-track", "challenge": "index", "car": "4gheap", "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "throughput", "operation": "index", "value": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }, { "environment": "unittest", "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tag": "let-me-test", "track": "unittest-track", "challenge": "index", "car": "4gheap", "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "young_gc_time", "value": { "single": 100 } }] self.es_mock.bulk_index.assert_called_with( index="rally-results-2016-01", doc_type="results", items=expected_docs)
def test_store_race(self): schedule = [ track.Task(track.Operation("index", track.OperationType.Index)) ] t = track.Track(name="unittest", short_description="unittest track", source_root_url="http://example.org", indices=[ track.Index(name="tests", auto_managed=True, types=[ track.Type(name="test-type", mapping_file=None) ]) ], challenges=[ track.Challenge(name="index", description="Index", default=True, index_settings=None, schedule=schedule) ]) race = metrics.Race(rally_version="0.4.4", environment_name="unittest", trial_timestamp=EsRaceStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tag="let-me-test", track=t, challenge=t.default_challenge, car="4gheap", total_laps=12, cluster=EsRaceStoreTests.DictHolder({ "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1", "plugins": ["analysis-icu", "x-pack"] }] }), lap_results=[], results=EsRaceStoreTests.DictHolder({ "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] })) self.race_store.store_race(race) expected_doc = { "rally-version": "0.4.4", "environment": "unittest", "trial-timestamp": "20160131T000000Z", "pipeline": "from-sources", "user-tag": "let-me-test", "track": "unittest", "challenge": "index", "car": "4gheap", "total-laps": 12, "cluster": { "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1", "plugins": ["analysis-icu", "x-pack"] }] }, "results": { "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] } } self.es_mock.index.assert_called_with(index="rally-races-2016-01", doc_type="races", item=expected_doc)
def test_store_race(self): from esrally import time schedule = [ track.Task(track.Operation("index", track.OperationType.Index)) ] t = track.Track(name="unittest", short_description="unittest track", source_root_url="http://example.org", indices=[ track.Index(name="tests", auto_managed=True, types=[ track.Type(name="test-type", mapping_file=None) ]) ], challenges=[ track.Challenge(name="index", description="Index", default=True, index_settings=None, schedule=schedule) ]) race = metrics.Race(rally_version="0.4.4", environment_name="unittest", trial_timestamp=FileRaceStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tag="let-me-test", track=t, challenge=t.default_challenge, car="4gheap", total_laps=12, cluster=FileRaceStoreTests.DictHolder({ "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1" }] }), lap_results=[], results=FileRaceStoreTests.DictHolder({ "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] })) self.race_store.store_race(race) retrieved_race = self.race_store.find_by_timestamp( timestamp=time.to_iso8601(FileRaceStoreTests.TRIAL_TIMESTAMP)) self.assertEqual(race.trial_timestamp, retrieved_race.trial_timestamp) self.assertEqual(1, len(self.race_store.list()))
def test_store_race(self): schedule = [ track.Task("index #1", track.Operation("index", track.OperationType.Bulk)) ] t = track.Track( name="unittest", indices=[track.Index(name="tests", types=["test-type"])], challenges=[ track.Challenge(name="index", default=True, schedule=schedule) ]) race = metrics.Race(rally_version="0.4.4", environment_name="unittest", trial_id=EsRaceStoreTests.TRIAL_ID, trial_timestamp=EsRaceStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tags={"os": "Linux"}, track=t, track_params={"shard-count": 3}, challenge=t.default_challenge, car="4gheap", total_laps=12, cluster=EsRaceStoreTests.DictHolder({ "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1", "plugins": ["analysis-icu", "x-pack"] }] }), lap_results=[], results=EsRaceStoreTests.DictHolder({ "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "task": "index #1", "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] })) self.race_store.store_race(race) expected_doc = { "rally-version": "0.4.4", "environment": "unittest", "trial-id": EsRaceStoreTests.TRIAL_ID, "trial-timestamp": "20160131T000000Z", "pipeline": "from-sources", "user-tags": { "os": "Linux" }, "track": "unittest", "track-params": { "shard-count": 3 }, "challenge": "index", "car": "4gheap", "total-laps": 12, "cluster": { "distribution-version": "5.0.0", "nodes": [{ "node_name": "node0", "ip": "127.0.0.1", "plugins": ["analysis-icu", "x-pack"] }] }, "results": { "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [{ "task": "index #1", "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }] } } self.es_mock.index.assert_called_with(index="rally-races-2016-01", doc_type="races", item=expected_doc)
def test_do_not_change_manually_managed_index(self, es): index = track.Index(name="test-index", auto_managed=False, types=[]) driver.setup_index(es, index, index_settings=None) es.assert_not_called()
def test_store_race(self): self.cfg.add(config.Scope.application, "system", "pipeline", "unittest-pipeline") self.cfg.add(config.Scope.application, "system", "user.tag", "") self.cfg.add(config.Scope.application, "benchmarks", "challenge", "index-and-search") self.cfg.add(config.Scope.application, "benchmarks", "car", "defaults") self.cfg.add(config.Scope.application, "benchmarks", "rounds", 1) self.cfg.add(config.Scope.application, "launcher", "external.target.hosts", "") self.cfg.add(config.Scope.application, "source", "revision", "latest") self.cfg.add(config.Scope.application, "source", "distribution.version", "5.0.0") index = "tests" type = "test-type" benchmarks = { track.BenchmarkPhase.index: track.IndexBenchmarkSettings(), track.BenchmarkPhase.search: track.LatencyBenchmarkSettings(queries=[ track.DefaultQuery(index=index, type=type, name="default", body={"query": { "match_all": {} }}) ]) } t = track.Track( name="unittest", short_description="unittest track", description="unittest track", source_root_url="http://example.org", indices=[ track.Index(name=index, types=[track.Type(name=type, mapping_file=None)]) ], challenges=[ track.Challenge(name="index-and-search", description="Index and Search Challenge", benchmark=benchmarks) ]) self.race_store.store_race(t) expected_doc = { "environment": "unittest-env", "trial-timestamp": "20160131T000000Z", "pipeline": "unittest-pipeline", "revision": "latest", "distribution-version": "5.0.0", "track": "unittest", "selected-challenge": { "name": "index-and-search", "benchmark-phase-index": True, "benchmark-phase-search": { "sample-size": 1000, "queries": ["default"] } }, "car": "defaults", "rounds": 1, "target-hosts": "", "user-tag": "" } self.es_mock.index.assert_called_with(index="rally-2016", doc_type="races", item=expected_doc)
def test_store_results(self): # here we need the real thing from esrally import reporter from esrally.mechanic import cluster schedule = [ track.Task("index #1", track.Operation("index", track.OperationType.Bulk)) ] t = track.Track(name="unittest-track", indices=[track.Index(name="tests", types=["test-type"])], challenges=[track.Challenge(name="index", default=True, schedule=schedule)]) c = cluster.Cluster([], [], None) c.distribution_version = "5.0.0" node = c.add_node("localhost", "rally-node-0") node.plugins.append("x-pack") race = metrics.Race(rally_version="0.4.4", environment_name="unittest", trial_id=EsResultsStoreTests.TRIAL_ID, trial_timestamp=EsResultsStoreTests.TRIAL_TIMESTAMP, pipeline="from-sources", user_tags={"os": "Linux"}, track=t, track_params=None, challenge=t.default_challenge, car="4gheap", car_params=None, plugin_params={"some-param": True}, total_laps=12, cluster=c, lap_results=[], results=reporter.Stats( { "young_gc_time": 100, "old_gc_time": 5, "op_metrics": [ { "task": "index #1", "operation": "index", "throughput": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } } ], "node_metrics": [ { "node": "rally-node-0", "startup_time": 3.4 } ] }) ) self.race_store.store_results(race) expected_docs = [ { "rally-version": "0.4.4", "environment": "unittest", "trial-id": EsResultsStoreTests.TRIAL_ID, "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tags": { "os": "Linux" }, "track": "unittest-track", "challenge": "index", "car": "4gheap", "plugin-params": { "some-param": True }, "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "old_gc_time", "value": { "single": 5 } }, { "rally-version": "0.4.4", "environment": "unittest", "trial-id": EsResultsStoreTests.TRIAL_ID, "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tags": { "os": "Linux" }, "track": "unittest-track", "challenge": "index", "car": "4gheap", "plugin-params": { "some-param": True }, "node-count": 1, "plugins": ["x-pack"], "active": True, "node": "rally-node-0", "name": "startup_time", "value": { "single": 3.4 }, }, { "rally-version": "0.4.4", "environment": "unittest", "trial-id": EsResultsStoreTests.TRIAL_ID, "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tags": { "os": "Linux" }, "track": "unittest-track", "challenge": "index", "car": "4gheap", "plugin-params": { "some-param": True }, "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "throughput", "task": "index #1", "operation": "index", "value": { "min": 1000, "median": 1250, "max": 1500, "unit": "docs/s" } }, { "rally-version": "0.4.4", "environment": "unittest", "trial-id": EsResultsStoreTests.TRIAL_ID, "trial-timestamp": "20160131T000000Z", "distribution-version": "5.0.0", "distribution-major-version": 5, "user-tags": { "os": "Linux" }, "track": "unittest-track", "challenge": "index", "car": "4gheap", "plugin-params": { "some-param": True }, "node-count": 1, "plugins": ["x-pack"], "active": True, "name": "young_gc_time", "value": { "single": 100 } } ] self.es_mock.bulk_index.assert_called_with(index="rally-results-2016-01", doc_type="results", items=expected_docs)