Skip to content

Commit dddc0c1

Browse files
committed
Drop functionality from tests that isn't available in serverless
1 parent 92f27cb commit dddc0c1

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

test_elasticsearch_serverless/test_server/test_helpers.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_bulk_actions_remain_unchanged(sync_client):
6666
def test_bulk_all_documents_get_inserted(sync_client):
6767
docs = [{"answer": x, "_id": x} for x in range(100)]
6868
for ok, item in helpers.streaming_bulk(
69-
sync_client, docs, index="test-index", refresh=True
69+
sync_client, docs, index="test-index"
7070
):
7171
assert ok
7272

@@ -79,7 +79,6 @@ def test_bulk_all_errors_from_chunk_are_raised_on_failure(sync_client):
7979
index="i",
8080
body={
8181
"mappings": {"properties": {"a": {"type": "integer"}}},
82-
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
8382
},
8483
)
8584
sync_client.cluster.health(wait_for_status="yellow")
@@ -177,7 +176,6 @@ def test_bulk_rejected_documents_are_retried(sync_client):
177176
assert 3 == len(results)
178177
print(results)
179178
assert [True, True, True] == [r[0] for r in results]
180-
sync_client.indices.refresh(index="i")
181179
res = sync_client.search(index="i")
182180
assert {"value": 3, "relation": "eq"} == res["hits"]["total"]
183181
assert 4 == failing_client._called
@@ -215,7 +213,6 @@ def test_bulk_rejected_documents_are_retried_when_bytes_or_string(
215213
)
216214
assert 3 == len(results)
217215
assert [True, True, True] == [r[0] for r in results]
218-
sync_client.indices.refresh(index="i")
219216
res = sync_client.search(index="i")
220217
assert {"value": 3, "relation": "eq"} == res["hits"]["total"]
221218
assert 4 == failing_client._called
@@ -252,7 +249,6 @@ def test_bulk_rejected_documents_are_retried_at_most_max_retries_times(sync_clie
252249
)
253250
assert 3 == len(results)
254251
assert [False, True, True] == [r[0] for r in results]
255-
sync_client.indices.refresh(index="i")
256252
res = sync_client.search(index="i")
257253
assert {"value": 2, "relation": "eq"} == res["hits"]["total"]
258254
assert 4 == failing_client._called
@@ -290,7 +286,7 @@ def streaming_bulk():
290286

291287
def test_bulk_works_with_single_item(sync_client):
292288
docs = [{"answer": 42, "_id": 1}]
293-
success, failed = helpers.bulk(sync_client, docs, index="test-index", refresh=True)
289+
success, failed = helpers.bulk(sync_client, docs, index="test-index")
294290

295291
assert 1 == success
296292
assert not failed
@@ -300,7 +296,7 @@ def test_bulk_works_with_single_item(sync_client):
300296

301297
def test_all_documents_get_inserted(sync_client):
302298
docs = [{"answer": x, "_id": x} for x in range(100)]
303-
success, failed = helpers.bulk(sync_client, docs, index="test-index", refresh=True)
299+
success, failed = helpers.bulk(sync_client, docs, index="test-index")
304300

305301
assert 100 == success
306302
assert not failed
@@ -311,7 +307,7 @@ def test_all_documents_get_inserted(sync_client):
311307
def test_stats_only_reports_numbers(sync_client):
312308
docs = [{"answer": x} for x in range(100)]
313309
success, failed = helpers.bulk(
314-
sync_client, docs, index="test-index", refresh=True, stats_only=True
310+
sync_client, docs, index="test-index", stats_only=True
315311
)
316312

317313
assert 100 == success
@@ -323,7 +319,6 @@ def test_errors_are_reported_correctly(sync_client):
323319
sync_client.indices.create(
324320
index="i",
325321
mappings={"properties": {"a": {"type": "integer"}}},
326-
settings={"number_of_shards": 1, "number_of_replicas": 0},
327322
)
328323
sync_client.cluster.health(wait_for_status="yellow")
329324

@@ -348,7 +343,6 @@ def test_error_is_raised(sync_client):
348343
sync_client.indices.create(
349344
index="i",
350345
mappings={"properties": {"a": {"type": "integer"}}},
351-
settings={"number_of_shards": 1, "number_of_replicas": 0},
352346
)
353347
sync_client.cluster.health(wait_for_status="yellow")
354348

@@ -395,7 +389,6 @@ def test_errors_are_collected_properly(sync_client):
395389
sync_client.indices.create(
396390
index="i",
397391
mappings={"properties": {"a": {"type": "integer"}}},
398-
settings={"number_of_shards": 1, "number_of_replicas": 0},
399392
)
400393
sync_client.cluster.health(wait_for_status="yellow")
401394

@@ -442,7 +435,7 @@ def test_order_can_be_preserved(sync_client):
442435
for x in range(100):
443436
bulk.append({"index": {"_index": "test_index", "_id": x}})
444437
bulk.append({"answer": x, "correct": x == 42})
445-
sync_client.bulk(operations=bulk, refresh=True)
438+
sync_client.bulk(operations=bulk)
446439

