From b1d36926c17e273388d513505d029cdab546eea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Tue, 20 May 2014 15:05:40 +0200 Subject: [PATCH] Allow get_test_client to not wait for es cluster startup --- elasticsearch/helpers/test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/elasticsearch/helpers/test.py b/elasticsearch/helpers/test.py index d81f05aa..39ddd21e 100644 --- a/elasticsearch/helpers/test.py +++ b/elasticsearch/helpers/test.py @@ -9,7 +9,7 @@ except ImportError: from elasticsearch import Elasticsearch from elasticsearch.exceptions import ConnectionError -def get_test_client(): +def get_test_client(nowait=False): # construct kwargs from the environment kw = {} if 'TEST_ES_CONNECTION' in os.environ: @@ -19,13 +19,12 @@ def get_test_client(): client = Elasticsearch([os.environ.get('TEST_ES_SERVER', {})], **kw) # wait for yellow status - for _ in range(100): - time.sleep(.1) + for _ in range(1 if nowait else 100): try: client.cluster.health(wait_for_status='yellow') return client except ConnectionError: - continue + time.sleep(.1) else: # timeout raise SkipTest("Elasticsearch failed to start.")