Skip to content

Commit

Permalink
use opensearch parallel bulk (#492)
Browse files Browse the repository at this point in the history
* use opensearch parallel bulk

* update changelog
  • Loading branch information
ekneg54 authored Dec 7, 2023
1 parent 6c4cec1 commit b2531c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

### Improvements

* use parallel_bulk api for opensearch output connector

### Bugfix


Expand Down
2 changes: 1 addition & 1 deletion logprep/connector/opensearch/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def describe(self) -> str:

def _bulk(self, *args, **kwargs):
try:
helpers.bulk(*args, **kwargs)
helpers.parallel_bulk(*args, **kwargs)
except search.SerializationError as error:
self._handle_serialization_error(error)
except search.ConnectionError as error:
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/connector/test_opensearch_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_build_failed_index_document(self):
assert failed_document == expected

@mock.patch(
"opensearchpy.helpers.bulk",
"opensearchpy.helpers.parallel_bulk",
side_effect=search.SerializationError,
)
def test_write_to_search_context_calls_handle_serialization_error_if_serialization_error(
Expand All @@ -148,7 +148,7 @@ def test_write_to_search_context_calls_handle_serialization_error_if_serializati
self.object._handle_serialization_error.assert_called()

@mock.patch(
"opensearchpy.helpers.bulk",
"opensearchpy.helpers.parallel_bulk",
side_effect=search.ConnectionError,
)
def test_write_to_search_context_calls_handle_connection_error_if_connection_error(self, _):
Expand All @@ -158,7 +158,7 @@ def test_write_to_search_context_calls_handle_connection_error_if_connection_err
self.object._handle_connection_error.assert_called()

@mock.patch(
"opensearchpy.helpers.bulk",
"opensearchpy.helpers.parallel_bulk",
side_effect=helpers.BulkIndexError,
)
def test_write_to_search_context_calls_handle_bulk_index_error_if_bulk_index_error(self, _):
Expand All @@ -167,7 +167,7 @@ def test_write_to_search_context_calls_handle_bulk_index_error_if_bulk_index_err
self.object._write_to_search_context({"dummy": "event"})
self.object._handle_bulk_index_error.assert_called()

@mock.patch("opensearchpy.helpers.bulk")
@mock.patch("opensearchpy.helpers.parallel_bulk")
def test__handle_bulk_index_error_calls_bulk(self, fake_bulk):
mock_bulk_index_error = mock.MagicMock()
mock_bulk_index_error.errors = [
Expand All @@ -181,7 +181,7 @@ def test__handle_bulk_index_error_calls_bulk(self, fake_bulk):
self.object._handle_bulk_index_error(mock_bulk_index_error)
fake_bulk.assert_called()

@mock.patch("opensearchpy.helpers.bulk")
@mock.patch("opensearchpy.helpers.parallel_bulk")
def test_handle_bulk_index_error_calls_bulk_with_error_documents(self, fake_bulk):
mock_bulk_index_error = mock.MagicMock()
mock_bulk_index_error.errors = [
Expand Down

0 comments on commit b2531c2

Please sign in to comment.