File tree 5 files changed +28
-26
lines changed
5 files changed +28
-26
lines changed Original file line number Diff line number Diff line change 24
24
from elasticsearch import Elasticsearch
25
25
from elasticsearch .exceptions import ConnectionError
26
26
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
+
27
34
28
35
def get_test_client (nowait = False , ** kwargs ):
29
36
# construct kwargs from the environment
@@ -37,7 +44,7 @@ def get_test_client(nowait=False, **kwargs):
37
44
)
38
45
39
46
kw .update (kwargs )
40
- client = Elasticsearch (os . environ . get ( " ELASTICSEARCH_URL" , {}) , ** kw )
47
+ client = Elasticsearch (ELASTICSEARCH_URL , ** kw )
41
48
42
49
# wait for yellow status
43
50
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
19
19
from unittest import TestCase
20
20
from ..client import Elasticsearch
21
21
22
+ ELASTICSEARCH_URL : str
23
+
22
24
def get_test_client (nowait : bool = ..., ** kwargs : Any ) -> Elasticsearch : ...
23
25
def _get_version (version_string : str ) -> Tuple [int , ...]: ...
24
26
Original file line number Diff line number Diff line change 15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
18
- import os
19
- import pytest
20
18
import asyncio
19
+
20
+ import pytest
21
21
import elasticsearch
22
+ from elasticsearch .helpers .test import ELASTICSEARCH_URL
23
+
22
24
from ...utils import wipe_cluster
23
25
24
26
pytestmark = pytest .mark .asyncio
@@ -31,15 +33,8 @@ async def async_client():
31
33
if not hasattr (elasticsearch , "AsyncElasticsearch" ):
32
34
pytest .skip ("test requires 'AsyncElasticsearch'" )
33
35
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 )
43
38
44
39
# wait for yellow status
45
40
for _ in range (100 ):
Original file line number Diff line number Diff line change 19
19
import time
20
20
import pytest
21
21
import elasticsearch
22
+ from elasticsearch .helpers .test import ELASTICSEARCH_URL
23
+
22
24
from ..utils import wipe_cluster
23
25
24
26
25
27
@pytest .fixture (scope = "function" )
26
28
def sync_client ():
27
29
client = None
28
30
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 )
41
40
42
41
# wait for yellow status
43
42
for _ in range (100 ):
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ def wipe_cluster_settings(client):
70
70
for name , value in settings .items ():
71
71
if value :
72
72
new_settings .setdefault (name , {})
73
- for key in name .keys ():
73
+ for key in value .keys ():
74
74
new_settings [name ][key + ".*" ] = None
75
75
if new_settings :
76
76
client .cluster .put_settings (body = new_settings )
@@ -103,7 +103,6 @@ def wipe_data_streams(client):
103
103
104
104
105
105
def wipe_indices (client ):
106
-
107
106
client .indices .delete (
108
107
index = "*" ,
109
108
expand_wildcards = "all" ,
You can’t perform that action at this time.
0 commit comments