24
24
import org .elasticsearch .common .settings .Settings ;
25
25
import org .elasticsearch .test .ESIntegTestCase ;
26
26
27
- import java .io .IOException ;
28
-
29
27
import static org .elasticsearch .index .mapper .DynamicMappingIT .assertMappingsHaveField ;
30
28
import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
31
29
@@ -36,25 +34,32 @@ protected boolean forbidPrivateIndexSettings() {
36
34
return false ;
37
35
}
38
36
39
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/37817" )
40
- public void testMappingsPropagatedToMasterNodeImmediatelyMultiType () throws IOException {
37
+ public void testMappingsPropagatedToMasterNodeImmediatelyMultiType () throws Exception {
41
38
assertAcked (prepareCreate ("index" ).setSettings (Settings .builder ().put ("index.version.created" , Version .V_5_6_0 .id )));
42
39
// allows for multiple types
43
40
44
41
// works when the type has been dynamically created
45
42
client ().prepareIndex ("index" , "type" , "1" ).setSource ("foo" , 3 ).get ();
46
- GetMappingsResponse mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type" ).get ();
47
- assertMappingsHaveField (mappings , "index" , "type" , "foo" );
43
+ assertBusy (() -> {
44
+ GetMappingsResponse mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type" ).get ();
45
+ assertMappingsHaveField (mappings , "index" , "type" , "foo" );
46
+ });
47
+
48
48
49
49
// works if the type already existed
50
50
client ().prepareIndex ("index" , "type" , "1" ).setSource ("bar" , "baz" ).get ();
51
- mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type" ).get ();
52
- assertMappingsHaveField (mappings , "index" , "type" , "bar" );
51
+ assertBusy (() -> {
52
+ GetMappingsResponse mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type" ).get ();
53
+ assertMappingsHaveField (mappings , "index" , "type" , "bar" );
54
+ });
53
55
54
56
// works if we indexed an empty document
55
57
client ().prepareIndex ("index" , "type2" , "1" ).setSource ().get ();
56
- mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type2" ).get ();
57
- assertTrue (mappings .getMappings ().get ("index" ).toString (), mappings .getMappings ().get ("index" ).containsKey ("type2" ));
58
+ assertBusy (() -> {
59
+ GetMappingsResponse mappings = client ().admin ().indices ().prepareGetMappings ("index" ).setTypes ("type2" ).get ();
60
+ assertNotNull (mappings .getMappings ().get ("index" ));
61
+ assertTrue (mappings .getMappings ().get ("index" ).toString (), mappings .getMappings ().get ("index" ).containsKey ("type2" ));
62
+ });
58
63
}
59
64
60
65
}
0 commit comments