From f56ea46190aa3f16c03ee4154ba28639300f3175 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Mon, 3 Dec 2018 12:53:36 -0700 Subject: [PATCH] Fix occasional failure in deprecation test Sometimes this test could end up trying to create an index with a negative or zero number of shards, which fails. This fixes the test. --- .../xpack/deprecation/ClusterDeprecationChecksTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java index f2cdf401fbb0..dc9611c5e717 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java @@ -25,7 +25,7 @@ public class ClusterDeprecationChecksTests extends ESTestCase { public void testCheckShardLimit() { - int shardsPerNode = randomIntBetween(1, 10000); + int shardsPerNode = randomIntBetween(2, 10000); int nodeCount = randomIntBetween(1, 10); int maxShardsInCluster = shardsPerNode * nodeCount; int currentOpenShards = maxShardsInCluster + randomIntBetween(0, 100); @@ -59,7 +59,7 @@ public void testCheckShardLimit() { MetaData goodMetaData = MetaData.builder(metaData).put(IndexMetaData.builder("test") .settings(settings(Version.CURRENT)) .numberOfReplicas(0) - .numberOfShards(maxShardsInCluster - randomIntBetween(1, 100))).build(); + .numberOfShards(maxShardsInCluster - randomIntBetween(1, (maxShardsInCluster - 1)))).build(); ClusterState goodState = ClusterState.builder(ClusterName.DEFAULT) .metaData(goodMetaData).nodes(state.nodes()).build(); issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(goodState));