Skip to content

Commit

Permalink
Adapt timeouts in UpdateMappingIntegrationIT
Browse files Browse the repository at this point in the history
Relates to elastic#37263 and possibly elastic#36916
  • Loading branch information
ywelsch committed Feb 1, 2019
1 parent d83c748 commit 859e2f5
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -25,10 +25,12 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.mapper.MapperService;
Expand Down Expand Up @@ -72,15 +74,19 @@ public void testDynamicUpdates() throws Exception {
.put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE)
).execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
client().admin().cluster().prepareUpdateSettings().setTransientSettings(
Settings.builder().put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMinutes(5)))
.get();

int recCount = randomIntBetween(200, 600);
int recCount = randomIntBetween(20, 200);
List<IndexRequestBuilder> indexRequests = new ArrayList<>();
for (int rec = 0; rec < recCount; rec++) {
String type = "type";
String fieldName = "field_" + type + "_" + rec;
indexRequests.add(client().prepareIndex("test", type, Integer.toString(rec)).setSource(fieldName, "some_value"));
indexRequests.add(client().prepareIndex("test", type, Integer.toString(rec))
.setTimeout(TimeValue.timeValueMinutes(5)).setSource(fieldName, "some_value"));
}
indexRandom(true, indexRequests);
indexRandom(true, false, indexRequests);

logger.info("checking all the documents are there");
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh().execute().actionGet();
Expand All @@ -95,6 +101,9 @@ public void testDynamicUpdates() throws Exception {
String fieldName = "field_" + type + "_" + rec;
assertConcreteMappingsOnAll("test", type, fieldName);
}

client().admin().cluster().prepareUpdateSettings().setTransientSettings(
Settings.builder().putNull(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey())).get();
}

public void testUpdateMappingWithoutType() {
Expand Down Expand Up @@ -224,7 +233,7 @@ public void testUpdateMappingConcurrently() throws Throwable {
JsonXContent.contentBuilder().startObject().startObject(typeName)
.startObject("properties").startObject(fieldName).field("type", "text").endObject().endObject()
.endObject().endObject()
).get();
).setMasterNodeTimeout(TimeValue.timeValueMinutes(5)).get();

assertThat(response.isAcknowledged(), equalTo(true));
GetMappingsResponse getMappingResponse = client2.admin().indices().prepareGetMappings(indexName).get();
Expand Down

0 comments on commit 859e2f5

Please sign in to comment.