Skip to content

Commit 0e542e4

Browse files
authored
Merge branch 'main' into requires-serverless
2 parents cd2c94f + aba9787 commit 0e542e4

File tree

4 files changed

+19
-120
lines changed

4 files changed

+19
-120
lines changed

test_elasticsearch_serverless/test_async/test_server/test_clients.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ async def test_bulk_works_with_bytestring_body(async_client):
5151
docs = (
5252
b'{ "index" : { "_index" : "bulk_test_index", "_id" : "2" } }\n{"answer": 42}'
5353
)
54-
response = await async_client.bulk(body=docs)
54+
resp = await async_client.bulk(body=docs)
5555

56-
assert response["errors"] is False
57-
assert len(response["items"]) == 1
56+
assert resp["errors"] is False
57+
assert len(resp["items"]) == 1
58+
59+
# Pop inconsistent items before asserting
60+
resp["items"][0]["index"].pop("_id")
61+
resp["items"][0]["index"].pop("_version")
62+
resp["items"][0]["index"].pop("_shards")
63+
assert resp["items"][0] == {
64+
"index": {
65+
"_index": "bulk_test_index",
66+
"result": "created",
67+
"_seq_no": 0,
68+
"_primary_term": 1,
69+
"status": 201,
70+
}
71+
}

test_elasticsearch_serverless/test_async/test_server/test_helpers.py

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -940,66 +940,6 @@ async def test_all_documents_get_moved(self, async_client, reindex_setup):
940940
)["_source"]
941941

942942

943-
@pytest_asyncio.fixture(scope="function")
944-
async def parent_reindex_setup(async_client):
945-
body = {
946-
"mappings": {
947-
"properties": {
948-
"question_answer": {
949-
"type": "join",
950-
"relations": {"question": "answer"},
951-
}
952-
}
953-
},
954-
}
955-
await async_client.indices.create(index="test-index", body=body)
956-
await async_client.indices.create(index="real-index", body=body)
957-
958-
await async_client.index(
959-
index="test-index", id=42, body={"question_answer": "question"}
960-
)
961-
await async_client.index(
962-
index="test-index",
963-
id=47,
964-
routing=42,
965-
body={"some": "data", "question_answer": {"name": "answer", "parent": 42}},
966-
refresh=True,
967-
)
968-
969-
970-
class TestParentChildReindex:
971-
async def test_children_are_reindexed_correctly(
972-
self, async_client, parent_reindex_setup
973-
):
974-
await helpers.async_reindex(async_client, "test-index", "real-index")
975-
976-
q = await async_client.get(index="real-index", id=42)
977-
assert {
978-
"_id": "42",
979-
"_index": "real-index",
980-
"_primary_term": 1,
981-
"_seq_no": 0,
982-
"_source": {"question_answer": "question"},
983-
"_version": 1,
984-
"found": True,
985-
} == q
986-
987-
q = await async_client.get(index="test-index", id=47, routing=42)
988-
assert {
989-
"_routing": "42",
990-
"_id": "47",
991-
"_index": "test-index",
992-
"_primary_term": 1,
993-
"_seq_no": 1,
994-
"_source": {
995-
"some": "data",
996-
"question_answer": {"name": "answer", "parent": 42},
997-
},
998-
"_version": 1,
999-
"found": True,
1000-
} == q
1001-
1002-
1003943
@pytest_asyncio.fixture(scope="function")
1004944
async def reindex_data_stream_setup(async_client):
1005945
dt = datetime.now(tz=timezone.utc)
@@ -1022,7 +962,7 @@ async def reindex_data_stream_setup(async_client):
1022962
"data_stream": {},
1023963
},
1024964
)
1025-
await async_client.indices.create_data_stream(name="py-test-stream", refresh=True)
965+
await async_client.indices.create_data_stream(name="py-test-stream")
1026966
yield
1027967

1028968

test_elasticsearch_serverless/test_server/test_clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def test_bulk_works_with_bytestring_body(sync_client):
5555
# Pop inconsistent items before asserting
5656
resp["items"][0]["index"].pop("_id")
5757
resp["items"][0]["index"].pop("_version")
58+
resp["items"][0]["index"].pop("_shards")
5859
assert resp["items"][0] == {
5960
"index": {
6061
"_index": "bulk_test_index",
6162
"result": "created",
62-
"_shards": {"total": 2, "successful": 1, "failed": 0},
6363
"_seq_no": 0,
6464
"_primary_term": 1,
6565
"status": 201,

test_elasticsearch_serverless/test_server/test_helpers.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -887,61 +887,6 @@ def test_all_documents_get_moved(sync_client):
887887
)["_source"]
888888

889889

890-
@pytest.fixture(scope="function")
891-
def parent_child_reindex_setup(sync_client):
892-
body = {
893-
"mappings": {
894-
"properties": {
895-
"question_answer": {
896-
"type": "join",
897-
"relations": {"question": "answer"},
898-
}
899-
}
900-
},
901-
}
902-
sync_client.indices.create(index="test-index", body=body)
903-
sync_client.indices.create(index="real-index", body=body)
904-
905-
sync_client.index(index="test-index", id=42, body={"question_answer": "question"})
906-
sync_client.index(
907-
index="test-index",
908-
id=47,
909-
routing=42,
910-
body={"some": "data", "question_answer": {"name": "answer", "parent": 42}},
911-
refresh=True,
912-
)
913-
914-
915-
@pytest.mark.usefixtures("parent_child_reindex_setup")
916-
def test_children_are_reindexed_correctly(sync_client):
917-
helpers.reindex(sync_client, "test-index", "real-index")
918-
919-
q = sync_client.get(index="real-index", id=42)
920-
assert {
921-
"_id": "42",
922-
"_index": "real-index",
923-
"_primary_term": 1,
924-
"_seq_no": 0,
925-
"_source": {"question_answer": "question"},
926-
"_version": 1,
927-
"found": True,
928-
} == q
929-
q = sync_client.get(index="test-index", id=47, routing=42)
930-
assert {
931-
"_routing": "42",
932-
"_id": "47",
933-
"_index": "test-index",
934-
"_primary_term": 1,
935-
"_seq_no": 1,
936-
"_source": {
937-
"some": "data",
938-
"question_answer": {"name": "answer", "parent": 42},
939-
},
940-
"_version": 1,
941-
"found": True,
942-
} == q
943-
944-
945890
@pytest.fixture(scope="function")
946891
def reindex_data_stream_setup(sync_client):
947892
dt = datetime.now(tz=tz.UTC)

0 commit comments

Comments
 (0)