Skip to content

Commit 7cee34e

Browse files
authored
Stop cleaning cluster between rest_api_spec tests (#56)
1 parent d010575 commit 7cee34e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

test_elasticsearch_serverless/test_async/test_server/conftest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
@pytest_asyncio.fixture(scope="function")
29-
async def async_client(elasticsearch_url, elasticsearch_api_key):
29+
async def async_client_factory(elasticsearch_url, elasticsearch_api_key):
3030

3131
if not hasattr(elasticsearch_serverless, "AsyncElasticsearch"):
3232
pytest.skip("test requires 'AsyncElasticsearch' and aiohttp to be installed")
@@ -37,10 +37,18 @@ async def async_client(elasticsearch_url, elasticsearch_api_key):
3737
client = None
3838
try:
3939
client = elasticsearch_serverless.AsyncElasticsearch(
40-
elasticsearch_url, api_key=elasticsearch_api_key, request_timeout=3
40+
elasticsearch_url, api_key=elasticsearch_api_key
4141
)
4242
yield client
4343
finally:
4444
if client:
45-
wipe_cluster(client, elasticsearch_api_key)
4645
await client.close()
46+
47+
48+
@pytest.fixture(scope="function")
49+
def async_client(async_client_factory, elasticsearch_api_key):
50+
try:
51+
yield async_client_factory
52+
finally:
53+
# Wipe the cluster clean after every test execution.
54+
wipe_cluster(async_client_factory, elasticsearch_api_key)

test_elasticsearch_serverless/test_async/test_server/test_rest_api_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ async def _feature_enabled(self, name):
241241

242242

243243
@pytest_asyncio.fixture(scope="function")
244-
def async_runner(async_client):
245-
return AsyncYamlRunner(async_client)
244+
def async_runner(async_client_factory):
245+
return AsyncYamlRunner(async_client_factory)
246246

247247

248248
if RUN_ASYNC_REST_API_TESTS:

test_elasticsearch_serverless/test_server/test_rest_api_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ def _skip_intentional_type_errors(self, e: Exception):
480480

481481

482482
@pytest.fixture(scope="function")
483-
def sync_runner(sync_client):
484-
return YamlRunner(sync_client)
483+
def sync_runner(sync_client_factory):
484+
return YamlRunner(sync_client_factory)
485485

486486

487487
# Source: https://stackoverflow.com/a/37958106/5763213

0 commit comments

Comments
 (0)