Skip to content

Commit f565d79

Browse files
committed
AssertBusy in testSimpleGetFieldMappingsWithDefaults
We need to await busily for the mapping in this test because we no longer require acking on the dynamic mapping of an index request. Relates elastic#31140 Closes elastic#37928
1 parent ed460c2 commit f565d79

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

server/src/test/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,27 @@ public void testSimpleGetFieldMappingsWithDefaults() throws Exception {
150150

151151
client().prepareIndex("test", "type", "1").setSource("num", 1).get();
152152

153-
GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings()
154-
.setFields("num", "field1", "obj.subfield").includeDefaults(true).get();
155-
156-
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
157-
hasEntry("index", Boolean.TRUE));
158-
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
159-
hasEntry("type", "long"));
160-
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
161-
hasEntry("index", Boolean.TRUE));
162-
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
163-
hasEntry("type", "text"));
164-
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "obj.subfield").sourceAsMap().get("subfield"),
165-
hasEntry("type", "keyword"));
153+
// we need to await busily for the mapping because we don't require acking on the dynamic mapping of an index request.
154+
assertBusy(() -> {
155+
GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings()
156+
.setFields("num", "field1", "obj.subfield").includeDefaults(true).get();
157+
158+
assertNotNull(response.fieldMappings("test", "type", "num"));
159+
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
160+
hasEntry("index", Boolean.TRUE));
161+
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
162+
hasEntry("type", "long"));
163+
164+
assertNotNull(response.fieldMappings("test", "type", "field1"));
165+
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
166+
hasEntry("index", Boolean.TRUE));
167+
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
168+
hasEntry("type", "text"));
169+
170+
assertNotNull(response.fieldMappings("test", "type", "obj.subfield"));
171+
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "obj.subfield").sourceAsMap().get("subfield"),
172+
hasEntry("type", "keyword"));
173+
});
166174
}
167175

168176
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)