Skip to content

Commit

Permalink
AssertBusy in testSimpleGetFieldMappingsWithDefaults
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dnhatn committed Jan 30, 2019
1 parent ed460c2 commit f565d79
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,27 @@ public void testSimpleGetFieldMappingsWithDefaults() throws Exception {

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

GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings()
.setFields("num", "field1", "obj.subfield").includeDefaults(true).get();

assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
hasEntry("index", Boolean.TRUE));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
hasEntry("type", "long"));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
hasEntry("index", Boolean.TRUE));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
hasEntry("type", "text"));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "obj.subfield").sourceAsMap().get("subfield"),
hasEntry("type", "keyword"));
// we need to await busily for the mapping because we don't require acking on the dynamic mapping of an index request.
assertBusy(() -> {
GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings()
.setFields("num", "field1", "obj.subfield").includeDefaults(true).get();

assertNotNull(response.fieldMappings("test", "type", "num"));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
hasEntry("index", Boolean.TRUE));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"),
hasEntry("type", "long"));

assertNotNull(response.fieldMappings("test", "type", "field1"));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
hasEntry("index", Boolean.TRUE));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"),
hasEntry("type", "text"));

assertNotNull(response.fieldMappings("test", "type", "obj.subfield"));
assertThat((Map<String, Object>) response.fieldMappings("test", "type", "obj.subfield").sourceAsMap().get("subfield"),
hasEntry("type", "keyword"));
});
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit f565d79

Please sign in to comment.