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

ElasticMock doesn't support cluster and _trasport methods #8

Closed
AxelSirota opened this issue Sep 19, 2017 · 3 comments
Closed

ElasticMock doesn't support cluster and _trasport methods #8

AxelSirota opened this issue Sep 19, 2017 · 3 comments

Comments

@AxelSirota
Copy link

When trying to mock Elasticsearch bulk api:

Error
Traceback (most recent call last):
File "/home/axel/Mulesoft/arm-performance/integration_tests/functional/ElasticStatsDeployerTest.py", line 38, in test_push_stats
elastic_instance=self.elastic_instance
File "/home/axel/Mulesoft/arm-performance/src/modules/stats/online/stats_processing/ElasticStatsDeployer.py", line 56, in post_process_stats
self.push_stats_to_elastic_search(elastic_instance, actions_list)
File "/home/axel/Mulesoft/arm-performance/src/modules/stats/online/stats_processing/ElasticStatsDeployer.py", line 60, in push_stats_to_elastic_search
helpers.bulk(elastic_instance, actions_list, chunk_size=ElasticStatsDeployer.max_chunk_size, max_chunk_bytes=ElasticStatsDeployer.max_bytes_size)
File "/home/axel/Mulesoft/virtualenvs/anypoint3.5/lib/python3.5/site-packages/elasticsearch/helpers/init.py", line 195, in bulk
for ok, item in streaming_bulk(client, actions, **kwargs):
File "/home/axel/Mulesoft/virtualenvs/anypoint3.5/lib/python3.5/site-packages/elasticsearch/helpers/init.py", line 162, in streaming_bulk
for bulk_actions in _chunk_actions(actions, chunk_size, max_chunk_bytes, client.transport.serializer):
AttributeError: 'FakeElasticsearch' object has no attribute 'transport'

Also, when trying to use cluster.health methods:

Error
Traceback (most recent call last):
File "/home/axel/Mulesoft/arm-performance/integration_tests/functional/ElasticStatsDeployerTest.py", line 38, in test_push_stats
elastic_instance=self.elastic_instance
File "/home/axel/Mulesoft/arm-performance/src/modules/stats/online/stats_processing/ElasticStatsDeployer.py", line 38, in post_process_stats
if not elastic_instance.cluster.health(wait_for_status='green', request_timeout=10):
AttributeError: 'FakeElasticsearch' object has no attribute 'cluster'

I can help add this to the FakeElasticMock class, but I do not know how to in principle :)

@graham2071
Copy link

Same issue here. Example of workaround with MagicMock:

from unittest.mock import MagicMock

es = ...
es.transport = MagicMock()

@vrcmarcos
Copy link
Owner

Bulk API was recently mocked in this PR: #30

I'll provide a cluster.health mock soon

@vrcmarcos
Copy link
Owner

WIll be done on next release (probably 1.5.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants