Dry up more of index setting creation in tests (#95602)

Quick follow-up to #95569 of spots that I could automatically identify
and refactor, saving another 1.5k LoC in tests.
This commit is contained in:
Armin Braun 2023-04-27 17:11:48 +02:00 committed by GitHub
parent e752135f44
commit 4e69fa102f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
140 changed files with 406 additions and 1890 deletions

View file

@ -369,13 +369,7 @@ public class DatabaseNodeServiceTests extends ESTestCase {
: GeoIpDownloader.DATABASES_INDEX; : GeoIpDownloader.DATABASES_INDEX;
Index index = new Index(indexName, UUID.randomUUID().toString()); Index index = new Index(indexName, UUID.randomUUID().toString());
IndexMetadata.Builder idxMeta = IndexMetadata.builder(index.getName()) IndexMetadata.Builder idxMeta = IndexMetadata.builder(index.getName())
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put("index.uuid", index.getUUID()));
Settings.builder()
.put("index.version.created", Version.CURRENT)
.put("index.uuid", index.getUUID())
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
);
if (aliasGeoipDatabase) { if (aliasGeoipDatabase) {
idxMeta.putAlias(AliasMetadata.builder(GeoIpDownloader.DATABASES_INDEX)); idxMeta.putAlias(AliasMetadata.builder(GeoIpDownloader.DATABASES_INDEX));
} }

View file

@ -195,12 +195,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
} }
static Settings createSettings(Version creationVersion, int flagSettingValue) { static Settings createSettings(Version creationVersion, int flagSettingValue) {
return Settings.builder() return indexSettings(creationVersion, 1, 0).put(FlAG_SETTING_KEY, flagSettingValue).build();
.put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1)
.put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0)
.put(FlAG_SETTING_KEY, flagSettingValue)
.put("index.version.created", creationVersion)
.build();
} }
static String createMapping(boolean descriptorManaged, boolean descriptorInternal) { static String createMapping(boolean descriptorManaged, boolean descriptorInternal) {

View file

@ -179,13 +179,7 @@ public class ReindexSourceTargetValidationTests extends ESTestCase {
} }
private static IndexMetadata index(String name, @Nullable Boolean writeIndex, String... aliases) { private static IndexMetadata index(String name, @Nullable Boolean writeIndex, String... aliases) {
IndexMetadata.Builder builder = IndexMetadata.builder(name) IndexMetadata.Builder builder = IndexMetadata.builder(name).settings(indexSettings(Version.CURRENT, 1, 1));
.settings(
Settings.builder()
.put("index.version.created", Version.CURRENT.id)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
);
for (String alias : aliases) { for (String alias : aliases) {
builder.putAlias(AliasMetadata.builder(alias).writeIndex(writeIndex).build()); builder.putAlias(AliasMetadata.builder(alias).writeIndex(writeIndex).build());
} }

View file

@ -171,11 +171,7 @@ public class RetryTests extends ESIntegTestCase {
.put("node.attr.color", "blue") .put("node.attr.color", "blue")
.build(); .build();
final String node = internalCluster().startDataOnlyNode(nodeSettings); final String node = internalCluster().startDataOnlyNode(nodeSettings);
final Settings indexSettings = Settings.builder() final Settings indexSettings = indexSettings(1, 0).put("index.routing.allocation.include.color", "blue").build();
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("index.routing.allocation.include.color", "blue")
.build();
// Create the source index on the node with small thread pools so we can block them. // Create the source index on the node with small thread pools so we can block them.
client().admin().indices().prepareCreate("source").setSettings(indexSettings).execute().actionGet(); client().admin().indices().prepareCreate("source").setSettings(indexSettings).execute().actionGet();

View file

@ -174,7 +174,7 @@ public class CCSDuelIT extends ESRestTestCase {
assertTrue(response.isAcknowledged()); assertTrue(response.isAcknowledged());
int numShards = randomIntBetween(1, 5); int numShards = randomIntBetween(1, 5);
Settings settings = Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", 0).build(); Settings settings = indexSettings(numShards, 0).build();
String mapping = """ String mapping = """
{ {
"properties": { "properties": {

View file

@ -1213,12 +1213,7 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("idx") .prepareCreate("idx")
.setSettings( .setSettings(indexSettings(numPrimaries, numReplicas).put(settings))
Settings.builder()
.put("index.number_of_shards", numPrimaries)
.put("index.number_of_replicas", numReplicas)
.put(settings)
)
.setWaitForActiveShards(activeShardCount) .setWaitForActiveShards(activeShardCount)
.get() .get()
); );

View file

@ -105,13 +105,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareResizeIndex("source", "first_shrink") .prepareResizeIndex("source", "first_shrink")
.setSettings( .setSettings(indexSettings(shardSplits[1], 0).putNull("index.blocks.write").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[1])
.putNull("index.blocks.write")
.build()
)
.get() .get()
); );
ensureGreen(); ensureGreen();
@ -139,12 +133,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("first_shrink", "second_shrink") .prepareResizeIndex("first_shrink", "second_shrink")
.setSettings( .setSettings(
Settings.builder() indexSettings(shardSplits[2], 0).putNull("index.blocks.write").putNull("index.routing.allocation.require._name").build()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[2])
.putNull("index.blocks.write")
.putNull("index.routing.allocation.require._name")
.build()
) )
.get() .get()
); );
@ -230,10 +219,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
final long beforeShrinkPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetadata::primaryTerm).max().getAsLong(); final long beforeShrinkPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetadata::primaryTerm).max().getAsLong();
// now merge source into target // now merge source into target
final Settings shrinkSettings = Settings.builder() final Settings shrinkSettings = indexSettings(numberOfTargetShards, 0).build();
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", numberOfTargetShards)
.build();
assertAcked(client().admin().indices().prepareResizeIndex("source", "target").setSettings(shrinkSettings).get()); assertAcked(client().admin().indices().prepareResizeIndex("source", "target").setSettings(shrinkSettings).get());
ensureGreen(TimeValue.timeValueSeconds(120)); ensureGreen(TimeValue.timeValueSeconds(120));
@ -476,13 +462,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
() -> client().admin() () -> client().admin()
.indices() .indices()
.prepareResizeIndex("source", "target") .prepareResizeIndex("source", "target")
.setSettings( .setSettings(indexSettings(2, 0).put("index.sort.field", "foo").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2")
.put("index.sort.field", "foo")
.build()
)
.get() .get()
); );
assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index")); assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index"));
@ -492,13 +472,7 @@ public class ShrinkIndexIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareResizeIndex("source", "target") .prepareResizeIndex("source", "target")
.setSettings( .setSettings(indexSettings(2, 0).putNull("index.blocks.write").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2")
.putNull("index.blocks.write")
.build()
)
.get() .get()
); );
ensureGreen(); ensureGreen();
@ -620,11 +594,9 @@ public class ShrinkIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("original", "shrunk") .prepareResizeIndex("original", "shrunk")
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1).putNull(
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) ).build()
.putNull(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey())
.build()
) )
.setResizeType(ResizeType.SHRINK) .setResizeType(ResizeType.SHRINK)
.get() .get()
@ -644,11 +616,9 @@ public class ShrinkIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("shrunk", "splitagain") .prepareResizeIndex("shrunk", "splitagain")
.setSettings( .setSettings(
Settings.builder() indexSettings(shardCount, 0).putNull(
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, shardCount) ).build()
.putNull(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey())
.build()
) )
.setResizeType(ResizeType.SPLIT) .setResizeType(ResizeType.SPLIT)
); );

View file

@ -178,10 +178,7 @@ public class SplitIndexIT extends ESIntegTestCase {
ensureYellow(); ensureYellow();
updateIndexSettings(Settings.builder().put("index.blocks.write", true), "source"); updateIndexSettings(Settings.builder().put("index.blocks.write", true), "source");
ensureGreen(); ensureGreen();
Settings.Builder firstSplitSettingsBuilder = Settings.builder() Settings.Builder firstSplitSettingsBuilder = indexSettings(firstSplitShards, 0).putNull("index.blocks.write");
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", firstSplitShards)
.putNull("index.blocks.write");
if (sourceShards == 1 && useRoutingPartition == false && randomBoolean()) { // try to set it if we have a source index with 1 shard if (sourceShards == 1 && useRoutingPartition == false && randomBoolean()) { // try to set it if we have a source index with 1 shard
firstSplitSettingsBuilder.put("index.number_of_routing_shards", secondSplitShards); firstSplitSettingsBuilder.put("index.number_of_routing_shards", secondSplitShards);
} }
@ -220,13 +217,7 @@ public class SplitIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("first_split", "second_split") .prepareResizeIndex("first_split", "second_split")
.setResizeType(ResizeType.SPLIT) .setResizeType(ResizeType.SPLIT)
.setSettings( .setSettings(indexSettings(secondSplitShards, 0).putNull("index.blocks.write").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", secondSplitShards)
.putNull("index.blocks.write")
.build()
)
.get() .get()
); );
ensureGreen(); ensureGreen();
@ -339,11 +330,7 @@ public class SplitIndexIT extends ESIntegTestCase {
final long beforeSplitPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetadata::primaryTerm).max().getAsLong(); final long beforeSplitPrimaryTerm = IntStream.range(0, numberOfShards).mapToLong(indexMetadata::primaryTerm).max().getAsLong();
// now split source into target // now split source into target
final Settings splitSettings = Settings.builder() final Settings splitSettings = indexSettings(numberOfTargetShards, 0).putNull("index.blocks.write").build();
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", numberOfTargetShards)
.putNull("index.blocks.write")
.build();
assertAcked( assertAcked(
client().admin() client().admin()
.indices() .indices()
@ -398,13 +385,7 @@ public class SplitIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("source", "target") .prepareResizeIndex("source", "target")
.setResizeType(ResizeType.SPLIT) .setResizeType(ResizeType.SPLIT)
.setSettings( .setSettings(indexSettings(2, createWithReplicas ? 1 : 0).putNull("index.blocks.write").build())
Settings.builder()
.put("index.number_of_replicas", createWithReplicas ? 1 : 0)
.put("index.number_of_shards", 2)
.putNull("index.blocks.write")
.build()
)
.get() .get()
); );
ensureGreen(); ensureGreen();
@ -508,13 +489,7 @@ public class SplitIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("source", "target") .prepareResizeIndex("source", "target")
.setResizeType(ResizeType.SPLIT) .setResizeType(ResizeType.SPLIT)
.setSettings( .setSettings(indexSettings(4, 0).put("index.sort.field", "foo").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", 4)
.put("index.sort.field", "foo")
.build()
)
.get() .get()
); );
assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index")); assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index"));
@ -525,13 +500,7 @@ public class SplitIndexIT extends ESIntegTestCase {
.indices() .indices()
.prepareResizeIndex("source", "target") .prepareResizeIndex("source", "target")
.setResizeType(ResizeType.SPLIT) .setResizeType(ResizeType.SPLIT)
.setSettings( .setSettings(indexSettings(4, 0).putNull("index.blocks.write").build())
Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", 4)
.putNull("index.blocks.write")
.build()
)
.get() .get()
); );
ensureGreen(); ensureGreen();

View file

@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Strings; import org.elasticsearch.core.Strings;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
@ -30,11 +29,7 @@ import static org.hamcrest.Matchers.startsWith;
*/ */
public class WaitActiveShardCountIT extends ESIntegTestCase { public class WaitActiveShardCountIT extends ESIntegTestCase {
public void testReplicationWaitsForActiveShardCount() throws Exception { public void testReplicationWaitsForActiveShardCount() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate( CreateIndexResponse createIndexResponse = prepareCreate("test", 1, indexSettings(1, 2)).get();
"test",
1,
Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 2)
).get();
assertAcked(createIndexResponse); assertAcked(createIndexResponse);

View file

@ -27,7 +27,6 @@ import org.elasticsearch.cluster.metadata.IndexAbstraction;
import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
@ -704,15 +703,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
public void testWaitForAliasCreationSingleShard() throws Exception { public void testWaitForAliasCreationSingleShard() throws Exception {
logger.info("--> creating index [test]"); logger.info("--> creating index [test]");
assertAcked( assertAcked(admin().indices().create(new CreateIndexRequest("test").settings(indexSettings(1, 0))).get());
admin().indices()
.create(
new CreateIndexRequest("test").settings(
Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 1)
)
)
.get()
);
ensureGreen(); ensureGreen();

View file

@ -125,14 +125,7 @@ public class PrevalidateNodeRemovalIT extends ESIntegTestCase {
String node1 = internalCluster().startDataOnlyNode(); String node1 = internalCluster().startDataOnlyNode();
String node2 = internalCluster().startDataOnlyNode(); String node2 = internalCluster().startDataOnlyNode();
String indexName = "test-idx"; String indexName = "test-idx";
createIndex( createIndex(indexName, indexSettings(1, 0).put("index.routing.allocation.require._name", node1).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.require._name", node1)
.build()
);
ensureGreen(indexName); ensureGreen(indexName);
// Prevent node1 from removing its local index shard copies upon removal, by blocking // Prevent node1 from removing its local index shard copies upon removal, by blocking
// its ACTION_SHARD_EXISTS requests since after a relocation, the source first waits // its ACTION_SHARD_EXISTS requests since after a relocation, the source first waits
@ -181,14 +174,7 @@ public class PrevalidateNodeRemovalIT extends ESIntegTestCase {
String node1 = internalCluster().startDataOnlyNode(); String node1 = internalCluster().startDataOnlyNode();
String node2 = internalCluster().startDataOnlyNode(); String node2 = internalCluster().startDataOnlyNode();
String indexName = "test-index"; String indexName = "test-index";
createIndex( createIndex(indexName, indexSettings(1, 0).put("index.routing.allocation.require._name", node1).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put("index.routing.allocation.require._name", node1)
.build()
);
ensureGreen(indexName); ensureGreen(indexName);
// make it red! // make it red!
internalCluster().stopNode(node1); internalCluster().stopNode(node1);

View file

@ -231,10 +231,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
final String indexName = "test" + i; final String indexName = "test" + i;
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(5, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), randomIntBetween(250, 1000) + "ms")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), randomIntBetween(250, 1000) + "ms")
.build() .build()
); );
if (randomBoolean()) { if (randomBoolean()) {

View file

@ -73,9 +73,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
public void testAssignmentWithJustAddedNodes() { public void testAssignmentWithJustAddedNodes() {
internalCluster().startNode(Settings.builder().put(TransportSettings.CONNECT_TIMEOUT.getKey(), "1s")); internalCluster().startNode(Settings.builder().put(TransportSettings.CONNECT_TIMEOUT.getKey(), "1s"));
final String index = "index"; final String index = "index";
prepareCreate(index).setSettings( prepareCreate(index).setSettings(indexSettings(1, 0)).get();
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
).get();
ensureGreen(index); ensureGreen(index);
// close to have some unassigned started shards shards.. // close to have some unassigned started shards shards..
@ -243,14 +241,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
assertNotNull(otherNode); assertNotNull(otherNode);
// Don't allocate the shard on the master node // Don't allocate the shard on the master node
assertAcked( assertAcked(prepareCreate("index").setSettings(indexSettings(1, 0).put("index.routing.allocation.exclude._name", master)).get());
prepareCreate("index").setSettings(
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.exclude._name", master)
).get()
);
ensureGreen(); ensureGreen();
// Check routing tables // Check routing tables
@ -333,12 +324,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
// Force allocation of the primary on the master node by first only allocating on the master // Force allocation of the primary on the master node by first only allocating on the master
// and then allowing all nodes so that the replica gets allocated on the other node // and then allowing all nodes so that the replica gets allocated on the other node
prepareCreate("index").setSettings( prepareCreate("index").setSettings(indexSettings(1, 1).put("index.routing.allocation.include._name", master)).get();
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put("index.routing.allocation.include._name", master)
).get();
updateIndexSettings(Settings.builder().put("index.routing.allocation.include._name", ""), "index"); updateIndexSettings(Settings.builder().put("index.routing.allocation.include._name", ""), "index");
ensureGreen(); ensureGreen();

View file

@ -10,7 +10,6 @@ package org.elasticsearch.cluster.routing;
import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
@ -29,12 +28,8 @@ public class DelayedAllocationIT extends ESIntegTestCase {
*/ */
public void testNoDelayedTimeout() throws Exception { public void testNoDelayedTimeout() throws Exception {
internalCluster().startNodes(3); internalCluster().startNodes(3);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0))
Settings.builder() .get();
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0)
).get();
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
internalCluster().stopNode(findNodeWithShard()); internalCluster().stopNode(findNodeWithShard());
@ -51,10 +46,7 @@ public class DelayedAllocationIT extends ESIntegTestCase {
public void testDelayedAllocationNodeLeavesAndComesBack() throws Exception { public void testDelayedAllocationNodeLeavesAndComesBack() throws Exception {
internalCluster().startNodes(3); internalCluster().startNodes(3);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
).get(); ).get();
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
@ -79,10 +71,7 @@ public class DelayedAllocationIT extends ESIntegTestCase {
public void testDelayedAllocationTimesOut() throws Exception { public void testDelayedAllocationTimesOut() throws Exception {
internalCluster().startNodes(3); internalCluster().startNodes(3);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMillis(100))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMillis(100))
).get(); ).get();
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
@ -110,10 +99,7 @@ public class DelayedAllocationIT extends ESIntegTestCase {
public void testDelayedAllocationChangeWithSettingTo100ms() throws Exception { public void testDelayedAllocationChangeWithSettingTo100ms() throws Exception {
internalCluster().startNodes(3); internalCluster().startNodes(3);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
).get(); ).get();
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
@ -142,10 +128,7 @@ public class DelayedAllocationIT extends ESIntegTestCase {
public void testDelayedAllocationChangeWithSettingTo0() throws Exception { public void testDelayedAllocationChangeWithSettingTo0() throws Exception {
internalCluster().startNodes(3); internalCluster().startNodes(3);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueHours(1))
).get(); ).get();
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();

View file

@ -55,8 +55,6 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
@ -92,12 +90,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setSettings( .setSettings(indexSettings(1, 1).put("index.global_checkpoint_sync.interval", "1s"))
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put("index.global_checkpoint_sync.interval", "1s")
)
.get() .get()
); );
ensureGreen(); ensureGreen();
@ -422,12 +415,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setWaitForActiveShards(ActiveShardCount.NONE) .setWaitForActiveShards(ActiveShardCount.NONE)
.setSettings( .setSettings(indexSettings(1, 0).put("index.routing.allocation.exclude._name", node))
Settings.builder()
.put("index.routing.allocation.exclude._name", node)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
)
.get(); .get();
assertThat( assertThat(
@ -446,12 +434,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setSettings( .setSettings(indexSettings(1, 1).put("index.unassigned.node_left.delayed_timeout", "0ms"))
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put("index.unassigned.node_left.delayed_timeout", "0ms")
)
.get() .get()
); );
String replicaNode = internalCluster().startDataOnlyNode(Settings.EMPTY); String replicaNode = internalCluster().startDataOnlyNode(Settings.EMPTY);
@ -486,12 +469,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setSettings( .setSettings(indexSettings(1, 1).put("index.unassigned.node_left.delayed_timeout", "0ms"))
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put("index.unassigned.node_left.delayed_timeout", "0ms")
)
.get() .get()
); );
String replicaNode = internalCluster().startDataOnlyNode(Settings.EMPTY); String replicaNode = internalCluster().startDataOnlyNode(Settings.EMPTY);
@ -580,12 +558,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
String master = internalCluster().startMasterOnlyNode(Settings.EMPTY); String master = internalCluster().startMasterOnlyNode(Settings.EMPTY);
final int numberOfReplicas = between(2, 3); final int numberOfReplicas = between(2, 3);
final String oldPrimary = internalCluster().startDataOnlyNode(); final String oldPrimary = internalCluster().startDataOnlyNode();
assertAcked( assertAcked(prepareCreate("test", indexSettings(1, numberOfReplicas)));
prepareCreate(
"test",
Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas)
)
);
final ShardId shardId = new ShardId(clusterService().state().metadata().index("test").getIndex(), 0); final ShardId shardId = new ShardId(clusterService().state().metadata().index("test").getIndex(), 0);
final Set<String> replicaNodes = new HashSet<>(internalCluster().startDataOnlyNodes(numberOfReplicas)); final Set<String> replicaNodes = new HashSet<>(internalCluster().startDataOnlyNodes(numberOfReplicas));
ensureGreen(); ensureGreen();

View file

@ -70,10 +70,7 @@ public class RemoveReplicaPriorityIT extends ESIntegTestCase {
createIndex( createIndex(
INDEX_NAME, INDEX_NAME,
Settings.builder() indexSettings(1, 3).put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_PREFIX + "._id", dataNodeIdFilter)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 3)
.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_PREFIX + "._id", dataNodeIdFilter)
.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._id", excludedDataNodeId) .put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._id", excludedDataNodeId)
.build() .build()
); );

View file

@ -235,10 +235,7 @@ public class ShardRoutingRoleIT extends ESIntegTestCase {
Settings getIndexSettings() { Settings getIndexSettings() {
logger.info("--> numShards={}, numReplicas={}", numShards, numReplicas); logger.info("--> numShards={}, numReplicas={}", numShards, numReplicas);
return Settings.builder() return indexSettings(numShards, numReplicas).build();
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicas)
.build();
} }
} }

View file

@ -50,10 +50,7 @@ public class DiskThresholdMonitorIT extends DiskUsageIntegTestCase {
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(1, 0).put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeName) .put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeName)
.build() .build()
); );
@ -110,10 +107,7 @@ public class DiskThresholdMonitorIT extends DiskUsageIntegTestCase {
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(1, 0).put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeName) .put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(), dataNodeName)
.build() .build()
); );

View file

@ -10,7 +10,6 @@ package org.elasticsearch.cluster.routing.allocation;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.IndicesService;
@ -22,9 +21,7 @@ public class ShardStateIT extends ESIntegTestCase {
public void testPrimaryFailureIncreasesTerm() throws Exception { public void testPrimaryFailureIncreasesTerm() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(2); internalCluster().ensureAtLeastNumDataNodes(2);
prepareCreate("test").setSettings( prepareCreate("test").setSettings(indexSettings(2, 1)).get();
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
).get();
ensureGreen(); ensureGreen();
assertPrimaryTerms(1, 1); assertPrimaryTerms(1, 1);

View file

@ -16,7 +16,6 @@ import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterInfoServiceUtils; import org.elasticsearch.cluster.ClusterInfoServiceUtils;
import org.elasticsearch.cluster.DiskUsageIntegTestCase; import org.elasticsearch.cluster.DiskUsageIntegTestCase;
import org.elasticsearch.cluster.InternalClusterInfoService; import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
@ -84,14 +83,7 @@ public class DiskThresholdDeciderIT extends DiskUsageIntegTestCase {
final String dataNode0Id = internalCluster().getInstance(NodeEnvironment.class, dataNodeName).nodeId(); final String dataNode0Id = internalCluster().getInstance(NodeEnvironment.class, dataNodeName).nodeId();
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
createIndex( createIndex(indexName, indexSettings(6, 0).put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms").build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 6)
.put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.build()
);
var smallestShard = createReasonableSizedShards(indexName); var smallestShard = createReasonableSizedShards(indexName);
// reduce disk size of node 0 so that no shards fit below the high watermark, forcing all shards onto the other data node // reduce disk size of node 0 so that no shards fit below the high watermark, forcing all shards onto the other data node
@ -127,14 +119,7 @@ public class DiskThresholdDeciderIT extends DiskUsageIntegTestCase {
final String dataNode0Id = internalCluster().getInstance(NodeEnvironment.class, dataNodeName).nodeId(); final String dataNode0Id = internalCluster().getInstance(NodeEnvironment.class, dataNodeName).nodeId();
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
createIndex( createIndex(indexName, indexSettings(6, 0).put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms").build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 6)
.put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms")
.build()
);
var smallestShard = createReasonableSizedShards(indexName); var smallestShard = createReasonableSizedShards(indexName);
final CreateSnapshotResponse createSnapshotResponse = client().admin() final CreateSnapshotResponse createSnapshotResponse = client().admin()

View file

@ -8,7 +8,6 @@
package org.elasticsearch.cluster.routing.allocation.decider; package org.elasticsearch.cluster.routing.allocation.decider;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
@ -38,16 +37,8 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase {
// we test with 2 shards since otherwise it's pretty fragile if there are difference in the num or shards such that // we test with 2 shards since otherwise it's pretty fragile if there are difference in the num or shards such that
// all shards are relocated to the second node which is not what we want here. It's solely a test for the settings to take effect // all shards are relocated to the second node which is not what we want here. It's solely a test for the settings to take effect
final int numShards = 2; final int numShards = 2;
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(numShards, 0)));
prepareCreate("test").setSettings( assertAcked(prepareCreate("test_1").setSettings(indexSettings(numShards, 0)));
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
)
);
assertAcked(
prepareCreate("test_1").setSettings(
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
)
);
ensureGreen(); ensureGreen();
assertAllShardsOnNodes("test", firstNode); assertAllShardsOnNodes("test", firstNode);
assertAllShardsOnNodes("test_1", firstNode); assertAllShardsOnNodes("test_1", firstNode);

View file

@ -42,12 +42,7 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setSettings( .setSettings(indexSettings(1, 0).put("index.routing.allocation.include.tag", "A"))
Settings.builder()
.put("index.number_of_shards", "1")
.put("index.number_of_replicas", 0)
.put("index.routing.allocation.include.tag", "A")
)
.execute() .execute()
.actionGet(); .actionGet();
ensureGreen(); ensureGreen();
@ -73,12 +68,7 @@ public class ClusterSearchShardsIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate("test") .prepareCreate("test")
.setSettings( .setSettings(indexSettings(4, 0).put("index.routing.allocation.include.tag", "A"))
Settings.builder()
.put("index.number_of_shards", "4")
.put("index.number_of_replicas", 0)
.put("index.routing.allocation.include.tag", "A")
)
.execute() .execute()
.actionGet(); .actionGet();
ensureGreen(); ensureGreen();

View file

@ -126,11 +126,7 @@ public class ClusterShardLimitIT extends ESIntegTestCase {
.preparePutTemplate("should-fail") .preparePutTemplate("should-fail")
.setPatterns(Collections.singletonList("should-fail")) .setPatterns(Collections.singletonList("should-fail"))
.setOrder(1) .setOrder(1)
.setSettings( .setSettings(indexSettings(counts.getFailingIndexShards(), counts.getFailingIndexReplicas()))
Settings.builder()
.put(SETTING_NUMBER_OF_SHARDS, counts.getFailingIndexShards())
.put(SETTING_NUMBER_OF_REPLICAS, counts.getFailingIndexReplicas())
)
.get() .get()
); );
@ -152,10 +148,7 @@ public class ClusterShardLimitIT extends ESIntegTestCase {
int shardsPerNode = firstShardCount - 1; int shardsPerNode = firstShardCount - 1;
setShardsPerNode(shardsPerNode); setShardsPerNode(shardsPerNode);
prepareCreate( prepareCreate("growing-should-fail", indexSettings(firstShardCount, 0)).get();
"growing-should-fail",
Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, firstShardCount).put(SETTING_NUMBER_OF_REPLICAS, 0)
).get();
try { try {
client().admin() client().admin()

View file

@ -279,11 +279,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
public void testRejoinDocumentExistsInAllShardCopies() throws Exception { public void testRejoinDocumentExistsInAllShardCopies() throws Exception {
List<String> nodes = startCluster(3); List<String> nodes = startCluster(3);
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(1, 2)).get());
prepareCreate("test").setSettings(
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2)
).get()
);
ensureGreen("test"); ensureGreen("test");
nodes = new ArrayList<>(nodes); nodes = new ArrayList<>(nodes);
@ -329,11 +325,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
String masterNode = internalCluster().getMasterName(); String masterNode = internalCluster().getMasterName();
List<String> nonMasterNodes = nodes.stream().filter(node -> node.equals(masterNode) == false).toList(); List<String> nonMasterNodes = nodes.stream().filter(node -> node.equals(masterNode) == false).toList();
String nonMasterNode = randomFrom(nonMasterNodes); String nonMasterNode = randomFrom(nonMasterNodes);
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(3, 2)));
prepareCreate("test").setSettings(
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 3).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2)
)
);
ensureGreen(); ensureGreen();
String nonMasterNodeId = internalCluster().clusterService(nonMasterNode).localNode().getId(); String nonMasterNodeId = internalCluster().clusterService(nonMasterNode).localNode().getId();

View file

@ -14,7 +14,6 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.coordination.NoMasterBlockService; import org.elasticsearch.cluster.coordination.NoMasterBlockService;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Strings; import org.elasticsearch.core.Strings;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
@ -87,13 +86,7 @@ public class MasterDisruptionIT extends AbstractDisruptionTestCase {
public void testIsolateMasterAndVerifyClusterStateConsensus() throws Exception { public void testIsolateMasterAndVerifyClusterStateConsensus() throws Exception {
final List<String> nodes = startCluster(3); final List<String> nodes = startCluster(3);
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(1 + randomInt(2), randomInt(2))));
prepareCreate("test").setSettings(
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1 + randomInt(2))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomInt(2))
)
);
ensureGreen(); ensureGreen();
String isolatedNode = internalCluster().getMasterName(); String isolatedNode = internalCluster().getMasterName();
@ -164,11 +157,7 @@ public class MasterDisruptionIT extends AbstractDisruptionTestCase {
internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey()).build()); internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey()).build());
// Makes sure that the get request can be executed on each node locally: // Makes sure that the get request can be executed on each node locally:
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(1, 2)));
prepareCreate("test").setSettings(
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2)
)
);
// Everything is stable now, it is now time to simulate evil... // Everything is stable now, it is now time to simulate evil...
// but first make sure we have no initializing shards and all is green // but first make sure we have no initializing shards and all is green

View file

@ -18,8 +18,6 @@ import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.support.replication.ReplicationResponse; import org.elasticsearch.action.support.replication.ReplicationResponse;
import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.XContentType;
@ -96,11 +94,9 @@ public class ShardInfoIT extends ESIntegTestCase {
logger.info("Number of copies: {}", numCopies); logger.info("Number of copies: {}", numCopies);
assertAcked( assertAcked(
prepareCreate("idx").setSettings( prepareCreate("idx").setSettings(indexSettings(numberOfPrimaryShards, numCopies - 1))
Settings.builder() .setMapping("_routing", "required=" + routingRequired)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfPrimaryShards) .get()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numCopies - 1)
).setMapping("_routing", "required=" + routingRequired).get()
); );
for (int i = 0; i < numberOfPrimaryShards; i++) { for (int i = 0; i < numberOfPrimaryShards; i++) {
ensureActiveShardCopies(i, numNodes); ensureActiveShardCopies(i, numNodes);

View file

@ -58,7 +58,6 @@ import java.util.Set;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.gateway.GatewayService.RECOVER_AFTER_DATA_NODES_SETTING; import static org.elasticsearch.gateway.GatewayService.RECOVER_AFTER_DATA_NODES_SETTING;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@ -194,11 +193,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
); );
// note: default replica settings are tied to #data nodes-1 which is 0 here. We can do with 1 in this test. // note: default replica settings are tied to #data nodes-1 which is 0 here. We can do with 1 in this test.
int numberOfShards = numberOfShards(); int numberOfShards = numberOfShards();
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(numberOfShards(), randomIntBetween(0, 1))).setMapping(mapping));
prepareCreate("test").setSettings(
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards()).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1))
).setMapping(mapping)
);
int value1Docs; int value1Docs;
int value2Docs; int value2Docs;
@ -698,14 +693,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
3, 3,
Settings.builder().put(ElectionSchedulerFactory.ELECTION_INITIAL_TIMEOUT_SETTING.getKey(), "2ms").build() Settings.builder().put(ElectionSchedulerFactory.ELECTION_INITIAL_TIMEOUT_SETTING.getKey(), "2ms").build()
); );
createIndex( createIndex("test", indexSettings(1, 0).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms").build());
"test",
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms")
.build()
);
ensureGreen("test"); ensureGreen("test");
internalCluster().fullRestart(); internalCluster().fullRestart();
ensureGreen("test"); ensureGreen("test");

View file

@ -9,7 +9,6 @@
package org.elasticsearch.gateway; package org.elasticsearch.gateway;
import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.RoutingNodesHelper; import org.elasticsearch.cluster.routing.RoutingNodesHelper;
import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.UnassignedInfo;
@ -80,10 +79,7 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1).put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 1.0f)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 1.0f)
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms")
@ -154,10 +150,7 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1).put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 0.1f)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 0.1f)
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms")
@ -248,10 +241,10 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, numOfReplicas).put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(),
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), randomIntBetween(10, 100) + "kb") randomIntBetween(10, 100) + "kb"
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) )
.put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 0.5) .put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 0.5)
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
@ -295,10 +288,10 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1).put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(),
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), randomIntBetween(10, 100) + "kb") randomIntBetween(10, 100) + "kb"
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) )
.put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 3.0) .put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 3.0)
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "0ms") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "0ms")
@ -361,10 +354,7 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 0).put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
) )
); );
@ -417,10 +407,7 @@ public class ReplicaShardAllocatorIT extends ESIntegTestCase {
internalCluster().ensureAtLeastNumDataNodes(1); internalCluster().ensureAtLeastNumDataNodes(1);
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(1, 0).put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.build() .build()
); );

View file

@ -10,7 +10,6 @@ package org.elasticsearch.gateway;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
@ -159,10 +158,9 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) // expire PRRLs quickly
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) .put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), "1ms")
.put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), "1ms") // expire PRRLs quickly
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1ms")
@ -228,10 +226,10 @@ public class ReplicaShardAllocatorSyncIdIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, numOfReplicas).put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(),
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) randomIntBetween(10, 100) + "kb"
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), randomIntBetween(10, 100) + "kb") )
.put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), "1ms") // expire PRRLs quickly .put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), "1ms") // expire PRRLs quickly
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")

View file

@ -23,8 +23,6 @@ import org.junit.Before;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.node.DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE; import static org.elasticsearch.cluster.node.DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE;
import static org.elasticsearch.indices.ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE; import static org.elasticsearch.indices.ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
@ -86,7 +84,7 @@ public class ShardsCapacityHealthIndicatorServiceIT extends ESIntegTestCase {
} }
private void createIndex(int shards, int replicas) { private void createIndex(int shards, int replicas) {
createIndex(INDEX_NAME, Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shards).put(SETTING_NUMBER_OF_REPLICAS, replicas).build()); createIndex(INDEX_NAME, indexSettings(shards, replicas).build());
} }
private HealthIndicatorResult fetchShardsCapacityIndicatorResult(InternalTestCluster internalCluster) throws Exception { private HealthIndicatorResult fetchShardsCapacityIndicatorResult(InternalTestCluster internalCluster) throws Exception {

View file

@ -15,7 +15,6 @@ import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.bulk.TransportShardBulkAction; import org.elasticsearch.action.bulk.TransportShardBulkAction;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
@ -72,12 +71,7 @@ public class IndexingPressureIT extends ESIntegTestCase {
} }
public void testWriteIndexingPressureMetricsAreIncremented() throws Exception { public void testWriteIndexingPressureMetricsAreIncremented() throws Exception {
assertAcked( assertAcked(prepareCreate(INDEX_NAME, indexSettings(1, 1)));
prepareCreate(
INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
)
);
ensureGreen(INDEX_NAME); ensureGreen(INDEX_NAME);
Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames(); Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames();
@ -256,12 +250,7 @@ public class IndexingPressureIT extends ESIntegTestCase {
Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), (long) (bulkShardRequestSize * 1.5) + "B").build() Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), (long) (bulkShardRequestSize * 1.5) + "B").build()
); );
assertAcked( assertAcked(prepareCreate(INDEX_NAME, indexSettings(1, 1)));
prepareCreate(
INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
)
);
ensureGreen(INDEX_NAME); ensureGreen(INDEX_NAME);
Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames(); Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames();
@ -324,12 +313,7 @@ public class IndexingPressureIT extends ESIntegTestCase {
Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), (long) (bulkShardRequestSize * 1.5) + "B").build() Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), (long) (bulkShardRequestSize * 1.5) + "B").build()
); );
assertAcked( assertAcked(prepareCreate(INDEX_NAME, indexSettings(1, 1)));
prepareCreate(
INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
)
);
ensureGreen(INDEX_NAME); ensureGreen(INDEX_NAME);
Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames(); Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames();
@ -373,12 +357,7 @@ public class IndexingPressureIT extends ESIntegTestCase {
public void testWritesWillSucceedIfBelowThreshold() throws Exception { public void testWritesWillSucceedIfBelowThreshold() throws Exception {
restartNodesWithSettings(Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "1MB").build()); restartNodesWithSettings(Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "1MB").build());
assertAcked( assertAcked(prepareCreate(INDEX_NAME, indexSettings(1, 1)));
prepareCreate(
INDEX_NAME,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
)
);
ensureGreen(INDEX_NAME); ensureGreen(INDEX_NAME);
Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames(); Tuple<String, String> primaryReplicaNodeNames = getPrimaryReplicaNodeNames();

View file

@ -11,8 +11,6 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.ESIntegTestCase.Scope;
@ -30,14 +28,7 @@ public class InternalEngineMergeIT extends ESIntegTestCase {
public void testMergesHappening() throws Exception { public void testMergesHappening() throws Exception {
final int numOfShards = randomIntBetween(1, 5); final int numOfShards = randomIntBetween(1, 5);
// some settings to keep num segments low // some settings to keep num segments low
assertAcked( assertAcked(prepareCreate("test").setSettings(indexSettings(numOfShards, 0).build()));
prepareCreate("test").setSettings(
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build()
)
);
long id = 0; long id = 0;
final int rounds = scaledRandomIntBetween(50, 300); final int rounds = scaledRandomIntBetween(50, 300);
logger.info("Starting rounds [{}] ", rounds); logger.info("Starting rounds [{}] ", rounds);

View file

@ -95,8 +95,6 @@ import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting; import static org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting;
import static org.elasticsearch.index.shard.IndexShardTestCase.getTranslog; import static org.elasticsearch.index.shard.IndexShardTestCase.getTranslog;
import static org.elasticsearch.index.shard.IndexShardTestCase.recoverFromStore; import static org.elasticsearch.index.shard.IndexShardTestCase.recoverFromStore;
@ -239,12 +237,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
} }
public void testExpectedShardSizeIsPresent() throws InterruptedException { public void testExpectedShardSizeIsPresent() throws InterruptedException {
assertAcked( assertAcked(client().admin().indices().prepareCreate("test").setSettings(indexSettings(1, 0)));
client().admin()
.indices()
.prepareCreate("test")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
);
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
client().prepareIndex("test").setSource("{}", XContentType.JSON).get(); client().prepareIndex("test").setSource("{}", XContentType.JSON).get();
} }

View file

@ -29,7 +29,6 @@ import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.cli.MockTerminal; import org.elasticsearch.cli.MockTerminal;
import org.elasticsearch.cli.ProcessInfo; import org.elasticsearch.cli.ProcessInfo;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.GroupShardsIterator;
@ -107,10 +106,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
final String indexName = "index42"; final String indexName = "index42";
assertAcked( assertAcked(
prepareCreate(indexName).setSettings( prepareCreate(indexName).setSettings(
Settings.builder() indexSettings(1, 0).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(MergePolicyConfig.INDEX_MERGE_ENABLED, false)
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1") .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
.put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) .put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), "checksum") .put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), "checksum")
@ -277,10 +273,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
final String indexName = "test"; final String indexName = "test";
assertAcked( assertAcked(
prepareCreate(indexName).setSettings( prepareCreate(indexName).setSettings(
Settings.builder() indexSettings(1, 1).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
.put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog .put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog
.put("index.routing.allocation.exclude._name", node2) .put("index.routing.allocation.exclude._name", node2)
) )
@ -476,10 +469,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
final String indexName = "test"; final String indexName = "test";
assertAcked( assertAcked(
prepareCreate(indexName).setSettings( prepareCreate(indexName).setSettings(
Settings.builder() indexSettings(1, 1).put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1")
.put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog .put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog
.put("index.routing.allocation.exclude._name", node2) .put("index.routing.allocation.exclude._name", node2)
) )
@ -582,13 +572,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
final List<String> nodeNames = internalCluster().startNodes(numOfNodes, Settings.EMPTY); final List<String> nodeNames = internalCluster().startNodes(numOfNodes, Settings.EMPTY);
final String indexName = "test" + randomInt(100); final String indexName = "test" + randomInt(100);
assertAcked( assertAcked(prepareCreate(indexName).setSettings(indexSettings(1, numOfNodes - 1)));
prepareCreate(indexName).setSettings(
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfNodes - 1)
)
);
flush(indexName); flush(indexName);
ensureGreen(indexName); ensureGreen(indexName);

View file

@ -147,10 +147,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
assertAcked( assertAcked(
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 1).put(MergePolicyConfig.INDEX_MERGE_ENABLED, false)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, "1")
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "1")
.put(MergePolicyConfig.INDEX_MERGE_ENABLED, false)
// no checkindex - we corrupt shards on purpose // no checkindex - we corrupt shards on purpose
.put(MockFSIndexStore.INDEX_CHECK_INDEX_ON_CLOSE_SETTING.getKey(), false) .put(MockFSIndexStore.INDEX_CHECK_INDEX_ON_CLOSE_SETTING.getKey(), false)
// no translog based flush - it might change the .liv / segments.N files // no translog based flush - it might change the .liv / segments.N files
@ -347,10 +344,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
var unluckyNode = dataNodes.get(1); var unluckyNode = dataNodes.get(1);
assertAcked( assertAcked(
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 0).put("index.routing.allocation.include._name", primariesNode.getName())
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "0")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put("index.routing.allocation.include._name", primariesNode.getName())
.put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE) .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
.put("index.allocation.max_retries", Integer.MAX_VALUE) // keep on retrying .put("index.allocation.max_retries", Integer.MAX_VALUE) // keep on retrying
) )
@ -404,9 +398,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
assertAcked( assertAcked(
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(between(1, 4), 0) // don't go crazy here it must recovery fast
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "0")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 4)) // don't go crazy here it must recovery fast
// This does corrupt files on the replica, so we can't check: // This does corrupt files on the replica, so we can't check:
.put(MockFSIndexStore.INDEX_CHECK_INDEX_ON_CLOSE_SETTING.getKey(), false) .put(MockFSIndexStore.INDEX_CHECK_INDEX_ON_CLOSE_SETTING.getKey(), false)
.put("index.routing.allocation.include._name", primariesNode.getName()) .put("index.routing.allocation.include._name", primariesNode.getName())

View file

@ -51,10 +51,7 @@ public class CorruptedTranslogIT extends ESIntegTestCase {
assertAcked( assertAcked(
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 0).put("index.refresh_interval", "-1")
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("index.refresh_interval", "-1")
.put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog .put(MockEngineSupport.DISABLE_FLUSH_ON_CLOSE.getKey(), true) // never flush - always recover from translog
.put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB)) .put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(1, ByteSizeUnit.PB))
) )

View file

@ -17,7 +17,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.search.stats.SearchStats;
import org.elasticsearch.search.suggest.SuggestBuilder; import org.elasticsearch.search.suggest.SuggestBuilder;
import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder; import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder;
@ -27,8 +26,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -52,16 +49,8 @@ public class SuggestStatsIT extends ESIntegTestCase {
final int shardsIdx2 = Math.max(numNodes - shardsIdx1, randomIntBetween(1, 10)); final int shardsIdx2 = Math.max(numNodes - shardsIdx1, randomIntBetween(1, 10));
final int totalShards = shardsIdx1 + shardsIdx2; final int totalShards = shardsIdx1 + shardsIdx2;
assertThat(numNodes, lessThanOrEqualTo(totalShards)); assertThat(numNodes, lessThanOrEqualTo(totalShards));
assertAcked( assertAcked(prepareCreate("test1").setSettings(indexSettings(shardsIdx1, 0)).setMapping("f", "type=text"));
prepareCreate("test1").setSettings( assertAcked(prepareCreate("test2").setSettings(indexSettings(shardsIdx2, 0)).setMapping("f", "type=text"));
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx1).put(SETTING_NUMBER_OF_REPLICAS, 0)
).setMapping("f", "type=text")
);
assertAcked(
prepareCreate("test2").setSettings(
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx2).put(SETTING_NUMBER_OF_REPLICAS, 0)
).setMapping("f", "type=text")
);
assertThat(shardsIdx1 + shardsIdx2, equalTo(numAssignedShards("test1", "test2"))); assertThat(shardsIdx1 + shardsIdx2, equalTo(numAssignedShards("test1", "test2")));
assertThat(numAssignedShards("test1", "test2"), greaterThanOrEqualTo(2)); assertThat(numAssignedShards("test1", "test2"), greaterThanOrEqualTo(2));
ensureGreen(); ensureGreen();

View file

@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.index.cache.request.RequestCacheStats; import org.elasticsearch.index.cache.request.RequestCacheStats;
@ -112,11 +111,8 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
.prepareCreate("index") .prepareCreate("index")
.setMapping("s", "type=date") .setMapping("s", "type=date")
.setSettings( .setSettings(
Settings.builder() indexSettings(5, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5)
.put("index.number_of_routing_shards", 5) .put("index.number_of_routing_shards", 5)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
) )
.get() .get()
); );
@ -182,12 +178,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate("index") .prepareCreate("index")
.setMapping("s", "type=date") .setMapping("s", "type=date")
.setSettings( .setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
Settings.builder()
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.get() .get()
); );
indexRandom( indexRandom(
@ -248,12 +239,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate("index") .prepareCreate("index")
.setMapping("d", "type=date") .setMapping("d", "type=date")
.setSettings( .setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
Settings.builder()
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.get() .get()
); );
indexRandom( indexRandom(
@ -313,11 +299,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
public void testQueryRewriteDatesWithNow() throws Exception { public void testQueryRewriteDatesWithNow() throws Exception {
Client client = client(); Client client = client();
Settings settings = Settings.builder() Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build();
assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get()); assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get());
assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get()); assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get());
assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get()); assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get());
@ -393,11 +375,8 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
public void testCanCache() throws Exception { public void testCanCache() throws Exception {
Client client = client(); Client client = client();
Settings settings = Settings.builder() Settings settings = indexSettings(2, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2)
.put("index.number_of_routing_shards", 2) .put("index.number_of_routing_shards", 2)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get()); assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get());
indexRandom( indexRandom(
@ -493,11 +472,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
public void testCacheWithFilteredAlias() { public void testCacheWithFilteredAlias() {
Client client = client(); Client client = client();
Settings settings = Settings.builder() Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build();
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build();
assertAcked( assertAcked(
client.admin() client.admin()
.indices() .indices()
@ -552,12 +527,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate("index") .prepareCreate("index")
.setMapping("k", "type=keyword") .setMapping("k", "type=keyword")
.setSettings( .setSettings(indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true))
Settings.builder()
.put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.get() .get()
); );
indexRandom(true, client.prepareIndex("index").setSource("k", "hello")); indexRandom(true, client.prepareIndex("index").setSource("k", "hello"));

View file

@ -11,7 +11,6 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.flush.FlushResponse; import org.elasticsearch.action.admin.indices.flush.FlushResponse;
import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.ValidationException;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
@ -122,10 +121,7 @@ public class FlushIT extends ESIntegTestCase {
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(
Settings.builder() indexSettings(1, 1).put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), randomTimeValue(200, 500, "ms"))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), randomTimeValue(200, 500, "ms"))
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), randomTimeValue(50, 200, "ms")) .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), randomTimeValue(50, 200, "ms"))
.put("index.routing.allocation.include._name", String.join(",", dataNodes)) .put("index.routing.allocation.include._name", String.join(",", dataNodes))
.build() .build()

View file

@ -20,7 +20,6 @@ import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.Client;
import org.elasticsearch.client.internal.Requests; import org.elasticsearch.client.internal.Requests;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.breaker.CircuitBreaker;
import org.elasticsearch.common.breaker.CircuitBreakingException; import org.elasticsearch.common.breaker.CircuitBreakingException;
@ -365,10 +364,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
assertAcked( assertAcked(
prepareCreate("index").setSettings( prepareCreate("index").setSettings(
Settings.builder() indexSettings(1, 0).put("index.routing.allocation.include._name", targetNode.getNode().getName())
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put("index.routing.allocation.include._name", targetNode.getNode().getName())
.put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE) .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
) )
); );

