def client(): try: connection = get_test_client(nowait='WAIT_FOR_ES' not in os.environ) connections.add_connection('default', connection) return connection except SkipTest: skip()
def client(): try: connection = get_test_client(nowait="WAIT_FOR_ES" not in os.environ) add_connection("default", connection) return connection except SkipTest: skip()
def client(): try: connection = get_test_client(nowait='WAIT_FOR_ES' not in os.environ) connections.add_connection('default', connection) return connection except SkipTest: skip()
def elastic_client(): try: connection = get_test_client() add_connection("default", connection) yield connection connection.indices.delete("test-*", ignore=404) except SkipTest: skip()
def client(request): # hack to workaround pytest not caching skip on fixtures (#467) global _client_loaded if _client_loaded: skip() _client_loaded = True try: return get_test_client(nowait='WAIT_FOR_ES' not in os.environ) except SkipTest: skip()
def client(request): # hack to workaround pytest not caching skip on fixtures (#467) global _client_loaded if _client_loaded: skip() _client_loaded = True try: return get_test_client(nowait=True) except SkipTest: skip()
def get_client(): global client if client is not None: return client # try and locate manual override in the local environment try: from test_elasticsearch.local import get_client as local_get_client client = local_get_client() except ImportError: # fallback to using vanilla client client = get_test_client() return client
def client(request): # inner import to avoid throwing off coverage from elasticsearch_dsl.connections import connections # hack to workaround pytest not caching skip on fixtures (#467) global _client_loaded if _client_loaded: skip() _client_loaded = True try: client = get_test_client(nowait='WAIT_FOR_ES' not in os.environ) connections.add_connection('default', client) return client except SkipTest: skip()
def _es_client(worker_id): """ Makes the ES test helper client available. Also patches settings.ES_INDEX_PREFIX using the xdist worker ID so that each process gets unique indices when running tests using multiple processes using pytest -n. """ # pytest's monkeypatch does not work in session fixtures, but there is no need to restore # the value so we just overwrite it normally settings.ES_INDEX_PREFIX = f'test_{worker_id}' from elasticsearch_dsl.connections import connections client = get_test_client(nowait=False) connections.add_connection('default', client) yield client
def get_client(): global client if client is not None: return client # try and locate manual override in the local environment try: from test_elasticsearch.local import get_client as local_get_client client = local_get_client() except ImportError: # fallback to using vanilla client client = get_test_client() return client
def get_client(**kwargs): global client if client is not None and not kwargs: return client # try and locate manual override in the local environment try: from test_elasticsearch.local import get_client as local_get_client new_client = local_get_client(**kwargs) except ImportError: # fallback to using vanilla client new_client = get_test_client(**kwargs) if not kwargs: client = new_client return new_client
def get_client(**kwargs): global client if client is not None and not kwargs: return client # try and locate manual override in the local environment try: from test_elasticsearch.local import get_client as local_get_client new_client = local_get_client(**kwargs) except ImportError: # fallback to using vanilla client new_client = get_test_client(**kwargs) if not kwargs: client = new_client return new_client
def get_client(**kwargs): global client if client is False: raise SkipTest("No client is available") if client is not None and not kwargs: return client # try and locate manual override in the local environment try: from test_elasticsearch.local import get_client as local_get_client new_client = local_get_client(**kwargs) except ImportError: # fallback to using vanilla client try: new_client = test.get_test_client(**kwargs) except SkipTest: client = False raise if not kwargs: client = new_client return new_client
import unittest, logging, time from es_injectors import elasticsearch_injector as es from elasticsearch.helpers.test import get_test_client, ElasticsearchTestCase as BaseTestCase import random, threading, socket metric_index = 'es_injector_test' bind_port = 8888 host = '0.0.0.0' #TEST_ES_SERVER es_client = get_test_client() parser = es.OpenTsdbParser() es_injector = es.ElasticsearchSender(parser, es_client, metric_index) server = es.AggregatorServer(host, bind_port, es_injector) server.start() class Client(threading.Thread): def __init__(self, host, port, client_id, iterations): threading.Thread.__init__(self, name='Client') self.setDaemon(True) self.port = port self.client_id = client_id self.iterations = iterations def run(self):
def setUp(self): super(TestElasticsearchSender, self).setUp() self._logger_handler.reset() # So each test is independent self.es_client = get_test_client() #TEST_ES_SERVER
def setUp(self): super(TestElasticsearchSender, self).setUp() self._logger_handler.reset() # So each test is independent self.es_client = get_test_client() # TEST_ES_SERVER
def es_connection(): es_connection = get_test_client() add_connection("default", es_connection) yield es_connection
def client(elasticsearch_instance): """Return a connection to the elasticsearch server """ connection = get_test_client(nowait=True) connections.add_connection("default", connection) return connection
def client(): try: return get_test_client() except SkipTest: skip()
import unittest, logging, time from es_injectors import elasticsearch_injector as es from elasticsearch.helpers.test import get_test_client, ElasticsearchTestCase as BaseTestCase import random, threading, socket metric_index = 'es_injector_test' bind_port = 8888 host = '0.0.0.0' #TEST_ES_SERVER es_client = get_test_client() parser = es.OpenTsdbParser() es_injector = es.ElasticsearchSender(parser, es_client, metric_index) server = es.AggregatorServer(host, bind_port, es_injector) server.start() class Client(threading.Thread): def __init__(self, host, port, client_id, iterations): threading.Thread.__init__(self, name='Client') self.setDaemon(True) self.port = port self.client_id = client_id self.iterations = iterations def run(self):