[Test] testLargeClusterStatePublishing - bound max shard no to number of nodes and set replica count to 0

ensureGreen sometimes times out due to too many shards and GC kicking in
This commit is contained in:
Boaz Leskes 2014-08-27 08:34:19 +02:00
parent 1804f864d5
commit 8a94044b69
1 changed files with 7 additions and 2 deletions

View File

@ -19,10 +19,10 @@
package org.elasticsearch.cluster;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.ByteSizeValue;
@ -142,8 +142,13 @@ public class SimpleClusterStateTests extends ElasticsearchIntegrationTest {
}
logger.info("number of fields [{}], estimated bytes [{}]", numberOfFields, estimatedBytesSize);
mapping.endObject().endObject().endObject();
int numberOfShards = scaledRandomIntBetween(1, cluster().numDataNodes());
// if the create index is ack'ed, then all nodes have successfully processed the cluster state
assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", mapping).setTimeout("60s").get());
assertAcked(client().admin().indices().prepareCreate("test")
.setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.addMapping("type", mapping)
.setTimeout("60s").get());
ensureGreen(); // wait for green state, so its both green, and there are no more pending events
MappingMetaData masterMappingMetaData = client().admin().indices().prepareGetMappings("test").setTypes("type").get().getMappings().get("test").get("type");
for (Client client : clients()) {