Skip to content

Commit

Permalink
AssertBusy to check mapping in LegacyDynamicMappingIT
Browse files Browse the repository at this point in the history
Dynamic mapping update of an index request no longer requires acks from
all nodes. We need busily to check the mapping update.

Relates #31140.
Closes #37817
  • Loading branch information
dnhatn committed Jan 25, 2019
1 parent d124692 commit f925690
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;

import java.io.IOException;

import static org.elasticsearch.index.mapper.DynamicMappingIT.assertMappingsHaveField;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;

Expand All @@ -36,25 +34,32 @@ protected boolean forbidPrivateIndexSettings() {
return false;
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37817")
public void testMappingsPropagatedToMasterNodeImmediatelyMultiType() throws IOException {
public void testMappingsPropagatedToMasterNodeImmediatelyMultiType() throws Exception {
assertAcked(prepareCreate("index").setSettings(Settings.builder().put("index.version.created", Version.V_5_6_0.id)));
// allows for multiple types

// works when the type has been dynamically created
client().prepareIndex("index", "type", "1").setSource("foo", 3).get();
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get();
assertMappingsHaveField(mappings, "index", "type", "foo");
assertBusy(() -> {
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get();
assertMappingsHaveField(mappings, "index", "type", "foo");
});


// works if the type already existed
client().prepareIndex("index", "type", "1").setSource("bar", "baz").get();
mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get();
assertMappingsHaveField(mappings, "index", "type", "bar");
assertBusy(() -> {
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get();
assertMappingsHaveField(mappings, "index", "type", "bar");
});

// works if we indexed an empty document
client().prepareIndex("index", "type2", "1").setSource().get();
mappings = client().admin().indices().prepareGetMappings("index").setTypes("type2").get();
assertTrue(mappings.getMappings().get("index").toString(), mappings.getMappings().get("index").containsKey("type2"));
assertBusy(() -> {
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type2").get();
assertNotNull(mappings.getMappings().get("index"));
assertTrue(mappings.getMappings().get("index").toString(), mappings.getMappings().get("index").containsKey("type2"));
});
}

}

0 comments on commit f925690

Please sign in to comment.