Skip to content

Commit 6a58051

Browse files
committed
Fixing race condition in DynamicMappingIT when checking for updates in mappings
1 parent c3255ad commit 6a58051

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,6 @@ tests:
568568
- class: org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapperTests
569569
method: testExistsQueryMinimalMapping
570570
issue: https://github.com/elastic/elasticsearch/issues/129911
571-
- class: org.elasticsearch.index.mapper.DynamicMappingIT
572-
method: testDenseVectorDynamicMapping
573-
issue: https://github.com/elastic/elasticsearch/issues/129928
574571

575572
# Examples:
576573
#

server/src/internalClusterTest/java/org/elasticsearch/index/mapper/DynamicMappingIT.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -924,15 +924,21 @@ public void testDenseVectorDynamicMapping() throws Exception {
924924
client().index(
925925
new IndexRequest("test").source("vector_bbq", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD, 0.0, 5.0).toArray())
926926
).get();
927-
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
928-
.get()
929-
.mappings()
930-
.get("test")
931-
.sourceAsMap();
932-
assertTrue(new WriteField("properties.vector_int8", () -> mappings).exists());
933-
assertTrue(new WriteField("properties.vector_int8.index_options.type", () -> mappings).get(null).toString().equals("int8_hnsw"));
934-
assertTrue(new WriteField("properties.vector_bbq", () -> mappings).exists());
935-
assertTrue(new WriteField("properties.vector_bbq.index_options.type", () -> mappings).get(null).toString().equals("bbq_hnsw"));
927+
928+
assertBusy(() -> {
929+
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
930+
.get()
931+
.mappings()
932+
.get("test")
933+
.sourceAsMap();
934+
935+
assertTrue(new WriteField("properties.vector_int8", () -> mappings).exists());
936+
assertTrue(
937+
new WriteField("properties.vector_int8.index_options.type", () -> mappings).get(null).toString().equals("int8_hnsw")
938+
);
939+
assertTrue(new WriteField("properties.vector_bbq", () -> mappings).exists());
940+
assertTrue(new WriteField("properties.vector_bbq.index_options.type", () -> mappings).get(null).toString().equals("bbq_hnsw"));
941+
});
936942
}
937943

938944
public void testBBQDynamicMappingWhenFirstIngestingDoc() throws Exception {
@@ -956,12 +962,15 @@ public void testBBQDynamicMappingWhenFirstIngestingDoc() throws Exception {
956962

957963
client().index(new IndexRequest("test").source("vector", Randomness.get().doubles(BBQ_DIMS_DEFAULT_THRESHOLD, 0.0, 5.0).toArray()))
958964
.get();
959-
Map<String, Object> updatedMappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
960-
.get()
961-
.mappings()
962-
.get("test")
963-
.sourceAsMap();
964-
assertTrue(new WriteField("properties.vector", () -> updatedMappings).exists());
965-
assertTrue(new WriteField("properties.vector.index_options.type", () -> updatedMappings).get(null).toString().equals("bbq_hnsw"));
965+
966+
assertBusy(() -> {
967+
Map<String, Object> updatedMappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
968+
.get()
969+
.mappings()
970+
.get("test")
971+
.sourceAsMap();
972+
assertTrue(new WriteField("properties.vector", () -> updatedMappings).exists());
973+
assertTrue(new WriteField("properties.vector.index_options.type", () -> updatedMappings).get("").toString().equals("bbq_hnsw"));
974+
});
966975
}
967976
}

0 commit comments

Comments
 (0)