pytest-elasticsearch
pytest-elasticsearch copied to clipboard
can't create elastic test
I create elasticsearch_my_proc and elasticsearch_my in conftest.py elasticsearch_my_proc = factories.elasticsearch_proc( host='127.0.0.1', port=9201, cluster_name=None, network_publish_host='127.0.0.1', discovery_zen_ping_multicast_enabled=False, index_store_type='memory', logs_prefix='') elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')
Then I use this in test_save function def test_save(product_test_data, elasticsearch_my): es_product = EsRepositoryInterface(elastic_url=PRODUCT_CATALOG_URL_1) es_product._index = PRODUCT_CATALOG_INDEX es_product.doc_type = EsConfig.PRODUCT_CATALOG_DOC_TYPE print(elasticsearch_my) test_data = product_test_data['_PARSED'][0] res = es_product.save(data=test_data) assert res
But it raise this error request = <SubRequest 'elasticsearch_my' for <Function test_save>>
@pytest.fixture
def elasticsearch_fixture(request):
"""Elasticsearch client fixture."""
process = request.getfixturevalue(process_fixture_name)
../../.local/lib/python3.6/site-packages/pytest_elasticsearch/factories.py:244:
../../.local/lib/python3.6/site-packages/pytest_elasticsearch/factories.py:222: in elasticsearch_proc_fixture elasticsearch_executor.start() ../../.local/lib/python3.6/site-packages/mirakuru/base.py:431: in start self.wait_for(self.check_subprocess) ../../.local/lib/python3.6/site-packages/mirakuru/base.py:348: in wait_for if wait_for():
self = <mirakuru.http.HTTPExecutor: " ..." 0x7f8eb55bc2e8>
def check_subprocess(self):
"""
Make sure the process didn't exit with an error and run the checks.
:rtype: bool
:return: the actual check status
:raise ProcessExitedWithError: when the main process exits with
an error
"""
exit_code = self.process.poll()
if exit_code is not None and exit_code != 0:
# The main process exited with an error. Clean up the children
# if any.
self._kill_all_kids(self._sig_kill)
self._clear_process()
raise ProcessExitedWithError(self, exit_code)
E mirakuru.exceptions.ProcessExitedWithError: The process invoked by the <mirakuru.http.HTTPExecutor: " E /usr/share/elasticsearch/bin/elasticsearch -p /tmp/elasticsearch.9201.pid E -E http.port=9201 E -E transport.tcp.port=23245 E -E path.logs=/tmp/elasticsearch_9201_logs E -E path.data=/tmp/elasticsearch_9201_tmp E -E cluster.name=elasticsearch_cluster_9201 E -E network.host='127.0.0.1' E -E index.store.type=memory E "> executor has exited with a non-zero code: 1.
../../.local/lib/python3.6/site-packages/mirakuru/base.py:449: ProcessExitedWithError
How can you fix it?
Hey,
Sorry I must have missed the issue. Could you reformat the output? Or actually try to run the command by hand and see what happens?
/usr/share/elasticsearch/bin/elasticsearch -p /tmp/elasticsearch.9201.pid -E http.port=9201 -E transport.tcp.port=23245 -E path.logs=/tmp/elasticsearch_9201_logs -E path.data=/tmp/elasticsearch_9201_tmp -E cluster.name=elasticsearch_cluster_9201 -E network.host='127.0.0.1' -E index.store.type=memory
Properly formatted output:
============================================================================================================ ERRORS ============================================================================================================
________________________________________________________________________________________________ ERROR at setup of test_search _________________________________________________________________________________________________
request = <SubRequest 'elasticsearch' for <Function test_search>>
@pytest.fixture
def elasticsearch_fixture(request):
"""Elasticsearch client fixture."""
> process = request.getfixturevalue(process_fixture_name)
.tox/py3/lib/python3.5/site-packages/pytest_elasticsearch/factories.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.5/site-packages/pytest_elasticsearch/factories.py:189: in elasticsearch_proc_fixture
elasticsearch_executor.start()
.tox/py3/lib/python3.5/site-packages/mirakuru/base.py:493: in start
self.wait_for(self.check_subprocess)
.tox/py3/lib/python3.5/site-packages/mirakuru/base.py:410: in wait_for
if wait_for():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mirakuru.http.HTTPExecutor: "
..." 0x7f08a1ffc4a8>
def check_subprocess(self) -> bool:
"""
Make sure the process didn't exit with an error and run the checks.
:rtype: bool
:return: the actual check status or False before starting the process
:raise ProcessExitedWithError: when the main process exits with
an error
"""
if self.process is None: # pragma: no cover
# No process was started.
return False
exit_code = self.process.poll()
if exit_code is not None and exit_code != 0:
# The main process exited with an error. Clean up the children
# if any.
self._kill_all_kids(self._sig_kill)
self._clear_process()
> raise ProcessExitedWithError(self, exit_code)
E mirakuru.exceptions.ProcessExitedWithError: The process invoked by the <mirakuru.http.HTTPExecutor: "
E /usr/share/elasticsearch/bin/elasticsearch -p /tmp/elasticsearch.31383.pid
E -E http.port=31383
E -E transport.tcp.port=23662
E -E path.logs=/tmp/elasticsearch_31383_logs
E -E path.data=/tmp/elasticsearch_31383_tmp
E -E cluster.name=elasticsearch_cluster_31383
E -E network.host='127.0.0.1'
E -E index.store.type=memory
E "> executor has exited with a non-zero code: 78.
.tox/py3/lib/python3.5/site-packages/mirakuru/base.py:514: ProcessExitedWithError
---------------------------------------------------------------------------------------------------- Captured stderr setup -----------------------------------------------------------------------------------------------------
/usr/share/elasticsearch/bin/elasticsearch-env: line 81: cd: /etc/elasticsearch: Permission denied
/usr/share/elasticsearch/bin/elasticsearch-env: line 81: cd: /etc/elasticsearch: Permission denied
Running ES directly show:
/usr/share/elasticsearch/bin/elasticsearch-env: line 81: cd: /etc/elasticsearch: Permission denied
2019-08-28 14:01:20,778 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:444)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1805)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:318)
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.apache.logging.log4j.core.jmx.Server.register(Server.java:393)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:168)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:141)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:558)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:207)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:220)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:197)
at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:250)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:127)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:310)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
ERROR: no log4j2.properties found; tried [/home/dev/swh-environment/swh-search] and its subdirectories
Creating an empty file named log4j2.properties in the CWD solves the issue.