Skip to content

Commit 1d951c6

Browse files
wipe cluster after dsl tests
1 parent ea43c06 commit 1d951c6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test_elasticsearch/test_dsl/conftest.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from elasticsearch.exceptions import ConnectionError
3838
from elasticsearch.helpers import bulk
3939

40-
from ..utils import CA_CERTS
40+
from ..utils import CA_CERTS, wipe_cluster
4141
from .test_integration._async import test_document as async_document
4242
from .test_integration._sync import test_document as sync_document
4343
from .test_integration.test_data import (
@@ -110,14 +110,16 @@ def _get_version(version_string: str) -> Tuple[int, ...]:
110110
return tuple(int(v) if v.isdigit() else 999 for v in version)
111111

112112

113-
@fixture(scope="session")
113+
@fixture
114114
def client(elasticsearch_url) -> Elasticsearch:
115115
try:
116116
connection = get_test_client(
117117
elasticsearch_url, wait="WAIT_FOR_ES" in os.environ
118118
)
119119
add_connection("default", connection)
120-
return connection
120+
yield connection
121+
wipe_cluster(connection)
122+
connection.close()
121123
except SkipTest:
122124
skip()
123125

@@ -130,12 +132,13 @@ async def async_client(elasticsearch_url) -> AsyncGenerator[AsyncElasticsearch,
130132
)
131133
add_async_connection("default", connection)
132134
yield connection
135+
wipe_cluster(connection)
133136
await connection.close()
134137
except SkipTest:
135138
skip()
136139

137140

138-
@fixture(scope="session")
141+
@fixture
139142
def es_version(client: Elasticsearch) -> Generator[Tuple[int, ...], None, None]:
140143
info = client.info()
141144
yield tuple(
@@ -192,7 +195,7 @@ def async_mock_client(
192195
async_connections._kwargs = {}
193196

194197

195-
@fixture(scope="session")
198+
@fixture
196199
def data_client(client: Elasticsearch) -> Generator[Elasticsearch, None, None]:
197200
# create mappings
198201
create_git_index(client, "git")

0 commit comments

Comments
 (0)