From e5e59b479fc862406511468bfeee47897c44143b Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 22 Jun 2021 08:05:44 +0200 Subject: [PATCH] Remove limitation for elasticsearch library (#16553) * Remove limitation for elasticsearch library Elasticsearch <7.6.0 does not work with Python 3.9 (import errors on deprecated base64 functionality that have been removed in Python 3.9) see: ihttps://bugzilla.redhat.com/show_bug.cgi?id=1894188 This PR bumps elasticsearch library version to latest available (7.13.1 as of this writing) in order to get it Python 3.9 compatible. --- setup.py | 4 +-- .../log/elasticmock/fake_elasticsearch.py | 26 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 0655c02153f95..4ecf176a7a6b2 100644 --- a/setup.py +++ b/setup.py @@ -275,8 +275,8 @@ def get_sphinx_theme_version() -> str: 'pydruid>=0.4.1', ] elasticsearch = [ - 'elasticsearch>7, <7.6.0', - 'elasticsearch-dbapi==0.1.0', + 'elasticsearch>7', + 'elasticsearch-dbapi', 'elasticsearch-dsl>=5.0.0', ] exasol = [ diff --git a/tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py b/tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py index 21219724de8bd..4d6902a234854 100644 --- a/tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py +++ b/tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py @@ -88,7 +88,7 @@ def info(self, params=None): 'version', 'version_type', ) - def index(self, index, doc_type, body, id=None, params=None): + def index(self, index, doc_type, body, id=None, params=None, headers=None): if index not in self.__documents_dict: self.__documents_dict[index] = [] @@ -98,10 +98,24 @@ def index(self, index, doc_type, body, id=None, params=None): version = 1 self.__documents_dict[index].append( - {'_type': doc_type, '_id': id, '_source': body, '_index': index, '_version': version} + { + '_type': doc_type, + '_id': id, + '_source': body, + '_index': index, + '_version': version, + '_headers': headers, + } ) - return {'_type': doc_type, '_id': id, 'created': True, '_version': version, '_index': index} + return { + '_type': doc_type, + '_id': id, + 'created': True, + '_version': version, + '_index': index, + '_headers': headers, + } @query_params('parent', 'preference', 'realtime', 'refresh', 'routing') def exists(self, index, doc_type, id, params=None): @@ -198,7 +212,7 @@ def get_source(self, index, doc_type, id, params=None): 'track_scores', 'version', ) - def count(self, index=None, doc_type=None, body=None, params=None): + def count(self, index=None, doc_type=None, body=None, params=None, headers=None): searchable_indexes = self._normalize_index_to_list(index) searchable_doc_types = self._normalize_doc_type_to_list(doc_type) @@ -247,7 +261,7 @@ def count(self, index=None, doc_type=None, body=None, params=None): 'track_scores', 'version', ) - def search(self, index=None, doc_type=None, body=None, params=None): + def search(self, index=None, doc_type=None, body=None, params=None, headers=None): searchable_indexes = self._normalize_index_to_list(index) matches = self._find_match(index, doc_type, body) @@ -275,7 +289,7 @@ def search(self, index=None, doc_type=None, body=None, params=None): @query_params( 'consistency', 'parent', 'refresh', 'replication', 'routing', 'timeout', 'version', 'version_type' ) - def delete(self, index, doc_type, id, params=None): + def delete(self, index, doc_type, id, params=None, headers=None): found = False