Skip to content

Commit

Permalink
wipe cluster after dsl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jan 15, 2025
1 parent ea43c06 commit 1d951c6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test_elasticsearch/test_dsl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from elasticsearch.exceptions import ConnectionError
from elasticsearch.helpers import bulk

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


@fixture(scope="session")
@fixture
def client(elasticsearch_url) -> Elasticsearch:
try:
connection = get_test_client(
elasticsearch_url, wait="WAIT_FOR_ES" in os.environ
)
add_connection("default", connection)
return connection
yield connection
wipe_cluster(connection)
connection.close()
except SkipTest:
skip()

Expand All @@ -130,12 +132,13 @@ async def async_client(elasticsearch_url) -> AsyncGenerator[AsyncElasticsearch,
)
add_async_connection("default", connection)
yield connection
wipe_cluster(connection)
await connection.close()
except SkipTest:
skip()


@fixture(scope="session")
@fixture
def es_version(client: Elasticsearch) -> Generator[Tuple[int, ...], None, None]:
info = client.info()
yield tuple(
Expand Down Expand Up @@ -192,7 +195,7 @@ def async_mock_client(
async_connections._kwargs = {}


@fixture(scope="session")
@fixture
def data_client(client: Elasticsearch) -> Generator[Elasticsearch, None, None]:
# create mappings
create_git_index(client, "git")
Expand Down

0 comments on commit 1d951c6

Please sign in to comment.