Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure execution time of bulk ingest pipeline #694

Merged
merged 1 commit into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ def detailed_stats(self, params, bulk_size, response):
if bulk_error_count > 0:
stats["error-type"] = "bulk"
stats["error-description"] = self.error_description(error_details)
if "ingest_took" in response:
stats["ingest_took"] = response["ingest_took"]

return stats

def simple_stats(self, bulk_size, response):
Expand All @@ -462,6 +465,8 @@ def simple_stats(self, bulk_size, response):
"success-count": bulk_size - bulk_error_count,
"error-count": bulk_error_count
}
if "ingest_took" in response:
stats["ingest_took"] = response["ingest_took"]
if bulk_error_count > 0:
stats["error-type"] = "bulk"
stats["error-description"] = self.error_description(error_details)
Expand Down
13 changes: 13 additions & 0 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def test_bulk_index_error_no_shards(self, es):
def test_mixed_bulk_with_simple_stats(self, es):
es.bulk.return_value = {
"took": 30,
"ingest_took": 20,
"errors": True,
"items": [
{
Expand Down Expand Up @@ -469,6 +470,7 @@ def test_mixed_bulk_with_simple_stats(self, es):

self.assertEqual("test", result["index"])
self.assertEqual(30, result["took"])
self.assertEqual(20, result["ingest_took"])
self.assertEqual(4, result["weight"])
self.assertEqual(4, result["bulk-size"])
self.assertEqual("docs", result["unit"])
Expand All @@ -478,10 +480,16 @@ def test_mixed_bulk_with_simple_stats(self, es):

es.bulk.assert_called_with(body=bulk_params["body"], params={})

es.bulk.return_value.pop("ingest_took")
result = bulk(es, bulk_params)
self.assertNotIn("ingest_took", result)


@mock.patch("elasticsearch.Elasticsearch")
def test_mixed_bulk_with_detailed_stats(self, es):
es.bulk.return_value = {
"took": 30,
"ingest_took": 20,
"errors": True,
"items": [
{
Expand Down Expand Up @@ -613,6 +621,7 @@ def test_mixed_bulk_with_detailed_stats(self, es):

self.assertEqual("test", result["index"])
self.assertEqual(30, result["took"])
self.assertEqual(20, result["ingest_took"])
self.assertEqual(6, result["weight"])
self.assertEqual(6, result["bulk-size"])
self.assertEqual("docs", result["unit"])
Expand Down Expand Up @@ -665,6 +674,10 @@ def test_mixed_bulk_with_detailed_stats(self, es):

es.bulk.assert_called_with(body=bulk_params["body"], params={})

es.bulk.return_value.pop("ingest_took")
result = bulk(es, bulk_params)
self.assertNotIn("ingest_took", result)


class ForceMergeRunnerTests(TestCase):
@mock.patch("elasticsearch.Elasticsearch")
Expand Down