File tree Expand file tree Collapse file tree 5 files changed +28
-26
lines changed
Expand file tree Collapse file tree 5 files changed +28
-26
lines changed Original file line number Diff line number Diff line change 2424from elasticsearch import Elasticsearch
2525from elasticsearch .exceptions import ConnectionError
2626
27+ if "ELASTICSEARCH_URL" in os .environ :
28+ ELASTICSEARCH_URL = os .environ ["ELASTICSEARCH_URL" ]
29+ elif os .environ .get ("TEST_SUITE" ) == "platinum" :
30+ ELASTICSEARCH_URL = "https://elastic:changeme@localhost:9200"
31+ else :
32+ ELASTICSEARCH_URL = "http://localhost:9200"
33+
2734
2835def get_test_client (nowait = False , ** kwargs ):
2936 # construct kwargs from the environment
@@ -37,7 +44,7 @@ def get_test_client(nowait=False, **kwargs):
3744 )
3845
3946 kw .update (kwargs )
40- client = Elasticsearch (os . environ . get ( " ELASTICSEARCH_URL" , {}) , ** kw )
47+ client = Elasticsearch (ELASTICSEARCH_URL , ** kw )
4148
4249 # wait for yellow status
4350 for _ in range (1 if nowait else 100 ):
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ from typing import Any, Tuple
1919from unittest import TestCase
2020from ..client import Elasticsearch
2121
22+ ELASTICSEARCH_URL : str
23+
2224def get_test_client (nowait : bool = ..., ** kwargs : Any ) -> Elasticsearch : ...
2325def _get_version (version_string : str ) -> Tuple [int , ...]: ...
2426
Original file line number Diff line number Diff line change 1515# specific language governing permissions and limitations
1616# under the License.
1717
18- import os
19- import pytest
2018import asyncio
19+
20+ import pytest
2121import elasticsearch
22+ from elasticsearch .helpers .test import ELASTICSEARCH_URL
23+
2224from ...utils import wipe_cluster
2325
2426pytestmark = pytest .mark .asyncio
@@ -31,15 +33,8 @@ async def async_client():
3133 if not hasattr (elasticsearch , "AsyncElasticsearch" ):
3234 pytest .skip ("test requires 'AsyncElasticsearch'" )
3335
34- kw = {
35- "timeout" : 3 ,
36- "ca_certs" : ".ci/certs/ca.pem" ,
37- "connection_class" : elasticsearch .AIOHttpConnection ,
38- }
39-
40- client = elasticsearch .AsyncElasticsearch (
41- [os .environ .get ("ELASTICSEARCH_HOST" , {})], ** kw
42- )
36+ kw = {"timeout" : 3 , "ca_certs" : ".ci/certs/ca.pem" }
37+ client = elasticsearch .AsyncElasticsearch (ELASTICSEARCH_URL , ** kw )
4338
4439 # wait for yellow status
4540 for _ in range (100 ):
Original file line number Diff line number Diff line change 1919import time
2020import pytest
2121import elasticsearch
22+ from elasticsearch .helpers .test import ELASTICSEARCH_URL
23+
2224from ..utils import wipe_cluster
2325
2426
2527@pytest .fixture (scope = "function" )
2628def sync_client ():
2729 client = None
2830 try :
29- kw = {
30- "timeout" : 3 ,
31- "ca_certs" : ".ci/certs/ca.pem" ,
32- "connection_class" : getattr (
33- elasticsearch ,
34- os .environ .get ("PYTHON_CONNECTION_CLASS" , "Urllib3HttpConnection" ),
35- ),
36- }
37-
38- client = elasticsearch .Elasticsearch (
39- [os .environ .get ("ELASTICSEARCH_URL" , {})], ** kw
40- )
31+ kw = {"timeout" : 3 , "ca_certs" : ".ci/certs/ca.pem" }
32+ if "PYTHON_CONNECTION_CLASS" in os .environ :
33+ from elasticsearch import connection
34+
35+ kw ["connection_class" ] = getattr (
36+ connection , os .environ ["PYTHON_CONNECTION_CLASS" ]
37+ )
38+
39+ client = elasticsearch .Elasticsearch (ELASTICSEARCH_URL , ** kw )
4140
4241 # wait for yellow status
4342 for _ in range (100 ):
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ def wipe_cluster_settings(client):
7070 for name , value in settings .items ():
7171 if value :
7272 new_settings .setdefault (name , {})
73- for key in name .keys ():
73+ for key in value .keys ():
7474 new_settings [name ][key + ".*" ] = None
7575 if new_settings :
7676 client .cluster .put_settings (body = new_settings )
@@ -103,7 +103,6 @@ def wipe_data_streams(client):
103103
104104
105105def wipe_indices (client ):
106-
107106 client .indices .delete (
108107 index = "*" ,
109108 expand_wildcards = "all" ,
You can’t perform that action at this time.
0 commit comments