View file

@ -347,10 +347,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
logger.info("--> create index on node: {}", nodeA); logger.info("--> create index on node: {}", nodeA);
createIndex( createIndex(
INDEX_NAME, INDEX_NAME,
Settings.builder() indexSettings(1, 1).put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms") .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "100ms")
.build() .build()
); );
@ -801,12 +798,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(indexSettings(1, 2).put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 1.0))
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2)
.put(IndexSettings.FILE_BASED_RECOVERY_THRESHOLD_SETTING.getKey(), 1.0)
)
.get(); .get();
ensureGreen(indexName); ensureGreen(indexName);
@ -920,12 +912,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(indexSettings(1, 0).put("index.routing.allocation.include._name", nodeWithPrimary))
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.include._name", nodeWithPrimary)
)
); );
MockTransportService transport = (MockTransportService) internalCluster().getInstance(TransportService.class, nodeWithPrimary); MockTransportService transport = (MockTransportService) internalCluster().getInstance(TransportService.class, nodeWithPrimary);
CountDownLatch phase1ReadyBlocked = new CountDownLatch(1); CountDownLatch phase1ReadyBlocked = new CountDownLatch(1);
@ -1079,10 +1066,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
String indexName = "test-index"; String indexName = "test-index";
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(1, 1).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h")
.build() .build()
); );
@ -1150,10 +1134,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
String indexName = "test-index"; String indexName = "test-index";
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(1, 1).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h")
.build() .build()
); );
@ -1233,10 +1214,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
internalCluster().ensureAtLeastNumDataNodes(2); internalCluster().ensureAtLeastNumDataNodes(2);
String indexName = "test-index"; String indexName = "test-index";
final Settings.Builder settings = Settings.builder() final Settings.Builder settings = indexSettings(1, 1).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "12h")
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms"); .put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "100ms");
@ -1378,14 +1356,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
internalCluster().ensureAtLeastNumDataNodes(2); internalCluster().ensureAtLeastNumDataNodes(2);
String indexName = "test-index"; String indexName = "test-index";
createIndex( createIndex(indexName, indexSettings(1, 0).put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.build()
);
indexRandom( indexRandom(
randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(),
@ -1462,11 +1433,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase {
final String indexName = "test-index"; final String indexName = "test-index";
createIndex( createIndex(
indexName, indexName,
Settings.builder() indexSettings(randomIntBetween(1, 6), 1).put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "200ms").build()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 6))
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "200ms")
.build()
); );
indexRandom( indexRandom(
randomBoolean(), randomBoolean(),

View file

@ -55,12 +55,7 @@ public class TaskRecoveryIT extends ESIntegTestCase {
client().admin() client().admin()
.indices() .indices()
.prepareCreate(indexName) .prepareCreate(indexName)
.setSettings( .setSettings(indexSettings(1, 0).put("index.routing.allocation.include._name", nodeWithPrimary))
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.include._name", nodeWithPrimary)
)
); );
try { try {
String nodeWithReplica = internalCluster().startDataOnlyNode(); String nodeWithReplica = internalCluster().startDataOnlyNode();

View file

@ -405,14 +405,7 @@ public class CloseIndexIT extends ESIntegTestCase {
final String indexName = "noop-peer-recovery-test"; final String indexName = "noop-peer-recovery-test";
int numberOfReplicas = between(1, 2); int numberOfReplicas = between(1, 2);
internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + between(1, 2)); internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + between(1, 2));
createIndex( createIndex(indexName, indexSettings(1, numberOfReplicas).put("index.routing.rebalance.enable", "none").build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numberOfReplicas)
.put("index.routing.rebalance.enable", "none")
.build()
);
int iterations = between(1, 3); int iterations = between(1, 3);
for (int iter = 0; iter < iterations; iter++) { for (int iter = 0; iter < iterations; iter++) {
indexRandom( indexRandom(
@ -451,14 +444,7 @@ public class CloseIndexIT extends ESIntegTestCase {
2, 2,
clusterService().state().nodes().getDataNodes().values().stream().map(DiscoveryNode::getName).collect(Collectors.toSet()) clusterService().state().nodes().getDataNodes().values().stream().map(DiscoveryNode::getName).collect(Collectors.toSet())
); );
createIndex( createIndex(indexName, indexSettings(1, 1).put("index.routing.allocation.include._name", String.join(",", dataNodes)).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put("index.routing.allocation.include._name", String.join(",", dataNodes))
.build()
);
indexRandom( indexRandom(
randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(),
@ -501,14 +487,7 @@ public class CloseIndexIT extends ESIntegTestCase {
final String indexName = "closed-index"; final String indexName = "closed-index";
final List<String> dataNodes = internalCluster().startDataOnlyNodes(2); final List<String> dataNodes = internalCluster().startDataOnlyNodes(2);
// allocate shard to first data node // allocate shard to first data node
createIndex( createIndex(indexName, indexSettings(1, 0).put("index.routing.allocation.include._name", dataNodes.get(0)).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.include._name", dataNodes.get(0))
.build()
);
indexRandom( indexRandom(
randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(),

View file

@ -12,7 +12,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.RecoverySource; import org.elasticsearch.cluster.routing.RecoverySource;
import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
@ -182,10 +181,7 @@ public class FullRollingRestartIT extends ESIntegTestCase {
* We have a fix for this to wait until we have allocated unallocated shards now so this shouldn't happen. * We have a fix for this to wait until we have allocated unallocated shards now so this shouldn't happen.
*/ */
prepareCreate("test").setSettings( prepareCreate("test").setSettings(
Settings.builder() indexSettings(6, 0).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMinutes(1))
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, "6")
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "0")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMinutes(1))
).get(); ).get();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {

View file

@ -21,7 +21,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
@ -41,8 +40,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
@ -73,10 +70,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
prepareCreate( prepareCreate(
"test", "test",
1, 1,
Settings.builder() indexSettings(numberOfShards, 1).put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
.put(SETTING_NUMBER_OF_SHARDS, numberOfShards)
.put(SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
) )
); );
@ -137,10 +131,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
prepareCreate( prepareCreate(
"test", "test",
1, 1,
Settings.builder() indexSettings(numberOfShards, 1).put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
.put(SETTING_NUMBER_OF_SHARDS, numberOfShards)
.put(SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
) )
); );
@ -198,10 +189,7 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
prepareCreate( prepareCreate(
"test", "test",
2, 2,
Settings.builder() indexSettings(numberOfShards, 1).put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
.put(SETTING_NUMBER_OF_SHARDS, numberOfShards)
.put(SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC)
) )
); );
@ -314,11 +302,10 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
prepareCreate( prepareCreate(
"test", "test",
3, 3,
Settings.builder() indexSettings(numShards, numReplicas).put(
.put(SETTING_NUMBER_OF_SHARDS, numShards) IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(),
.put(SETTING_NUMBER_OF_REPLICAS, numReplicas) Translog.Durability.ASYNC
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.ASYNC) ).put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), randomFrom("100ms", "1s", "5s", "30s", "60s"))
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), randomFrom("100ms", "1s", "5s", "30s", "60s"))
) )
); );

View file

