Skip to content

Commit 91f0838

Browse files
committed
Add missing refreshes in bulk test
We can't get the failure if we're not asking for a refresh.
1 parent c99e1a1 commit 91f0838

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

test_elasticsearch_serverless/test_async/test_server/test_helpers.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,34 +366,47 @@ async def test_error_is_raised(self, async_client):
366366
async def test_ignore_error_if_raised(self, async_client):
367367
# ignore the status code 400 in tuple
368368
await helpers.async_bulk(
369-
async_client, [{"a": 42}, {"a": "c"}], index="i", ignore_status=(400,)
369+
async_client,
370+
[{"a": 42}, {"a": "c"}],
371+
index="i",
372+
refresh=True,
373+
ignore_status=(400,),
370374
)
371375

372376
# ignore the status code 400 in list
373377
await helpers.async_bulk(
374378
async_client,
375379
[{"a": 42}, {"a": "c"}],
376380
index="i",
381+
refresh=True,
377382
ignore_status=[
378383
400,
379384
],
380385
)
381386

382387
# ignore the status code 400
383388
await helpers.async_bulk(
384-
async_client, [{"a": 42}, {"a": "c"}], index="i", ignore_status=400
389+
async_client,
390+
[{"a": 42}, {"a": "c"}],
391+
index="i",
392+
refresh=True,
393+
ignore_status=400,
385394
)
386395

387396
# ignore only the status code in the `ignore_status` argument
388397
with pytest.raises(helpers.BulkIndexError):
389398
await helpers.async_bulk(
390-
async_client, [{"a": 42}, {"a": "c"}], index="i", ignore_status=(444,)
399+
async_client,
400+
[{"a": 42}, {"a": "c"}],
401+
index="i",
402+
refresh=True,
403+
ignore_status=(444,),
391404
)
392405

393406
# ignore transport error exception
394407
failing_client = FailingBulkClient(async_client)
395408
await helpers.async_bulk(
396-
failing_client, [{"a": 42}], index="i", ignore_status=(599,)
409+
failing_client, [{"a": 42}], index="i", refresh=True, ignore_status=(599,)
397410
)
398411

399412
async def test_errors_are_collected_properly(self, async_client):

test_elasticsearch_serverless/test_server/test_helpers.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,33 +357,45 @@ def test_error_is_raised(sync_client):
357357

358358
def test_ignore_error_if_raised(sync_client):
359359
# ignore the status code 400 in tuple
360-
helpers.bulk(sync_client, [{"a": 42}, {"a": "c"}], index="i", ignore_status=(400,))
360+
helpers.bulk(
361+
sync_client,
362+
[{"a": 42}, {"a": "c"}],
363+
index="i",
364+
refresh=True,
365+
ignore_status=(400,),
366+
)
361367

362368
# ignore the status code 400 in list
363369
helpers.bulk(
364370
sync_client,
365371
[{"a": 42}, {"a": "c"}],
366372
index="i",
373+
refresh=True,
367374
ignore_status=[
368375
400,
369376
],
370377
)
371378

372379
# ignore the status code 400
373-
helpers.bulk(sync_client, [{"a": 42}, {"a": "c"}], index="i", ignore_status=400)
380+
helpers.bulk(
381+
sync_client, [{"a": 42}, {"a": "c"}], index="i", refresh=True, ignore_status=400
382+
)
374383

375384
# ignore only the status code in the `ignore_status` argument
376385
with pytest.raises(helpers.BulkIndexError):
377386
helpers.bulk(
378387
sync_client,
379388
[{"a": 42}, {"a": "c"}],
380389
index="i",
390+
refresh=True,
381391
ignore_status=(444,),
382392
)
383393

384394
# ignore transport error exception
385395
failing_client = FailingBulkClient(sync_client)
386-
helpers.bulk(failing_client, [{"a": 42}], index="i", ignore_status=(599,))
396+
helpers.bulk(
397+
failing_client, [{"a": 42}], index="i", refresh=True, ignore_status=(599,)
398+
)
387399

388400

389401
def test_errors_are_collected_properly(sync_client):

0 commit comments

Comments
 (0)