447440
docs = list(
448441
helpers.scan(
@@ -464,7 +457,7 @@ def test_all_documents_are_read(sync_client):
464457
for x in range(100):
465458
bulk.append({"index": {"_index": "test_index", "_id": x}})
466459
bulk.append({"answer": x, "correct": x == 42})
467-
sync_client.bulk(operations=bulk, refresh=True)
460+
sync_client.bulk(operations=bulk)
468461

469462
docs = list(helpers.scan(sync_client, index="test_index", size=2))
470463

@@ -479,7 +472,7 @@ def test_scroll_error(sync_client):
479472
for x in range(4):
480473
bulk.append({"index": {"_index": "test_index"}})
481474
bulk.append({"value": x})
482-
sync_client.bulk(operations=bulk, refresh=True)
475+
sync_client.bulk(operations=bulk)
483476

484477
with patch.object(sync_client, "options", return_value=sync_client), patch.object(
485478
sync_client, "scroll"
@@ -699,7 +692,7 @@ def test_log_warning_on_shard_failures(sync_client):
699692
for x in range(4):
700693
bulk.append({"index": {"_index": "test_index"}})
701694
bulk.append({"value": x})
702-
sync_client.bulk(operations=bulk, refresh=True)
695+
sync_client.bulk(operations=bulk)
703696

704697
with patch(
705698
"elasticsearch_serverless.helpers.actions.logger"
@@ -741,7 +734,7 @@ def test_clear_scroll(sync_client):
741734
for x in range(4):
742735
bulk.append({"index": {"_index": "test_index"}})
743736
bulk.append({"value": x})
744-
sync_client.bulk(operations=bulk, refresh=True)
737+
sync_client.bulk(operations=bulk)
745738

746739
with patch.object(sync_client, "options", return_value=sync_client), patch.object(
747740
sync_client, "clear_scroll", wraps=sync_client.clear_scroll
@@ -840,7 +833,7 @@ def reindex_setup(sync_client):
840833
"type": "answers" if x % 2 == 0 else "questions",
841834
}
842835
)
843-
sync_client.bulk(operations=bulk, refresh=True)
836+
sync_client.bulk(operations=bulk)
844837

845838

846839
@pytest.mark.usefixtures("reindex_setup")
@@ -850,7 +843,6 @@ def test_reindex_passes_kwargs_to_scan_and_bulk(sync_client):
850843
"test_index",
851844
"prod_index",
852845
scan_kwargs={"q": "type:answers"},
853-
bulk_kwargs={"refresh": True},
854846
)
855847

856848
assert sync_client.indices.exists(index="prod_index")
@@ -869,7 +861,6 @@ def test_reindex_accepts_a_query(sync_client):
869861
"prod_index",
870862
query={"query": {"bool": {"filter": {"term": {"type": "answers"}}}}},
871863
)
872-
sync_client.indices.refresh()
873864

874865
assert sync_client.indices.exists(index="prod_index")
875866
assert 50 == sync_client.count(index="prod_index", q="type:answers")["count"]
@@ -882,7 +873,6 @@ def test_reindex_accepts_a_query(sync_client):
882873
@pytest.mark.usefixtures("reindex_setup")
883874
def test_all_documents_get_moved(sync_client):
884875
helpers.reindex(sync_client, "test_index", "prod_index")
885-
sync_client.indices.refresh()
886876

887877
assert sync_client.indices.exists(index="prod_index")
888878
assert 50 == sync_client.count(index="prod_index", q="type:questions")["count"]
@@ -896,7 +886,6 @@ def test_all_documents_get_moved(sync_client):
896886
@pytest.fixture(scope="function")
897887
def parent_child_reindex_setup(sync_client):
898888
body = {
899-
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
900889
"mappings": {
901890
"properties": {
902891
"question_answer": {
@@ -916,7 +905,6 @@ def parent_child_reindex_setup(sync_client):
916905
routing=42,
917906
body={"some": "data", "question_answer": {"name": "answer", "parent": 42}},
918907
)
919-
sync_client.indices.refresh(index="test-index")
920908

921909

922910
@pytest.mark.usefixtures("parent_child_reindex_setup")
@@ -963,7 +951,7 @@ def reindex_data_stream_setup(sync_client):
963951
"@timestamp": (dt - timedelta(days=x)).isoformat(),
964952
}
965953
)
966-
sync_client.bulk(operations=bulk, refresh=True)
954+
sync_client.bulk(operations=bulk)
967955
sync_client.indices.put_index_template(
968956
name="my-index-template",
969957
body={
@@ -972,7 +960,6 @@ def reindex_data_stream_setup(sync_client):
972960
},
973961
)
974962
sync_client.indices.create_data_stream(name="py-test-stream")
975-
sync_client.indices.refresh()
976963

977964

978965
@pytest.mark.usefixtures("reindex_data_stream_setup")
@@ -985,7 +972,6 @@ def test_reindex_index_datastream(op_type, sync_client):
985972
query={"query": {"bool": {"filter": {"term": {"type": "answers"}}}}},
986973
op_type=op_type,
987974
)
988-
sync_client.indices.refresh()
989975
assert sync_client.indices.exists(index="py-test-stream")
990976
assert 50 == sync_client.count(index="py-test-stream", q="type:answers")["count"]
991977

test_elasticsearch_serverless/test_server/test_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def test_text_response(sync_client):
20-
resp = sync_client.cat.tasks()
20+
resp = sync_client.cat.aliases()
2121
assert resp.meta.status == 200
2222
assert isinstance(resp.body, str)
2323
assert str(resp.body) == str(resp)

0 commit comments

Comments
 (0)