@ -401,10 +401,7 @@ public class RelocationIT extends ESIntegTestCase {
final String p_node = internalCluster().startNode(); final String p_node = internalCluster().startNode();
prepareCreate( prepareCreate(indexName, indexSettings(1, 0)).get();
indexName,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
).get();
internalCluster().startNode(); internalCluster().startNode();
internalCluster().startNode(); internalCluster().startNode();

View file

@ -79,10 +79,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase {
assertAcked( assertAcked(
prepareCreate("test").setMapping("field1", "type=text", "the_id", "type=text") prepareCreate("test").setMapping("field1", "type=text", "the_id", "type=text")
.setSettings( .setSettings(
Settings.builder() indexSettings(numberOfShards(), 0).put("index.routing.allocation.include._name", primariesNode.getNode().getName())
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards())
.put("index.routing.allocation.include._name", primariesNode.getNode().getName())
) )
); // only allocate on the lucky node ); // only allocate on the lucky node

View file

@ -52,8 +52,6 @@ import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.function.Function; import java.util.function.Function;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.search.aggregations.AggregationBuilders.filter; import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
import static org.elasticsearch.search.aggregations.AggregationBuilders.significantTerms; import static org.elasticsearch.search.aggregations.AggregationBuilders.significantTerms;
import static org.elasticsearch.search.aggregations.AggregationBuilders.significantText; import static org.elasticsearch.search.aggregations.AggregationBuilders.significantText;
@ -438,8 +436,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
private void indexEqualTestData() throws ExecutionException, InterruptedException { private void indexEqualTestData() throws ExecutionException, InterruptedException {
assertAcked( assertAcked(
prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("text", "type=text,fielddata=true", "class", "type=keyword")
.setMapping("text", "type=text,fielddata=true", "class", "type=keyword")
); );
createIndex("idx_unmapped"); createIndex("idx_unmapped");

View file

@ -9,7 +9,6 @@ package org.elasticsearch.search.aggregations.bucket;
import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.BucketOrder; import org.elasticsearch.search.aggregations.BucketOrder;
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
@ -22,8 +21,6 @@ import org.elasticsearch.xcontent.XContentType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.search.aggregations.AggregationBuilders.filter; import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
import static org.elasticsearch.search.aggregations.AggregationBuilders.significantTerms; import static org.elasticsearch.search.aggregations.AggregationBuilders.significantTerms;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
@ -46,10 +43,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
} else { } else {
textMappings = "type=text,fielddata=true"; textMappings = "type=text,fielddata=true";
} }
assertAcked( assertAcked(prepareCreate(index).setSettings(indexSettings(1, 0)).setMapping("text", textMappings));
prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
.setMapping("text", textMappings)
);
List<IndexRequestBuilder> indexBuilders = new ArrayList<>(); List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
addTermsDocs("1", 1, 0, indexBuilders);// high score but low doc freq addTermsDocs("1", 1, 0, indexBuilders);// high score but low doc freq
@ -115,10 +109,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
if (termtype.equals("text")) { if (termtype.equals("text")) {
termMappings += ",fielddata=true"; termMappings += ",fielddata=true";
} }
assertAcked( assertAcked(prepareCreate(index).setSettings(indexSettings(1, 0)).setMapping("text", termMappings));
prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
.setMapping("text", termMappings)
);
List<IndexRequestBuilder> indexBuilders = new ArrayList<>(); List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
addTermsDocs("1", 1, indexBuilders);// low doc freq but high score addTermsDocs("1", 1, indexBuilders);// low doc freq but high score

View file

@ -444,18 +444,12 @@ public class FieldCapabilitiesIT extends ESIntegTestCase {
private void populateTimeRangeIndices() throws Exception { private void populateTimeRangeIndices() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(2); internalCluster().ensureAtLeastNumDataNodes(2);
assertAcked( assertAcked(
prepareCreate("log-index-1").setSettings( prepareCreate("log-index-1").setSettings(indexSettings(between(1, 5), 1))
Settings.builder() .setMapping("timestamp", "type=date", "field1", "type=keyword")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
).setMapping("timestamp", "type=date", "field1", "type=keyword")
); );
assertAcked( assertAcked(
prepareCreate("log-index-2").setSettings( prepareCreate("log-index-2").setSettings(indexSettings(between(1, 5), 1))
Settings.builder() .setMapping("timestamp", "type=date", "field1", "type=long")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
).setMapping("timestamp", "type=date", "field1", "type=long")
); );
List<IndexRequestBuilder> reqs = new ArrayList<>(); List<IndexRequestBuilder> reqs = new ArrayList<>();
reqs.add(client().prepareIndex("log-index-1").setSource("timestamp", "2015-07-08")); reqs.add(client().prepareIndex("log-index-1").setSource("timestamp", "2015-07-08"));
@ -510,10 +504,7 @@ public class FieldCapabilitiesIT extends ESIntegTestCase {
public void testNoActiveCopy() throws Exception { public void testNoActiveCopy() throws Exception {
assertAcked( assertAcked(
prepareCreate("log-index-inactive").setSettings( prepareCreate("log-index-inactive").setSettings(
Settings.builder() indexSettings(between(1, 5), 1).put("index.routing.allocation.require._id", "unknown")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put("index.routing.allocation.require._id", "unknown")
).setWaitForActiveShards(ActiveShardCount.NONE).setMapping("timestamp", "type=date", "field1", "type=keyword") ).setWaitForActiveShards(ActiveShardCount.NONE).setMapping("timestamp", "type=date", "field1", "type=keyword")
); );
{ {

View file

@ -33,7 +33,6 @@ import org.elasticsearch.xcontent.XContentFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.lucene.search.function.CombineFunction.REPLACE; import static org.elasticsearch.common.lucene.search.function.CombineFunction.REPLACE;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
@ -773,10 +772,7 @@ public class QueryRescorerIT extends ESIntegTestCase {
// #11277 // #11277
public void testFromSize() throws Exception { public void testFromSize() throws Exception {
Builder settings = Settings.builder(); assertAcked(prepareCreate("test").setSettings(indexSettings(1, 0)));
settings.put(SETTING_NUMBER_OF_SHARDS, 1);
settings.put(SETTING_NUMBER_OF_REPLICAS, 0);
assertAcked(prepareCreate("test").setSettings(settings));
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
client().prepareIndex("test").setId("" + i).setSource("text", "hello world").get(); client().prepareIndex("test").setId("" + i).setSource("text", "hello world").get();
} }

View file

@ -34,7 +34,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery; import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@ -319,7 +318,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
// Issue #3039 // Issue #3039
public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception { public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception {
assertAcked(prepareCreate("foo", 2, Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put(SETTING_NUMBER_OF_REPLICAS, 0))); assertAcked(prepareCreate("foo", 2, indexSettings(2, 0)));
ensureGreen(); ensureGreen();
client().prepareIndex("foo") client().prepareIndex("foo")

View file

@ -22,8 +22,6 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ -43,11 +41,7 @@ public class SearchReplicaSelectionIT extends ESIntegTestCase {
// We grab a client directly to avoid using a randomizing client that might set a search preference. // We grab a client directly to avoid using a randomizing client that might set a search preference.
Client client = internalCluster().coordOnlyNodeClient(); Client client = internalCluster().coordOnlyNodeClient();
client.admin() client.admin().indices().prepareCreate("test").setSettings(indexSettings(1, 2)).get();
.indices()
.prepareCreate("test")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 2))
.get();
ensureGreen(); ensureGreen();
client.prepareIndex("test").setSource("field", "value").get(); client.prepareIndex("test").setSource("field", "value").get();

View file

@ -503,9 +503,7 @@ public class SearchScrollIT extends ESIntegTestCase {
public void testStringSortMissingAscTerminates() throws Exception { public void testStringSortMissingAscTerminates() throws Exception {
assertAcked( assertAcked(
prepareCreate("test").setSettings( prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("no_field", "type=keyword", "some_field", "type=keyword")
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
).setMapping("no_field", "type=keyword", "some_field", "type=keyword")
); );
client().prepareIndex("test").setId("1").setSource("some_field", "test").get(); client().prepareIndex("test").setId("1").setSource("some_field", "test").get();
refresh(); refresh();
@ -685,22 +683,8 @@ public class SearchScrollIT extends ESIntegTestCase {
public void testRestartDataNodesDuringScrollSearch() throws Exception { public void testRestartDataNodesDuringScrollSearch() throws Exception {
final String dataNode = internalCluster().startDataOnlyNode(); final String dataNode = internalCluster().startDataOnlyNode();
createIndex( createIndex("demo", indexSettings(1, 0).put("index.routing.allocation.include._name", dataNode).build());
"demo", createIndex("prod", indexSettings(1, 0).put("index.routing.allocation.include._name", dataNode).build());
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.include._name", dataNode)
.build()
);
createIndex(
"prod",
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.include._name", dataNode)
.build()
);
int numDocs = randomIntBetween(10, 100); int numDocs = randomIntBetween(10, 100);
for (int i = 0; i < numDocs; i++) { for (int i = 0; i < numDocs; i++) {
index("demo", "demo-" + i, Map.of()); index("demo", "demo-" + i, Map.of());

View file

@ -39,8 +39,6 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
@ -310,7 +308,7 @@ public class SimpleSearchIT extends ESIntegTestCase {
} }
public void testSimpleTerminateAfterCount() throws Exception { public void testSimpleTerminateAfterCount() throws Exception {
prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)).get(); prepareCreate("test").setSettings(indexSettings(1, 0)).get();
ensureGreen(); ensureGreen();
int max = randomIntBetween(3, 29); int max = randomIntBetween(3, 29);
List<IndexRequestBuilder> docbuilders = new ArrayList<>(max); List<IndexRequestBuilder> docbuilders = new ArrayList<>(max);
@ -344,9 +342,7 @@ public class SimpleSearchIT extends ESIntegTestCase {
} }
public void testSimpleIndexSortEarlyTerminate() throws Exception { public void testSimpleIndexSortEarlyTerminate() throws Exception {
prepareCreate("test").setSettings( prepareCreate("test").setSettings(indexSettings(1, 0).put("index.sort.field", "rank")).setMapping("rank", "type=integer").get();
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).put("index.sort.field", "rank")
).setMapping("rank", "type=integer").get();
ensureGreen(); ensureGreen();
int max = randomIntBetween(3, 29); int max = randomIntBetween(3, 29);
List<IndexRequestBuilder> docbuilders = new ArrayList<>(max); List<IndexRequestBuilder> docbuilders = new ArrayList<>(max);

View file

@ -27,8 +27,6 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
@ -51,12 +49,7 @@ public class FieldUsageStatsIT extends ESIntegTestCase {
public void testFieldUsageStats() throws ExecutionException, InterruptedException { public void testFieldUsageStats() throws ExecutionException, InterruptedException {
internalCluster().ensureAtLeastNumDataNodes(2); internalCluster().ensureAtLeastNumDataNodes(2);
int numShards = randomIntBetween(1, 2); int numShards = randomIntBetween(1, 2);
assertAcked( assertAcked(client().admin().indices().prepareCreate("test").setSettings(indexSettings(numShards, 1)));
client().admin()
.indices()
.prepareCreate("test")
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, numShards).put(SETTING_NUMBER_OF_REPLICAS, 1))
);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd", Locale.ROOT); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd", Locale.ROOT);
LocalDate date = LocalDate.of(2015, 9, 1); LocalDate date = LocalDate.of(2015, 9, 1);

View file

@ -16,7 +16,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.search.stats.SearchStats.Stats; import org.elasticsearch.index.search.stats.SearchStats.Stats;
@ -36,8 +35,6 @@ import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
@ -83,11 +80,7 @@ public class SearchStatsIT extends ESIntegTestCase {
final int shardsIdx1 = randomIntBetween(1, 10); // we make sure each node gets at least a single shard... final int shardsIdx1 = randomIntBetween(1, 10); // we make sure each node gets at least a single shard...
final int shardsIdx2 = Math.max(numNodes - shardsIdx1, randomIntBetween(1, 10)); final int shardsIdx2 = Math.max(numNodes - shardsIdx1, randomIntBetween(1, 10));
assertThat(numNodes, lessThanOrEqualTo(shardsIdx1 + shardsIdx2)); assertThat(numNodes, lessThanOrEqualTo(shardsIdx1 + shardsIdx2));
assertAcked( assertAcked(prepareCreate("test1").setSettings(indexSettings(shardsIdx1, 0)));
prepareCreate("test1").setSettings(
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx1).put(SETTING_NUMBER_OF_REPLICAS, 0)
)
);
int docsTest1 = scaledRandomIntBetween(3 * shardsIdx1, 5 * shardsIdx1); int docsTest1 = scaledRandomIntBetween(3 * shardsIdx1, 5 * shardsIdx1);
for (int i = 0; i < docsTest1; i++) { for (int i = 0; i < docsTest1; i++) {
client().prepareIndex("test1").setId(Integer.toString(i)).setSource("field", "value").get(); client().prepareIndex("test1").setId(Integer.toString(i)).setSource("field", "value").get();
@ -95,11 +88,7 @@ public class SearchStatsIT extends ESIntegTestCase {
refresh(); refresh();
} }
} }
assertAcked( assertAcked(prepareCreate("test2").setSettings(indexSettings(shardsIdx2, 0)));
prepareCreate("test2").setSettings(
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx2).put(SETTING_NUMBER_OF_REPLICAS, 0)
)
);
int docsTest2 = scaledRandomIntBetween(3 * shardsIdx2, 5 * shardsIdx2); int docsTest2 = scaledRandomIntBetween(3 * shardsIdx2, 5 * shardsIdx2);
for (int i = 0; i < docsTest2; i++) { for (int i = 0; i < docsTest2; i++) {
client().prepareIndex("test2").setId(Integer.toString(i)).setSource("field", "value").get(); client().prepareIndex("test2").setId(Integer.toString(i)).setSource("field", "value").get();

View file

@ -55,8 +55,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList; import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful;
@ -1315,10 +1313,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
// see #3555 // see #3555
public void testPrunedSegments() throws IOException { public void testPrunedSegments() throws IOException {
createIndexAndMappingAndSettings( createIndexAndMappingAndSettings(indexSettings(1, 0).build(), completionMappingBuilder);
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).build(),
completionMappingBuilder
);
client().prepareIndex(INDEX) client().prepareIndex(INDEX)
.setId("1") .setId("1")

View file

@ -47,7 +47,6 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.search.suggest.SuggestBuilders.phraseSuggestion; import static org.elasticsearch.search.suggest.SuggestBuilders.phraseSuggestion;
@ -181,10 +180,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
// see #3037 // see #3037
public void testSuggestModes() throws IOException { public void testSuggestModes() throws IOException {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings( CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(
Settings.builder() indexSettings(1, 0).put("index.analysis.analyzer.biword.tokenizer", "standard")
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.analysis.analyzer.biword.tokenizer", "standard")
.putList("index.analysis.analyzer.biword.filter", "shingler", "lowercase") .putList("index.analysis.analyzer.biword.filter", "shingler", "lowercase")
.put("index.analysis.filter.shingler.type", "shingle") .put("index.analysis.filter.shingler.type", "shingle")
.put("index.analysis.filter.shingler.min_shingle_size", 2) .put("index.analysis.filter.shingler.min_shingle_size", 2)
@ -241,7 +237,7 @@ public class SuggestSearchIT extends ESIntegTestCase {
// see #2729 // see #2729
public void testSizeOneShard() throws Exception { public void testSizeOneShard() throws Exception {
prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)).get(); prepareCreate("test").setSettings(indexSettings(1, 0)).get();
ensureGreen(); ensureGreen();
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {

View file

@ -55,14 +55,7 @@ public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase {
internalCluster().startMasterOnlyNode(); internalCluster().startMasterOnlyNode();
final String primaryNode = internalCluster().startDataOnlyNode(); final String primaryNode = internalCluster().startDataOnlyNode();
final String indexName = "test-index"; final String indexName = "test-index";
createIndex( createIndex(indexName, indexSettings(1, 1).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0).build());
indexName,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0)
.build()
);
ensureYellow(indexName); ensureYellow(indexName);
final String newPrimary = internalCluster().startDataOnlyNode(); final String newPrimary = internalCluster().startDataOnlyNode();
final Collection<String> toDelete = new ArrayList<>(); final Collection<String> toDelete = new ArrayList<>();

View file

@ -297,14 +297,7 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase {
logger.info("--> delete the index and recreate it with foo field"); logger.info("--> delete the index and recreate it with foo field");
cluster().wipeIndices("test-idx"); cluster().wipeIndices("test-idx");
assertAcked( assertAcked(
prepareCreate( prepareCreate("test-idx", 2, indexSettings(numShards.numPrimaries, between(0, 1)).put("refresh_interval", 5, TimeUnit.SECONDS))
"test-idx",
2,
Settings.builder()
.put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries)
.put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))
.put("refresh_interval", 5, TimeUnit.SECONDS)
)
); );
assertAcked(client().admin().indices().preparePutMapping("test-idx").setSource("foo", "type=text")); assertAcked(client().admin().indices().preparePutMapping("test-idx").setSource("foo", "type=text"));
ensureGreen(); ensureGreen();

View file

@ -1080,13 +1080,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
); );
// Create index on 2 nodes and make sure each node has a primary by setting no replicas // Create index on 2 nodes and make sure each node has a primary by setting no replicas
assertAcked( assertAcked(prepareCreate("test-idx", 2, indexSettingsNoReplicas(randomIntBetween(2, 10))));
prepareCreate(
"test-idx",
2,
Settings.builder().put("number_of_replicas", 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(2, 10))
)
);
indexRandomDocs("test-idx", 100); indexRandomDocs("test-idx", 100);
// Pick one node and block it // Pick one node and block it

View file

@ -21,7 +21,6 @@ import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
import org.elasticsearch.cluster.routing.allocation.command.AllocateReplicaAllocationCommand; import org.elasticsearch.cluster.routing.allocation.command.AllocateReplicaAllocationCommand;
import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.cluster.routing.allocation.decider.Decision;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.xcontent.ChunkedToXContent; import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentHelper;
@ -310,11 +309,8 @@ public class ClusterRerouteResponseTests extends ESTestCase {
.put( .put(
IndexMetadata.builder("index") IndexMetadata.builder("index")
.settings( .settings(
Settings.builder() indexSettings(1, 0).put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), true)
.put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), true)
.put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 10) .put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 10)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build() .build()
) )

View file

@ -226,11 +226,7 @@ public class AnalysisStatsTests extends AbstractWireSerializingTestCase<Analysis
public void testAccountsRegularIndices() { public void testAccountsRegularIndices() {
String mapping = """ String mapping = """
{"properties":{"bar":{"type":"text","analyzer":"german"}}}"""; {"properties":{"bar":{"type":"text","analyzer":"german"}}}""";
Settings settings = Settings.builder() Settings settings = indexSettings(Version.CURRENT, 4, 1).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
Metadata metadata = new Metadata.Builder().put(new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping)).build(); Metadata metadata = new Metadata.Builder().put(new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping)).build();
{ {
AnalysisStats analysisStats = AnalysisStats.of(metadata, () -> {}); AnalysisStats analysisStats = AnalysisStats.of(metadata, () -> {});
@ -269,11 +265,7 @@ public class AnalysisStatsTests extends AbstractWireSerializingTestCase<Analysis
public void testIgnoreSystemIndices() { public void testIgnoreSystemIndices() {
String mapping = """ String mapping = """
{"properties":{"bar":{"type":"text","analyzer":"german"}}}"""; {"properties":{"bar":{"type":"text","analyzer":"german"}}}""";
Settings settings = Settings.builder() Settings settings = indexSettings(Version.CURRENT, 4, 1).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping).system(true); IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping).system(true);
Metadata metadata = new Metadata.Builder().put(indexMetadata).build(); Metadata metadata = new Metadata.Builder().put(indexMetadata).build();
AnalysisStats analysisStats = AnalysisStats.of(metadata, () -> {}); AnalysisStats analysisStats = AnalysisStats.of(metadata, () -> {});
@ -281,12 +273,7 @@ public class AnalysisStatsTests extends AbstractWireSerializingTestCase<Analysis
} }
public void testChecksForCancellation() { public void testChecksForCancellation() {
Settings settings = Settings.builder() IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(indexSettings(Version.CURRENT, 4, 1));
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings);
Metadata metadata = new Metadata.Builder().put(indexMetadata).build(); Metadata metadata = new Metadata.Builder().put(indexMetadata).build();
expectThrows( expectThrows(
TaskCancelledException.class, TaskCancelledException.class,

View file

@ -32,11 +32,7 @@ import java.util.List;
public class MappingStatsTests extends AbstractWireSerializingTestCase<MappingStats> { public class MappingStatsTests extends AbstractWireSerializingTestCase<MappingStats> {
private static final Settings SINGLE_SHARD_NO_REPLICAS = Settings.builder() private static final Settings SINGLE_SHARD_NO_REPLICAS = indexSettings(Version.CURRENT, 1, 0).build();
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", 1)
.put("index.version.created", Version.CURRENT)
.build();
public static final String MAPPING_TEMPLATE = """ public static final String MAPPING_TEMPLATE = """
{ {
@ -469,12 +465,8 @@ public class MappingStatsTests extends AbstractWireSerializingTestCase<MappingSt
public void testAccountsRegularIndices() { public void testAccountsRegularIndices() {
String mapping = """ String mapping = """
{"properties":{"bar":{"type":"long"}}}"""; {"properties":{"bar":{"type":"long"}}}""";
Settings settings = Settings.builder() IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(indexSettings(Version.CURRENT, 4, 1))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) .putMapping(mapping);
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping);
Metadata metadata = new Metadata.Builder().put(indexMetadata).build(); Metadata metadata = new Metadata.Builder().put(indexMetadata).build();
MappingStats mappingStats = MappingStats.of(metadata, () -> {}); MappingStats mappingStats = MappingStats.of(metadata, () -> {});
FieldStats expectedStats = new FieldStats("long"); FieldStats expectedStats = new FieldStats("long");
@ -486,11 +478,7 @@ public class MappingStatsTests extends AbstractWireSerializingTestCase<MappingSt
public void testIgnoreSystemIndices() { public void testIgnoreSystemIndices() {
String mapping = """ String mapping = """
{"properties":{"bar":{"type":"long"}}}"""; {"properties":{"bar":{"type":"long"}}}""";
Settings settings = Settings.builder() Settings settings = indexSettings(Version.CURRENT, 4, 1).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping).system(true); IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping(mapping).system(true);
Metadata metadata = new Metadata.Builder().put(indexMetadata).build(); Metadata metadata = new Metadata.Builder().put(indexMetadata).build();
MappingStats mappingStats = MappingStats.of(metadata, () -> {}); MappingStats mappingStats = MappingStats.of(metadata, () -> {});
@ -498,11 +486,7 @@ public class MappingStatsTests extends AbstractWireSerializingTestCase<MappingSt
} }
public void testChecksForCancellation() { public void testChecksForCancellation() {
Settings settings = Settings.builder() Settings settings = indexSettings(Version.CURRENT, 4, 1).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 4)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping("{}"); IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder("foo").settings(settings).putMapping("{}");
Metadata metadata = new Metadata.Builder().put(indexMetadata).build(); Metadata metadata = new Metadata.Builder().put(indexMetadata).build();
expectThrows( expectThrows(

View file

@ -20,7 +20,6 @@ import org.elasticsearch.cluster.routing.RecoverySource;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardPath; import org.elasticsearch.index.shard.ShardPath;
@ -137,13 +136,7 @@ public class VersionStatsTests extends AbstractWireSerializingTestCase<VersionSt
} }
private static IndexMetadata indexMeta(String name, Version version, int primaryShards) { private static IndexMetadata indexMeta(String name, Version version, int primaryShards) {
Settings settings = Settings.builder() return new IndexMetadata.Builder(name).settings(indexSettings(version, primaryShards, randomIntBetween(0, 3))).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, version)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, primaryShards)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 3))
.build();
IndexMetadata.Builder indexMetadata = new IndexMetadata.Builder(name).settings(settings);
return indexMetadata.build();
} }
public static VersionStats randomInstance() { public static VersionStats randomInstance() {

View file

@ -178,11 +178,7 @@ public class MetadataRolloverServiceTests extends ESTestCase {
String index2 = randomAlphaOfLength(10); String index2 = randomAlphaOfLength(10);
String aliasWithNoWriteIndex = randomAlphaOfLength(10); String aliasWithNoWriteIndex = randomAlphaOfLength(10);
Boolean firstIsWriteIndex = randomFrom(false, null); Boolean firstIsWriteIndex = randomFrom(false, null);
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
Metadata.Builder metadataBuilder = Metadata.builder() Metadata.Builder metadataBuilder = Metadata.builder()
.put( .put(
@ -289,11 +285,7 @@ public class MetadataRolloverServiceTests extends ESTestCase {
final RolloverRequest rolloverRequest = new RolloverRequest(alias, randomAlphaOfLength(10)); final RolloverRequest rolloverRequest = new RolloverRequest(alias, randomAlphaOfLength(10));
final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE; final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE;
rolloverRequest.getCreateIndexRequest().waitForActiveShards(activeShardCount); rolloverRequest.getCreateIndexRequest().waitForActiveShards(activeShardCount);
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
rolloverRequest.getCreateIndexRequest().settings(settings); rolloverRequest.getCreateIndexRequest().settings(settings);
final CreateIndexClusterStateUpdateRequest createIndexRequest = MetadataRolloverService.prepareCreateIndexRequest( final CreateIndexClusterStateUpdateRequest createIndexRequest = MetadataRolloverService.prepareCreateIndexRequest(
@ -312,11 +304,7 @@ public class MetadataRolloverServiceTests extends ESTestCase {
final RolloverRequest rolloverRequest = new RolloverRequest(dataStream.getName(), randomAlphaOfLength(10)); final RolloverRequest rolloverRequest = new RolloverRequest(dataStream.getName(), randomAlphaOfLength(10));
final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE; final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE;
rolloverRequest.getCreateIndexRequest().waitForActiveShards(activeShardCount); rolloverRequest.getCreateIndexRequest().waitForActiveShards(activeShardCount);
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
rolloverRequest.getCreateIndexRequest().settings(settings); rolloverRequest.getCreateIndexRequest().settings(settings);
final CreateIndexClusterStateUpdateRequest createIndexRequest = MetadataRolloverService.prepareDataStreamCreateIndexRequest( final CreateIndexClusterStateUpdateRequest createIndexRequest = MetadataRolloverService.prepareDataStreamCreateIndexRequest(
@ -748,15 +736,9 @@ public class MetadataRolloverServiceTests extends ESTestCase {
} }
private static IndexMetadata createMetadata(String indexName) { private static IndexMetadata createMetadata(String indexName) {
final Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build();
return IndexMetadata.builder(indexName) return IndexMetadata.builder(indexName)
.creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(3).getMillis()) .creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(3).getMillis())
.settings(settings) .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()))
.build(); .build();
} }

View file

@ -216,12 +216,10 @@ public class TransportRolloverActionTests extends ESTestCase {
minPrimaryShardDocsCondition minPrimaryShardDocsCondition
); );
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, randomIntBetween(1, 1000), 10).put(
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) IndexMetadata.SETTING_INDEX_UUID,
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) UUIDs.randomBase64UUID()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 1000)) ).build();
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomInt(10))
.build();
final IndexMetadata metadata = IndexMetadata.builder(randomAlphaOfLength(10)) final IndexMetadata metadata = IndexMetadata.builder(randomAlphaOfLength(10))
.creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(randomIntBetween(5, 10)).getMillis()) .creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(randomIntBetween(5, 10)).getMillis())
@ -285,12 +283,10 @@ public class TransportRolloverActionTests extends ESTestCase {
minPrimaryShardDocsCondition minPrimaryShardDocsCondition
); );
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, randomIntBetween(1, 1000), 10).put(
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) IndexMetadata.SETTING_INDEX_UUID,
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) UUIDs.randomBase64UUID()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 1000)) ).build();
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomInt(10))
.build();
final IndexMetadata metadata = IndexMetadata.builder(randomAlphaOfLength(10)) final IndexMetadata metadata = IndexMetadata.builder(randomAlphaOfLength(10))
.creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(randomIntBetween(5, 10)).getMillis()) .creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(randomIntBetween(5, 10)).getMillis())
@ -447,11 +443,7 @@ public class TransportRolloverActionTests extends ESTestCase {
} }
private static IndexMetadata createMetadata(String indexName) { private static IndexMetadata createMetadata(String indexName) {
final Settings settings = Settings.builder() final Settings settings = indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
return IndexMetadata.builder(indexName) return IndexMetadata.builder(indexName)
.creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(3).getMillis()) .creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(3).getMillis())

View file

@ -42,19 +42,7 @@ public class TransportUpdateSettingsActionTests extends ESTestCase {
private static final ClusterState CLUSTER_STATE = ClusterState.builder(new ClusterName("test")) private static final ClusterState CLUSTER_STATE = ClusterState.builder(new ClusterName("test"))
.metadata( .metadata(
Metadata.builder() Metadata.builder()
.put( .put(IndexMetadata.builder(".my-system").system(true).settings(indexSettings(Version.CURRENT, 1, 0)).build(), true)
IndexMetadata.builder(".my-system")
.system(true)
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.build()
)
.build(),
true
)
.build() .build()
) )
.build(); .build();

View file

@ -10,7 +10,6 @@ package org.elasticsearch.action.admin.indices.shrink;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.index.shard.DocsStats;
import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.store.StoreStats;
@ -21,12 +20,9 @@ import static org.elasticsearch.action.admin.indices.shrink.ResizeNumberOfShards
public class ResizeNumberOfShardsCalculatorTests extends ESTestCase { public class ResizeNumberOfShardsCalculatorTests extends ESTestCase {
public void testShrink() { public void testShrink() {
Settings settings = Settings.builder() IndexMetadata indexMetadata = IndexMetadata.builder("index")
.put("index.number_of_shards", randomIntBetween(1, 5)) .settings(indexSettings(Version.CURRENT, randomIntBetween(1, 5), randomIntBetween(0, 5)))
.put("index.number_of_replicas", randomIntBetween(0, 5))
.put("index.version.created", Version.CURRENT)
.build(); .build();
IndexMetadata indexMetadata = IndexMetadata.builder("index").settings(settings).build();
ResizeNumberOfShardsCalculator.ShrinkShardsCalculator shrinkShardsCalculator = ResizeNumberOfShardsCalculator.ShrinkShardsCalculator shrinkShardsCalculator =
new ResizeNumberOfShardsCalculator.ShrinkShardsCalculator( new ResizeNumberOfShardsCalculator.ShrinkShardsCalculator(
@ -52,12 +48,9 @@ public class ResizeNumberOfShardsCalculatorTests extends ESTestCase {
} }
public void testCloneInputs() { public void testCloneInputs() {
Settings settings = Settings.builder() IndexMetadata indexMetadata = IndexMetadata.builder("index")
.put("index.number_of_shards", randomIntBetween(1, 5)) .settings(indexSettings(Version.CURRENT, randomIntBetween(1, 5), randomIntBetween(0, 5)))
.put("index.number_of_replicas", randomIntBetween(0, 5))
.put("index.version.created", Version.CURRENT)
.build(); .build();
IndexMetadata indexMetadata = IndexMetadata.builder("index").settings(settings).build();
ResizeNumberOfShardsCalculator.CloneShardsCalculator cloneShardsCalculator = ResizeNumberOfShardsCalculator.CloneShardsCalculator cloneShardsCalculator =
new ResizeNumberOfShardsCalculator.CloneShardsCalculator(); new ResizeNumberOfShardsCalculator.CloneShardsCalculator();
@ -73,12 +66,9 @@ public class ResizeNumberOfShardsCalculatorTests extends ESTestCase {
} }
public void testSplitInputs() { public void testSplitInputs() {
Settings settings = Settings.builder() IndexMetadata indexMetadata = IndexMetadata.builder("index")
.put("index.number_of_shards", randomIntBetween(2, 5)) .settings(indexSettings(Version.CURRENT, randomIntBetween(2, 5), randomIntBetween(0, 5)))
.put("index.number_of_replicas", randomIntBetween(0, 5))
.put("index.version.created", Version.CURRENT)
.build(); .build();
IndexMetadata indexMetadata = IndexMetadata.builder("index").settings(settings).build();
ResizeNumberOfShardsCalculator.SplitShardsCalculator splitShardsCalculator = ResizeNumberOfShardsCalculator.SplitShardsCalculator splitShardsCalculator =
new ResizeNumberOfShardsCalculator.SplitShardsCalculator(); new ResizeNumberOfShardsCalculator.SplitShardsCalculator();

View file

@ -80,11 +80,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
private static final ActionListener<Void> ASSERTING_DONE_LISTENER = ActionTestUtils.assertNoFailureListener(r -> {}); private static final ActionListener<Void> ASSERTING_DONE_LISTENER = ActionTestUtils.assertNoFailureListener(r -> {});
private final ShardId shardId = new ShardId("index", "_na_", 0); private final ShardId shardId = new ShardId("index", "_na_", 0);
private final Settings idxSettings = Settings.builder() private final Settings idxSettings = indexSettings(Version.CURRENT, 1, 0).build();
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("index.version.created", Version.CURRENT.id)
.build();
private IndexMetadata indexMetadata() throws IOException { private IndexMetadata indexMetadata() throws IOException {
return IndexMetadata.builder("index").putMapping(""" return IndexMetadata.builder("index").putMapping("""

View file

@ -111,11 +111,10 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
} }
Metadata.Builder metadata = Metadata.builder(); Metadata.Builder metadata = Metadata.builder();
for (String index : allIndices) { for (String index : allIndices) {
final Settings.Builder settings = Settings.builder() metadata.put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 10)) IndexMetadata.builder(index)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 2)) .settings(indexSettings(Version.CURRENT.minimumIndexCompatibilityVersion(), between(1, 10), between(0, 2)))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.minimumIndexCompatibilityVersion()); );
metadata.put(IndexMetadata.builder(index).settings(settings));
} }
clusterState = newClusterState(metadata.build(), discoNodes.build()); clusterState = newClusterState(metadata.build(), discoNodes.build());
} }
@ -182,11 +181,10 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
} }
Metadata.Builder metadata = Metadata.builder(); Metadata.Builder metadata = Metadata.builder();
for (String index : allIndices) { for (String index : allIndices) {
final Settings.Builder settings = Settings.builder() metadata.put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 10)) IndexMetadata.builder(index)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(1, 3)) .settings(indexSettings(Version.CURRENT.minimumIndexCompatibilityVersion(), between(1, 10), between(1, 3)))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.minimumIndexCompatibilityVersion()); );
metadata.put(IndexMetadata.builder(index).settings(settings));
} }
clusterState = newClusterState(metadata.build(), discoNodes.build()); clusterState = newClusterState(metadata.build(), discoNodes.build());
} }
@ -304,11 +302,10 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
} }
Metadata.Builder metadata = Metadata.builder(); Metadata.Builder metadata = Metadata.builder();
for (String index : allIndices) { for (String index : allIndices) {
final Settings.Builder settings = Settings.builder() metadata.put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 10)) IndexMetadata.builder(index)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 3)) .settings(indexSettings(Version.CURRENT.minimumIndexCompatibilityVersion(), between(1, 10), between(0, 3)))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.minimumIndexCompatibilityVersion()); );
metadata.put(IndexMetadata.builder(index).settings(settings));
} }
clusterState = newClusterState(metadata.build(), discoNodes.build()); clusterState = newClusterState(metadata.build(), discoNodes.build());
} }
@ -428,11 +425,10 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
} }
Metadata.Builder metadata = Metadata.builder(); Metadata.Builder metadata = Metadata.builder();
for (String index : allIndices) { for (String index : allIndices) {
final Settings.Builder settings = Settings.builder() metadata.put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(2, 10)) IndexMetadata.builder(index)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 2)) .settings(indexSettings(Version.CURRENT.minimumIndexCompatibilityVersion(), between(2, 10), between(0, 2)))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.minimumIndexCompatibilityVersion()); );
metadata.put(IndexMetadata.builder(index).settings(settings));
} }
clusterState = newClusterState(metadata.build(), discoNodes.build()); clusterState = newClusterState(metadata.build(), discoNodes.build());
} }
@ -456,7 +452,6 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
); );
final RequestTracker requestTracker = new RequestTracker(dispatcher, clusterState.routingTable(), withFilter); final RequestTracker requestTracker = new RequestTracker(dispatcher, clusterState.routingTable(), withFilter);
transportService.requestTracker.set(requestTracker); transportService.requestTracker.set(requestTracker);
final AtomicInteger failedTimes = new AtomicInteger();
final Set<ShardId> allUnmatchedShardIds = new HashSet<>(); final Set<ShardId> allUnmatchedShardIds = new HashSet<>();
for (String index : indices) { for (String index : indices) {
final Set<ShardId> shardIds = new HashSet<>(); final Set<ShardId> shardIds = new HashSet<>();
@ -519,7 +514,6 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
public void testStopAfterAllShardsUnmatched() throws Exception { public void testStopAfterAllShardsUnmatched() throws Exception {
final List<String> allIndices = IntStream.rangeClosed(1, 5).mapToObj(n -> "index_" + n).toList(); final List<String> allIndices = IntStream.rangeClosed(1, 5).mapToObj(n -> "index_" + n).toList();
final ClusterState clusterState; final ClusterState clusterState;
final boolean newVersionOnly = randomBoolean();
{ {
DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder();
int numNodes = randomIntBetween(1, 10); int numNodes = randomIntBetween(1, 10);
@ -528,11 +522,10 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
} }
Metadata.Builder metadata = Metadata.builder(); Metadata.Builder metadata = Metadata.builder();
for (String index : allIndices) { for (String index : allIndices) {
final Settings.Builder settings = Settings.builder() metadata.put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 10)) IndexMetadata.builder(index)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 2)) .settings(indexSettings(Version.CURRENT.minimumIndexCompatibilityVersion(), between(1, 10), between(0, 2)))
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.minimumIndexCompatibilityVersion()); );
metadata.put(IndexMetadata.builder(index).settings(settings));
} }
clusterState = newClusterState(metadata.build(), discoNodes.build()); clusterState = newClusterState(metadata.build(), discoNodes.build());
} }
@ -556,7 +549,6 @@ public class RequestDispatcherTests extends ESAllocationTestCase {
); );
final RequestTracker requestTracker = new RequestTracker(dispatcher, clusterState.routingTable(), withFilter); final RequestTracker requestTracker = new RequestTracker(dispatcher, clusterState.routingTable(), withFilter);
transportService.requestTracker.set(requestTracker); transportService.requestTracker.set(requestTracker);
final AtomicInteger failedTimes = new AtomicInteger();
final List<String> unmatchedIndices = randomSubsetOf(between(1, indices.size()), indices); final List<String> unmatchedIndices = randomSubsetOf(between(1, indices.size()), indices);
transportService.setTransportInterceptor(new TransportInterceptor.AsyncSender() { transportService.setTransportInterceptor(new TransportInterceptor.AsyncSender() {
@Override @Override

View file

@ -98,11 +98,7 @@ public class TransportMultiGetActionTests extends ESTestCase {
.metadata( .metadata(
new Metadata.Builder().put( new Metadata.Builder().put(
new IndexMetadata.Builder(index1.getName()).settings( new IndexMetadata.Builder(index1.getName()).settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 1).put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
.put("index.version.created", Version.CURRENT)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
) )
.putMapping( .putMapping(
XContentHelper.convertToJson( XContentHelper.convertToJson(
@ -123,11 +119,7 @@ public class TransportMultiGetActionTests extends ESTestCase {
) )
.put( .put(
new IndexMetadata.Builder(index2.getName()).settings( new IndexMetadata.Builder(index2.getName()).settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 1).put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
.put("index.version.created", Version.CURRENT)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
) )
.putMapping( .putMapping(
XContentHelper.convertToJson( XContentHelper.convertToJson(

View file

@ -66,9 +66,6 @@ import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_CREATION_DATE; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_CREATION_DATE;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_INDEX_UUID; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_INDEX_UUID;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED;
import static org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting; import static org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting;
import static org.elasticsearch.test.ClusterServiceUtils.createClusterService; import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
import static org.elasticsearch.test.ClusterServiceUtils.setState; import static org.elasticsearch.test.ClusterServiceUtils.setState;
@ -129,11 +126,7 @@ public class TransportReplicationAllPermitsAcquisitionTests extends IndexShardTe
RecoverySource.EmptyStoreRecoverySource.INSTANCE RecoverySource.EmptyStoreRecoverySource.INSTANCE
); );
Settings indexSettings = Settings.builder() Settings indexSettings = indexSettings(Version.CURRENT, 1, 1).put(SETTING_INDEX_UUID, shardId.getIndex().getUUID())
.put(SETTING_VERSION_CREATED, Version.CURRENT)
.put(SETTING_INDEX_UUID, shardId.getIndex().getUUID())
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 1)
.put(SETTING_CREATION_DATE, System.currentTimeMillis()) .put(SETTING_CREATION_DATE, System.currentTimeMillis())
.build(); .build();

View file

@ -99,11 +99,7 @@ public class TransportMultiTermVectorsActionTests extends ESTestCase {
.metadata( .metadata(
new Metadata.Builder().put( new Metadata.Builder().put(
new IndexMetadata.Builder(index1.getName()).settings( new IndexMetadata.Builder(index1.getName()).settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 1).put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
.put("index.version.created", Version.CURRENT)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
) )
.putMapping( .putMapping(
XContentHelper.convertToJson( XContentHelper.convertToJson(
@ -124,11 +120,7 @@ public class TransportMultiTermVectorsActionTests extends ESTestCase {
) )
.put( .put(
new IndexMetadata.Builder(index2.getName()).settings( new IndexMetadata.Builder(index2.getName()).settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 1).put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
.put("index.version.created", Version.CURRENT)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put(IndexMetadata.SETTING_INDEX_UUID, index1.getUUID())
) )
.putMapping( .putMapping(
XContentHelper.convertToJson( XContentHelper.convertToJson(

View file

@ -112,11 +112,8 @@ public class ComponentTemplateTests extends SimpleDiffableSerializationTestCase<
} }
private static Settings randomSettings() { private static Settings randomSettings() {
return Settings.builder() return indexSettings(randomIntBetween(1, 10), randomIntBetween(0, 5)).put(IndexMetadata.SETTING_BLOCKS_READ, randomBoolean())
.put(IndexMetadata.SETTING_BLOCKS_READ, randomBoolean())
.put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean()) .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 10))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 5))
.put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean()) .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
.put(IndexMetadata.SETTING_PRIORITY, randomIntBetween(0, 100000)) .put(IndexMetadata.SETTING_PRIORITY, randomIntBetween(0, 100000))
.build(); .build();

View file

@ -127,11 +127,8 @@ public class ComposableIndexTemplateTests extends SimpleDiffableSerializationTes
} }
private static Settings randomSettings() { private static Settings randomSettings() {
return Settings.builder() return indexSettings(randomIntBetween(1, 10), randomIntBetween(0, 5)).put(IndexMetadata.SETTING_BLOCKS_READ, randomBoolean())
.put(IndexMetadata.SETTING_BLOCKS_READ, randomBoolean())
.put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean()) .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 10))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 5))
.put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean()) .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
.put(IndexMetadata.SETTING_PRIORITY, randomIntBetween(0, 100000)) .put(IndexMetadata.SETTING_PRIORITY, randomIntBetween(0, 100000))
.build(); .build();

View file

@ -20,7 +20,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingHelper; import org.elasticsearch.cluster.routing.ShardRoutingHelper;
import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.index.shard.DocsStats;
import org.elasticsearch.index.shard.IndexingStats; import org.elasticsearch.index.shard.IndexingStats;
@ -38,15 +37,7 @@ import static org.mockito.Mockito.when;
public class IndexMetadataStatsTests extends ESTestCase { public class IndexMetadataStatsTests extends ESTestCase {
public void testFromStatsCreation() { public void testFromStatsCreation() {
final String indexName = "idx"; final String indexName = "idx";
final IndexMetadata indexMetadata = IndexMetadata.builder(indexName) final IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(indexSettings(Version.CURRENT, 3, 1)).build();
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 3)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build()
)
.build();
final IndicesStatsResponse response = mock(IndicesStatsResponse.class); final IndicesStatsResponse response = mock(IndicesStatsResponse.class);
final IndexStats indexStats = mock(IndexStats.class); final IndexStats indexStats = mock(IndexStats.class);

View file

@ -79,13 +79,7 @@ public class IndexMetadataTests extends ESTestCase {
Double indexWriteLoadForecast = randomBoolean() ? randomDoubleBetween(0.0, 128, true) : null; Double indexWriteLoadForecast = randomBoolean() ? randomDoubleBetween(0.0, 128, true) : null;
Long shardSizeInBytesForecast = randomBoolean() ? randomLongBetween(1024, 10240) : null; Long shardSizeInBytesForecast = randomBoolean() ? randomLongBetween(1024, 10240) : null;
IndexMetadata metadata = IndexMetadata.builder("foo") IndexMetadata metadata = IndexMetadata.builder("foo")
.settings( .settings(indexSettings(numShard, numberOfReplicas).put("index.version.created", 1))
Settings.builder()
.put("index.version.created", 1)
.put("index.number_of_shards", numShard)
.put("index.number_of_replicas", numberOfReplicas)
.build()
)
.creationDate(randomLong()) .creationDate(randomLong())
.primaryTerm(0, 2) .primaryTerm(0, 2)
.setRoutingNumShards(32) .setRoutingNumShards(32)
@ -176,13 +170,7 @@ public class IndexMetadataTests extends ESTestCase {
public void testSelectShrinkShards() { public void testSelectShrinkShards() {
int numberOfReplicas = randomIntBetween(0, 10); int numberOfReplicas = randomIntBetween(0, 10);
IndexMetadata metadata = IndexMetadata.builder("foo") IndexMetadata metadata = IndexMetadata.builder("foo")
.settings( .settings(indexSettings(32, numberOfReplicas).put("index.version.created", 1))
Settings.builder()
.put("index.version.created", 1)
.put("index.number_of_shards", 32)
.put("index.number_of_replicas", numberOfReplicas)
.build()
)
.creationDate(randomLong()) .creationDate(randomLong())
.build(); .build();
Set<ShardId> shardIds = IndexMetadata.selectShrinkShards(0, metadata, 8); Set<ShardId> shardIds = IndexMetadata.selectShrinkShards(0, metadata, 8);
@ -226,25 +214,13 @@ public class IndexMetadataTests extends ESTestCase {
int numTargetShards = randomFrom(4, 6, 8, 12); int numTargetShards = randomFrom(4, 6, 8, 12);
IndexMetadata split = IndexMetadata.builder("foo") IndexMetadata split = IndexMetadata.builder("foo")
.settings( .settings(indexSettings(2, 0).put("index.version.created", 1))
Settings.builder()
.put("index.version.created", 1)
.put("index.number_of_shards", 2)
.put("index.number_of_replicas", 0)
.build()
)
.creationDate(randomLong()) .creationDate(randomLong())
.setRoutingNumShards(numTargetShards * 2) .setRoutingNumShards(numTargetShards * 2)
.build(); .build();
IndexMetadata shrink = IndexMetadata.builder("foo") IndexMetadata shrink = IndexMetadata.builder("foo")
.settings( .settings(indexSettings(32, 0).put("index.version.created", 1))
Settings.builder()
.put("index.version.created", 1)
.put("index.number_of_shards", 32)
.put("index.number_of_replicas", 0)
.build()
)
.creationDate(randomLong()) .creationDate(randomLong())
.build(); .build();
int shard = randomIntBetween(0, numTargetShards - 1); int shard = randomIntBetween(0, numTargetShards - 1);
@ -265,13 +241,7 @@ public class IndexMetadataTests extends ESTestCase {
public void testSelectSplitShard() { public void testSelectSplitShard() {
IndexMetadata metadata = IndexMetadata.builder("foo") IndexMetadata metadata = IndexMetadata.builder("foo")
.settings( .settings(indexSettings(2, 0).put("index.version.created", 1))
Settings.builder()
.put("index.version.created", 1)
.put("index.number_of_shards", 2)
.put("index.number_of_replicas", 0)
.build()
)
.creationDate(randomLong()) .creationDate(randomLong())
.setRoutingNumShards(4) .setRoutingNumShards(4)
.build(); .build();
@ -301,12 +271,7 @@ public class IndexMetadataTests extends ESTestCase {
} }
public void testIndexFormat() { public void testIndexFormat() {
Settings defaultSettings = Settings.builder() Settings defaultSettings = indexSettings(1, 1).put("index.version.created", 1).build();
.put("index.version.created", 1)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.build();
// matching version // matching version
{ {
IndexMetadata metadata = IndexMetadata.builder("foo") IndexMetadata metadata = IndexMetadata.builder("foo")
@ -446,10 +411,7 @@ public class IndexMetadataTests extends ESTestCase {
} }
public void testIsHidden() { public void testIsHidden() {
Settings.Builder settings = Settings.builder() Settings.Builder settings = indexSettings(Version.CURRENT, randomIntBetween(1, 8), 0);
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 8))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT);
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).build(); IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).build();
assertFalse(indexMetadata.isHidden()); assertFalse(indexMetadata.isHidden());
@ -480,11 +442,7 @@ public class IndexMetadataTests extends ESTestCase {
} }
public void testLifeCyclePolicyName() { public void testLifeCyclePolicyName() {
Settings.Builder settings = Settings.builder() Settings.Builder settings = indexSettings(Version.CURRENT, randomIntBetween(1, 8), 0);
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 8))
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT);
IndexMetadata idxMeta1 = IndexMetadata.builder("test").settings(settings).build(); IndexMetadata idxMeta1 = IndexMetadata.builder("test").settings(settings).build();
// null means no policy // null means no policy
@ -535,12 +493,7 @@ public class IndexMetadataTests extends ESTestCase {
} }
private static Settings indexSettingsWithDataTier(String dataTier) { private static Settings indexSettingsWithDataTier(String dataTier) {
return Settings.builder() return indexSettings(Version.CURRENT, 1, 0).put(DataTier.TIER_PREFERENCE, dataTier).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(DataTier.TIER_PREFERENCE, dataTier)
.build();
} }
private IndexMetadataStats randomIndexStats(int numberOfShards) { private IndexMetadataStats randomIndexStats(int numberOfShards) {

View file

@ -152,14 +152,10 @@ public class IndexMetadataVerifierTests extends ESTestCase {
} }
private static IndexMetadata.Builder newIndexMetaBuilder(String name, Settings indexSettings) { private static IndexMetadata.Builder newIndexMetaBuilder(String name, Settings indexSettings) {
final Settings settings = Settings.builder() final Settings settings = indexSettings(randomIndexCompatibleVersion(random()), between(1, 5), between(0, 5)).put(
.put(IndexMetadata.SETTING_VERSION_CREATED, randomIndexCompatibleVersion(random())) IndexMetadata.SETTING_CREATION_DATE,
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 5)) randomNonNegativeLong()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)) ).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())).put(indexSettings).build();
.put(IndexMetadata.SETTING_CREATION_DATE, randomNonNegativeLong())
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random()))
.put(indexSettings)
.build();
final IndexMetadata.Builder indexMetadataBuilder = IndexMetadata.builder(name).settings(settings); final IndexMetadata.Builder indexMetadataBuilder = IndexMetadata.builder(name).settings(settings);
if (randomBoolean()) { if (randomBoolean()) {
indexMetadataBuilder.state(IndexMetadata.State.CLOSE); indexMetadataBuilder.state(IndexMetadata.State.CLOSE);

View file

@ -125,9 +125,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
PutRequest request = new PutRequest("test", "test_replicas"); PutRequest request = new PutRequest("test", "test_replicas");
request.patterns(singletonList("test_shards_wait*")); request.patterns(singletonList("test_shards_wait*"));
Settings.Builder settingsBuilder = builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "1") Settings.Builder settingsBuilder = indexSettings(1, 1).put(IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "2");
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, "1")
.put(IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "2");
request.settings(settingsBuilder.build()); request.settings(settingsBuilder.build());
@ -140,9 +138,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
PutRequest request = new PutRequest("test", "test_specified_replicas"); PutRequest request = new PutRequest("test", "test_specified_replicas");
request.patterns(singletonList("test_shards_wait*")); request.patterns(singletonList("test_shards_wait*"));
Settings.Builder settingsBuilder = builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "1") Settings.Builder settingsBuilder = indexSettings(1, 1).put(IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "3");
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, "1")
.put(IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS.getKey(), "3");
request.settings(settingsBuilder.build()); request.settings(settingsBuilder.build());
@ -1908,17 +1904,9 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
) )
.put( .put(
IndexMetadata.builder(".ds-unreferenced-000001") IndexMetadata.builder(".ds-unreferenced-000001")
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, "uuid2"))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid2")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
) )
) )
.build()
)
.build(); .build();
ComposableIndexTemplate template = new ComposableIndexTemplate( ComposableIndexTemplate template = new ComposableIndexTemplate(
@ -1945,17 +1933,9 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
) )
.put( .put(
IndexMetadata.builder(".ds-logs-mysql-default-000001") IndexMetadata.builder(".ds-logs-mysql-default-000001")
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, "uuid"))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
) )
) )
.build()
)
.build(); .build();
// Test replacing it with a version without the data stream config // Test replacing it with a version without the data stream config
@ -2068,17 +2048,9 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
) )
.put( .put(
IndexMetadata.builder(".ds-unreferenced-000001") IndexMetadata.builder(".ds-unreferenced-000001")
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, "uuid2"))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid2")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
) )
) )
.build()
)
.build(); .build();
ComposableIndexTemplate template = new ComposableIndexTemplate( ComposableIndexTemplate template = new ComposableIndexTemplate(
@ -2105,17 +2077,9 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
) )
.put( .put(
IndexMetadata.builder(".ds-logs-mysql-default-000001") IndexMetadata.builder(".ds-logs-mysql-default-000001")
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, "uuid"))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
) )
) )
.build()
)
.build(); .build();
ComposableIndexTemplate fineGrainedLogsTemplate = new ComposableIndexTemplate( ComposableIndexTemplate fineGrainedLogsTemplate = new ComposableIndexTemplate(

View file

@ -620,26 +620,8 @@ public class MetadataTests extends ESTestCase {
public void testFindMappings() throws IOException { public void testFindMappings() throws IOException {
Metadata metadata = Metadata.builder() Metadata metadata = Metadata.builder()
.put( .put(IndexMetadata.builder("index1").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(FIND_MAPPINGS_TEST_ITEM))
IndexMetadata.builder("index1") .put(IndexMetadata.builder("index2").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(FIND_MAPPINGS_TEST_ITEM))
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(FIND_MAPPINGS_TEST_ITEM)
)
.put(
IndexMetadata.builder("index2")
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(FIND_MAPPINGS_TEST_ITEM)
)
.build(); .build();
{ {
@ -684,16 +666,7 @@ public class MetadataTests extends ESTestCase {
); );
Metadata metadata = Metadata.builder() Metadata metadata = Metadata.builder()
.put( .put(IndexMetadata.builder("index1").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(originalMappingMetadata))
IndexMetadata.builder("index1")
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(originalMappingMetadata)
)
.build(); .build();
{ {
@ -729,36 +702,9 @@ public class MetadataTests extends ESTestCase {
} }
Metadata metadata = Metadata.builder() Metadata metadata = Metadata.builder()
.put( .put(IndexMetadata.builder("index1").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(mapping))
IndexMetadata.builder("index1") .put(IndexMetadata.builder("index2").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(mapping))
.settings( .put(IndexMetadata.builder("index3").settings(indexSettings(Version.CURRENT, 1, 0)).putMapping(mapping))
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(mapping)
)
.put(
IndexMetadata.builder("index2")
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(mapping)
)
.put(
IndexMetadata.builder("index3")
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putMapping(mapping)
)
.build(); .build();
{ {
@ -1269,14 +1215,7 @@ public class MetadataTests extends ESTestCase {
b = Metadata.builder(); b = Metadata.builder();
b.put( b.put(
IndexMetadata.builder("index1") IndexMetadata.builder("index1").settings(indexSettings(Version.CURRENT, 1, 0)).putAlias(new AliasMetadata.Builder("my-alias"))
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putAlias(new AliasMetadata.Builder("my-alias"))
); );
addDataStream("d1", b); addDataStream("d1", b);
@ -1304,14 +1243,7 @@ public class MetadataTests extends ESTestCase {
b = Metadata.builder(); b = Metadata.builder();
b.put( b.put(
IndexMetadata.builder("index1") IndexMetadata.builder("index1").settings(indexSettings(Version.CURRENT, 1, 0)).putAlias(new AliasMetadata.Builder("my-alias"))
.settings(
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
)
.putAlias(new AliasMetadata.Builder("my-alias"))
); );
b.dataStreams(Map.of("d1", createDataStream("d1")), Map.of("my-alias", new DataStreamAlias("my-alias", List.of("d1"), null, null))); b.dataStreams(Map.of("d1", createDataStream("d1")), Map.of("my-alias", new DataStreamAlias("my-alias", List.of("d1"), null, null)));
e = expectThrows(IllegalStateException.class, b::build); e = expectThrows(IllegalStateException.class, b::build);

View file

@ -236,9 +236,6 @@ public class SystemIndexMetadataUpgradeServiceTests extends ESTestCase {
} }
private static Settings.Builder getSettingsBuilder() { private static Settings.Builder getSettingsBuilder() {
return Settings.builder() return indexSettings(Version.CURRENT, 1, 0);
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1);
} }
} }

View file

@ -44,8 +44,6 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.routing.RoutingNodesHelper.shardsWithState; import static org.elasticsearch.cluster.routing.RoutingNodesHelper.shardsWithState;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
@ -138,10 +136,8 @@ public class FailedNodeRoutingTests extends ESAllocationTestCase {
logger.info("--> creating some indices"); logger.info("--> creating some indices");
for (int i = 0; i < randomIntBetween(2, 5); i++) { for (int i = 0; i < randomIntBetween(2, 5); i++) {
String name = "index_" + randomAlphaOfLength(8).toLowerCase(Locale.ROOT); String name = "index_" + randomAlphaOfLength(8).toLowerCase(Locale.ROOT);
Settings.Builder settingsBuilder = Settings.builder() CreateIndexRequest request = new CreateIndexRequest(name, indexSettings(randomIntBetween(1, 4), randomIntBetween(2, 4)).build())
.put(SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 4)) .waitForActiveShards(ActiveShardCount.NONE);
.put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(2, 4));
CreateIndexRequest request = new CreateIndexRequest(name, settingsBuilder.build()).waitForActiveShards(ActiveShardCount.NONE);
state = cluster.createIndex(state, request); state = cluster.createIndex(state, request);
assertTrue(state.metadata().hasIndex(name)); assertTrue(state.metadata().hasIndex(name));
} }

View file

@ -496,14 +496,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
IntFunction<String> assignmentFunction IntFunction<String> assignmentFunction
) { ) {
final var inSyncIds = randomList(numberOfShards, numberOfShards, () -> UUIDs.randomBase64UUID(random())); final var inSyncIds = randomList(numberOfShards, numberOfShards, () -> UUIDs.randomBase64UUID(random()));
final var indexMetadataBuilder = IndexMetadata.builder(indexName) final var indexMetadataBuilder = IndexMetadata.builder(indexName).settings(indexSettings(Version.CURRENT, numberOfShards, 0));
.settings(
Settings.builder()
.put("index.number_of_shards", numberOfShards)
.put("index.number_of_replicas", 0)
.put("index.version.created", Version.CURRENT)
.build()
);
for (int shardId = 0; shardId < numberOfShards; shardId++) { for (int shardId = 0; shardId < numberOfShards; shardId++) {
indexMetadataBuilder.putInSyncAllocationIds(shardId, Set.of(inSyncIds.get(shardId))); indexMetadataBuilder.putInSyncAllocationIds(shardId, Set.of(inSyncIds.get(shardId)));
} }

View file

@ -312,23 +312,13 @@ public class ResizeAllocationDeciderTests extends ESAllocationTestCase {
public void testGetForcedInitialShardAllocationToNodes() { public void testGetForcedInitialShardAllocationToNodes() {
var source = IndexMetadata.builder("source") var source = IndexMetadata.builder("source")
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, "uuid-1"))
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid-1")
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
)
.build(); .build();
var target = IndexMetadata.builder("target") var target = IndexMetadata.builder("target")
.settings( .settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.INDEX_RESIZE_SOURCE_NAME.getKey(), "source")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.INDEX_RESIZE_SOURCE_NAME.getKey(), "source")
.put(IndexMetadata.INDEX_RESIZE_SOURCE_UUID.getKey(), "uuid-1") .put(IndexMetadata.INDEX_RESIZE_SOURCE_UUID.getKey(), "uuid-1")
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid-2") .put(IndexMetadata.SETTING_INDEX_UUID, "uuid-2")
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
) )
.build(); .build();
var clusterState = ClusterState.builder(new ClusterName("test-cluster")) var clusterState = ClusterState.builder(new ClusterName("test-cluster"))

View file

@ -119,11 +119,10 @@ public class ClusterAllocationSimulationTests extends ESAllocationTestCase {
metadataBuilder.put( metadataBuilder.put(
IndexMetadata.builder(indexName) IndexMetadata.builder(indexName)
.settings( .settings(
Settings.builder() indexSettings(Version.CURRENT, shardCount, replicaCount).put(
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, shardCount) IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + ".fake_tier",
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, replicaCount) tier
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) )
.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + ".fake_tier", tier)
) )
.indexWriteLoadForecast(indexWriteLoad) .indexWriteLoadForecast(indexWriteLoad)
.shardSizeInBytesForecast(shardSize) .shardSizeInBytesForecast(shardSize)

View file

@ -329,12 +329,7 @@ public class ClusterInfoSimulatorTests extends ESTestCase {
private static void addIndex(Metadata.Builder metadataBuilder, RoutingTable.Builder routingTableBuilder, ShardRouting shardRouting) { private static void addIndex(Metadata.Builder metadataBuilder, RoutingTable.Builder routingTableBuilder, ShardRouting shardRouting) {
var name = shardRouting.getIndexName(); var name = shardRouting.getIndexName();
var settings = Settings.builder() metadataBuilder.put(IndexMetadata.builder(name).settings(indexSettings(Version.CURRENT, 1, 0)));
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("index.version.created", Version.CURRENT)
.build();
metadataBuilder.put(IndexMetadata.builder(name).settings(settings));
routingTableBuilder.add(IndexRoutingTable.builder(metadataBuilder.get(name).getIndex()).addShard(shardRouting)); routingTableBuilder.add(IndexRoutingTable.builder(metadataBuilder.get(name).getIndex()).addShard(shardRouting));
} }

View file

@ -602,14 +602,7 @@ public class DesiredBalanceComputerTests extends ESTestCase {
var inSyncIds = randomList(shards * (replicas + 1), shards * (replicas + 1), () -> UUIDs.randomBase64UUID(random())); var inSyncIds = randomList(shards * (replicas + 1), shards * (replicas + 1), () -> UUIDs.randomBase64UUID(random()));
var shardSize = randomLongBetween(10_000_000L, 10_000_000_000L); var shardSize = randomLongBetween(10_000_000L, 10_000_000_000L);
var indexMetadataBuilder = IndexMetadata.builder(indexName) var indexMetadataBuilder = IndexMetadata.builder(indexName).settings(indexSettings(Version.CURRENT, shards, replicas));
.settings(
Settings.builder()
.put("index.number_of_shards", shards)
.put("index.number_of_replicas", replicas)
.put("index.version.created", Version.CURRENT)
.build()
);
if (randomBoolean()) { if (randomBoolean()) {
indexMetadataBuilder.shardSizeInBytesForecast(smallShardSizeDeviation(shardSize)); indexMetadataBuilder.shardSizeInBytesForecast(smallShardSizeDeviation(shardSize));
} }
@ -749,14 +742,7 @@ public class DesiredBalanceComputerTests extends ESTestCase {
metadataBuilder.put( metadataBuilder.put(
IndexMetadata.builder(indexName) IndexMetadata.builder(indexName)
.settings( .settings(indexSettings(Version.CURRENT, 1, 1).put("index.routing.allocation.exclude._name", "node-2"))
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put("index.version.created", Version.CURRENT)
.put("index.routing.allocation.exclude._name", "node-2")
.build()
)
); );
var indexId = metadataBuilder.get(indexName).getIndex(); var indexId = metadataBuilder.get(indexName).getIndex();
@ -789,14 +775,7 @@ public class DesiredBalanceComputerTests extends ESTestCase {
metadataBuilder.put( metadataBuilder.put(
IndexMetadata.builder(indexName) IndexMetadata.builder(indexName)
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put("index.routing.allocation.exclude._name", "node-2"))
Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("index.version.created", Version.CURRENT)
.put("index.routing.allocation.exclude._name", "node-2")
.build()
)
); );
var indexId = metadataBuilder.get(indexName).getIndex(); var indexId = metadataBuilder.get(indexName).getIndex();

View file

@ -297,12 +297,8 @@ public class FilterAllocationDeciderTests extends ESAllocationTestCase {
public void testGetForcedInitialShardAllocationToNodes() { public void testGetForcedInitialShardAllocationToNodes() {
var index = IndexMetadata.builder("index") var index = IndexMetadata.builder("index")
.settings( .settings(
Settings.builder() indexSettings(Version.CURRENT, 1, 0).put("index.routing.allocation.initial_recovery._id", "node-1")
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.routing.allocation.initial_recovery._id", "node-1")
.put(IndexMetadata.SETTING_INDEX_UUID, "uuid") .put(IndexMetadata.SETTING_INDEX_UUID, "uuid")
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
) )
.build(); .build();
var clusterState = ClusterState.builder(new ClusterName("test-cluster")) var clusterState = ClusterState.builder(new ClusterName("test-cluster"))

View file

@ -75,14 +75,7 @@ public class NodeReplacementAllocationDeciderTests extends ESAllocationTestCase
private final String idxName = "test-idx"; private final String idxName = "test-idx";
private final String idxUuid = "test-idx-uuid"; private final String idxUuid = "test-idx-uuid";
private final IndexMetadata indexMetadata = IndexMetadata.builder(idxName) private final IndexMetadata indexMetadata = IndexMetadata.builder(idxName)
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, idxUuid))
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, idxUuid)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build()
)
.build(); .build();
public void testNoReplacements() { public void testNoReplacements() {

View file

@ -69,14 +69,7 @@ public class NodeShutdownAllocationDeciderTests extends ESAllocationTestCase {
private final String idxName = "test-idx"; private final String idxName = "test-idx";
private final String idxUuid = "test-idx-uuid"; private final String idxUuid = "test-idx-uuid";
private final IndexMetadata indexMetadata = IndexMetadata.builder(idxName) private final IndexMetadata indexMetadata = IndexMetadata.builder(idxName)
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, idxUuid))
Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_INDEX_UUID, idxUuid)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build()
)
.build(); .build();
private static final List<SingleNodeShutdownMetadata.Type> REMOVE_SHUTDOWN_TYPES = List.of( private static final List<SingleNodeShutdownMetadata.Type> REMOVE_SHUTDOWN_TYPES = List.of(

View file

@ -1066,14 +1066,7 @@ public class ScopedSettingsTests extends ESTestCase {
} }
public static IndexMetadata newIndexMeta(String name, Settings indexSettings) { public static IndexMetadata newIndexMeta(String name, Settings indexSettings) {
Settings build = Settings.builder() return IndexMetadata.builder(name).settings(indexSettings(Version.CURRENT, 1, 0).put(indexSettings)).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(indexSettings)
.build();
IndexMetadata metadata = IndexMetadata.builder(name).settings(build).build();
return metadata;
} }
public void testKeyPattern() { public void testKeyPattern() {

View file

@ -107,14 +107,7 @@ public class ClusterStateUpdatersTests extends ESTestCase {
private IndexMetadata createIndexMetadata(final String name, final Settings settings) { private IndexMetadata createIndexMetadata(final String name, final Settings settings) {
return IndexMetadata.builder(name) return IndexMetadata.builder(name)
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()).put(settings))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(settings)
)
.build(); .build();
} }

View file

@ -33,11 +33,7 @@ import static org.mockito.Mockito.when;
public class DanglingIndicesStateTests extends ESTestCase { public class DanglingIndicesStateTests extends ESTestCase {
private static final Settings indexSettings = Settings.builder() private static final Settings indexSettings = indexSettings(Version.CURRENT, 1, 0).build();
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
public void testDanglingIndicesAreDiscovered() throws Exception { public void testDanglingIndicesAreDiscovered() throws Exception {
try (NodeEnvironment env = newNodeEnvironment()) { try (NodeEnvironment env = newNodeEnvironment()) {

View file

@ -171,16 +171,9 @@ public class GatewayMetaStatePersistedStateTests extends ESTestCase {
return builder.build(); return builder.build();
} }
private IndexMetadata createIndexMetadata(String indexName, int numberOfShards, long version) { private static IndexMetadata createIndexMetadata(String indexName, int numberOfShards, long version) {
return IndexMetadata.builder(indexName) return IndexMetadata.builder(indexName)
.settings( .settings(indexSettings(Version.CURRENT, numberOfShards, 0).put(IndexMetadata.SETTING_INDEX_UUID, indexName).build())
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, indexName)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
)
.version(version) .version(version)
.build(); .build();
} }

View file

@ -45,14 +45,7 @@ public class MetaStateServiceTests extends ESTestCase {
private static IndexMetadata indexMetadata(String name) { private static IndexMetadata indexMetadata(String name) {
return IndexMetadata.builder(name) return IndexMetadata.builder(name)
.settings( .settings(indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()))
Settings.builder()
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build()
)
.build(); .build();
} }

View file

@ -279,12 +279,8 @@ public class PriorityComparatorTests extends ESTestCase {
} }
private static Settings buildSettings(int creationDate, int priority) { private static Settings buildSettings(int creationDate, int priority) {
return Settings.builder() return indexSettings(Version.CURRENT, 1, 0).put(IndexMetadata.SETTING_CREATION_DATE, creationDate)
.put(IndexMetadata.SETTING_CREATION_DATE, creationDate)
.put(IndexMetadata.SETTING_PRIORITY, priority) .put(IndexMetadata.SETTING_PRIORITY, priority)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
} }
} }

View file

@ -220,11 +220,7 @@ public class IndexSettingsTests extends ESTestCase {
public void testNodeSettingsAreContained() { public void testNodeSettingsAreContained() {
final int numShards = randomIntBetween(1, 10); final int numShards = randomIntBetween(1, 10);
final int numReplicas = randomIntBetween(0, 10); final int numReplicas = randomIntBetween(0, 10);
Settings theSettings = Settings.builder() Settings theSettings = indexSettings(numShards, numReplicas).put("index.foo.bar", 0).build();
.put("index.foo.bar", 0)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicas)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
.build();
Settings nodeSettings = Settings.builder().put("index.foo.bar", 43).build(); Settings nodeSettings = Settings.builder().put("index.foo.bar", 43).build();
final AtomicInteger indexValue = new AtomicInteger(0); final AtomicInteger indexValue = new AtomicInteger(0);
@ -236,44 +232,18 @@ public class IndexSettingsTests extends ESTestCase {
assertEquals(0, indexValue.get()); assertEquals(0, indexValue.get());
assertTrue( assertTrue(
settings.updateIndexMetadata( settings.updateIndexMetadata(newIndexMeta("index", indexSettings(numShards, numReplicas + 1).put("index.foo.bar", 42).build()))
newIndexMeta(
"index",
Settings.builder()
.put("index.foo.bar", 42)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicas + 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
.build()
)
)
); );
assertEquals(42, indexValue.get()); assertEquals(42, indexValue.get());
assertSame(nodeSettings, settings.getNodeSettings()); assertSame(nodeSettings, settings.getNodeSettings());
assertTrue( assertTrue(settings.updateIndexMetadata(newIndexMeta("index", indexSettings(numShards, numReplicas + 1).build())));
settings.updateIndexMetadata(
newIndexMeta(
"index",
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicas + 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
.build()
)
)
);
assertEquals(43, indexValue.get()); assertEquals(43, indexValue.get());
} }
public static IndexMetadata newIndexMeta(String name, Settings indexSettings) { public static IndexMetadata newIndexMeta(String name, Settings indexSettings) {
Settings build = Settings.builder() return IndexMetadata.builder(name).settings(indexSettings(Version.CURRENT, 1, 1).put(indexSettings)).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(indexSettings)
.build();
return IndexMetadata.builder(name).settings(build).build();
} }
public void testUpdateDurability() { public void testUpdateDurability() {

View file

@ -469,13 +469,6 @@ public class IndexingSlowLogTests extends ESTestCase {
} }
private IndexMetadata newIndexMeta(String name, Settings indexSettings) { private IndexMetadata newIndexMeta(String name, Settings indexSettings) {
Settings build = Settings.builder() return IndexMetadata.builder(name).settings(indexSettings(Version.CURRENT, 1, 1).put(indexSettings)).build();
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(indexSettings)
.build();
IndexMetadata metadata = IndexMetadata.builder(name).settings(build).build();
return metadata;
} }
} }

Some files were not shown because too many files have changed in this diff Show more