From 6eb655380c012d8c0917e6c8cb17be9be7190763 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 22 Apr 2014 10:48:15 +0200 Subject: [PATCH] [TEST] Randomized number of replicas between 0 and the number of data nodes - 1 (rather than just between 0 and 1) Closes #5896 --- .../java/org/elasticsearch/test/ImmutableTestCluster.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java b/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java index caa825bf038..41d27f3e89e 100644 --- a/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java +++ b/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java @@ -20,6 +20,7 @@ package org.elasticsearch.test; import com.carrotsearch.hppc.ObjectArrayList; +import com.carrotsearch.randomizedtesting.RandomizedTest; import com.carrotsearch.randomizedtesting.generators.RandomInts; import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.apache.lucene.store.StoreRateLimiting; @@ -156,7 +157,7 @@ public abstract class ImmutableTestCluster implements Iterable { // which is the case in the CloseIndexDisableCloseAllTests if ("_all".equals(indices[0])) { ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().execute().actionGet(); - ObjectArrayList concreteIndices = new ObjectArrayList(); + ObjectArrayList concreteIndices = new ObjectArrayList<>(); for (IndexMetaData indexMetaData : clusterStateResponse.getState().metaData()) { concreteIndices.add(indexMetaData.getIndex()); } @@ -234,8 +235,8 @@ public abstract class ImmutableTestCluster implements Iterable { setRandomSettings(random, ImmutableSettings.builder()) .put(SETTING_INDEX_SEED, random.nextLong()) .put(SETTING_NUMBER_OF_SHARDS, RandomInts.randomIntBetween(random, DEFAULT_MIN_NUM_SHARDS, DEFAULT_MAX_NUM_SHARDS)) - .put(SETTING_NUMBER_OF_REPLICAS, RandomInts.randomIntBetween(random, 0, 1)); - + //use either 0 or 1 replica, yet a higher amount when possible, but only rarely + .put(SETTING_NUMBER_OF_REPLICAS, RandomInts.randomIntBetween(random, 0, random.nextInt(10) > 0 ? 1 : dataNodes() - 1)); client().admin().indices().preparePutTemplate("random_index_template") .setTemplate("*") .setOrder(0)