diff --git a/core/src/test/java/org/apache/lucene/queries/MinDocQueryTests.java b/core/src/test/java/org/apache/lucene/queries/MinDocQueryTests.java index 725bafbdfd6..3b9671d195a 100644 --- a/core/src/test/java/org/apache/lucene/queries/MinDocQueryTests.java +++ b/core/src/test/java/org/apache/lucene/queries/MinDocQueryTests.java @@ -44,7 +44,7 @@ public class MinDocQueryTests extends ESTestCase { final int numDocs = randomIntBetween(10, 200); final Document doc = new Document(); final Directory dir = newDirectory(); - final RandomIndexWriter w = new RandomIndexWriter(getRandom(), dir); + final RandomIndexWriter w = new RandomIndexWriter(random(), dir); for (int i = 0; i < numDocs; ++i) { w.addDocument(doc); } diff --git a/core/src/test/java/org/elasticsearch/ESExceptionTests.java b/core/src/test/java/org/elasticsearch/ESExceptionTests.java index ad3f0632019..55b8c3ed4ec 100644 --- a/core/src/test/java/org/elasticsearch/ESExceptionTests.java +++ b/core/src/test/java/org/elasticsearch/ESExceptionTests.java @@ -339,9 +339,9 @@ public class ESExceptionTests extends ESTestCase { } assertArrayEquals(e.getStackTrace(), ex.getStackTrace()); assertTrue(e.getStackTrace().length > 1); - ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), t); - ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), ex); - ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), e); + ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), t); + ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), ex); + ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), e); } } } diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index 69e41910ff5..e5cabd417b8 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -203,7 +203,7 @@ public class BulkProcessorIT extends ESIntegTestCase { //let's make sure that the bulk action limit trips, one single execution will index all the documents .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10), - RandomPicks.randomFrom(getRandom(), ByteSizeUnit.values()))) + RandomPicks.randomFrom(random(), ByteSizeUnit.values()))) .build(); MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkShardRequestTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkShardRequestTests.java index 3ad343e2469..ff1a24d6900 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkShardRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkShardRequestTests.java @@ -26,7 +26,7 @@ import static org.apache.lucene.util.TestUtil.randomSimpleString; public class BulkShardRequestTests extends ESTestCase { public void testToString() { - String index = randomSimpleString(getRandom(), 10); + String index = randomSimpleString(random(), 10); int count = between(1, 100); BulkShardRequest r = new BulkShardRequest(null, new ShardId(index, "ignored", 0), false, new BulkItemRequest[count]); assertEquals("BulkShardRequest to [" + index + "] containing [" + count + "] requests", r.toString()); diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java index 9ea9b340c20..40995ff778b 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java @@ -70,7 +70,7 @@ public class BasicAnalysisBackwardCompatibilityIT extends ESBackcompatTestCase { // cause differences when the random string generated contains these complex characters. To mitigate // the problem, we skip any strings containing these characters. // TODO: only skip strings containing complex chars when comparing against ES <= 1.3.x - input = TestUtil.randomAnalysisString(getRandom(), 100, false); + input = TestUtil.randomAnalysisString(random(), 100, false); matcher = complexUnicodeChars.matcher(input); } while (matcher.find()); @@ -104,7 +104,7 @@ public class BasicAnalysisBackwardCompatibilityIT extends ESBackcompatTestCase { } private String randomAnalyzer() { - PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(getRandom(), PreBuiltAnalyzers.values()); + PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(random(), PreBuiltAnalyzers.values()); return preBuiltAnalyzers.name().toLowerCase(Locale.ROOT); } diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index ae739701593..c26da0e6f1c 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java @@ -319,7 +319,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs]; String[] indexForDoc = new String[docs.length]; for (int i = 0; i < numDocs; i++) { - docs[i] = client().prepareIndex(indexForDoc[i] = RandomPicks.randomFrom(getRandom(), indices), "type1", String.valueOf(i)).setSource("field1", English.intToEnglish(i), "num_int", randomInt(), "num_double", randomDouble()); + docs[i] = client().prepareIndex(indexForDoc[i] = RandomPicks.randomFrom(random(), indices), "type1", String.valueOf(i)).setSource("field1", English.intToEnglish(i), "num_int", randomInt(), "num_double", randomDouble()); } indexRandom(true, docs); for (String index : indices) { diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java index 1c9e607f363..0246ec227dd 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java @@ -63,7 +63,7 @@ public class TransportClientNodesServiceTests extends ESTestCase { TestIteration() { threadPool = new ThreadPool("transport-client-nodes-service-tests"); - transport = new FailAndRetryMockTransport(getRandom()) { + transport = new FailAndRetryMockTransport(random()) { @Override public List getLocalAddresses() { return Collections.emptyList(); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 0745bd38804..017537443a2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -492,7 +492,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase { public IndexMetaData randomCreate(String name) { IndexMetaData.Builder builder = IndexMetaData.builder(name); Settings.Builder settingsBuilder = Settings.builder(); - setRandomIndexSettings(getRandom(), settingsBuilder); + setRandomIndexSettings(random(), settingsBuilder); settingsBuilder.put(randomSettings(Settings.EMPTY)).put(IndexMetaData.SETTING_VERSION_CREATED, randomVersion(random())); builder.settings(settingsBuilder); builder.numberOfShards(randomIntBetween(1, 10)).numberOfReplicas(randomInt(10)); @@ -672,6 +672,6 @@ public class ClusterStateDiffIT extends ESIntegTestCase { * Generates a random name that starts with the given prefix */ private String randomName(String prefix) { - return prefix + Strings.randomBase64UUID(getRandom()); + return prefix + Strings.randomBase64UUID(random()); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java index ba73181ad97..5c91c80f298 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java @@ -72,7 +72,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase { } public void testSerialization() throws Exception { - UnassignedInfo meta = new UnassignedInfo(RandomPicks.randomFrom(getRandom(), UnassignedInfo.Reason.values()), randomBoolean() ? randomAsciiOfLength(4) : null); + UnassignedInfo meta = new UnassignedInfo(RandomPicks.randomFrom(random(), UnassignedInfo.Reason.values()), randomBoolean() ? randomAsciiOfLength(4) : null); BytesStreamOutput out = new BytesStreamOutput(); meta.writeTo(out); out.close(); @@ -273,7 +273,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase { public void testUnassignedDelayOnlyNodeLeftNonNodeLeftReason() throws Exception { EnumSet reasons = EnumSet.allOf(UnassignedInfo.Reason.class); reasons.remove(UnassignedInfo.Reason.NODE_LEFT); - UnassignedInfo unassignedInfo = new UnassignedInfo(RandomPicks.randomFrom(getRandom(), reasons), null); + UnassignedInfo unassignedInfo = new UnassignedInfo(RandomPicks.randomFrom(random(), reasons), null); long delay = unassignedInfo.updateDelay(unassignedInfo.getUnassignedTimeInNanos() + 1, // add 1 tick delay Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "10h").build(), Settings.EMPTY); assertThat(delay, equalTo(0L)); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java index f1495bb5e7b..53a88d333c0 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceConfigurationTests.java @@ -313,7 +313,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase { public void testNoRebalanceOnPrimaryOverload() { Settings.Builder settings = settingsBuilder(); AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(), - new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()), + new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random()), NoopGatewayAllocator.INSTANCE, new ShardsAllocator() { public Map weighShard(RoutingAllocation allocation, ShardRouting shard) { diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java index 0bdab7a1158..582fcfd52c7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/RandomAllocationDeciderTests.java @@ -56,7 +56,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase { * already allocated on a node and balances the cluster to gain optimal * balance.*/ public void testRandomDecisions() { - RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(getRandom()); + RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(random()); AllocationService strategy = new AllocationService(settingsBuilder().build(), new AllocationDeciders(Settings.EMPTY, new HashSet<>(Arrays.asList(new SameShardAllocationDecider(Settings.EMPTY), new ReplicaAfterPrimaryActiveAllocationDecider(Settings.EMPTY), randomAllocationDecider))), NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java index bd1738b59b2..f42920551ff 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationTests.java @@ -155,14 +155,14 @@ public class EnableAllocationTests extends ESAllocationTestCase { public void testEnableClusterBalance() { final boolean useClusterSetting = randomBoolean(); - final Rebalance allowedOnes = RandomPicks.randomFrom(getRandom(), EnumSet.of(Rebalance.PRIMARIES, Rebalance.REPLICAS, Rebalance.ALL)); + final Rebalance allowedOnes = RandomPicks.randomFrom(random(), EnumSet.of(Rebalance.PRIMARIES, Rebalance.REPLICAS, Rebalance.ALL)); Settings build = settingsBuilder() - .put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings + .put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(random(), Rebalance.values())) // index settings override cluster settings .put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10) .build(); ClusterSettings clusterSettings = new ClusterSettings(build, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - AllocationService strategy = createAllocationService(build, clusterSettings, getRandom()); + AllocationService strategy = createAllocationService(build, clusterSettings, random()); Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), Rebalance.NONE).build(); logger.info("Building initial routing table"); @@ -260,11 +260,11 @@ public class EnableAllocationTests extends ESAllocationTestCase { public void testEnableClusterBalanceNoReplicas() { final boolean useClusterSetting = randomBoolean(); Settings build = settingsBuilder() - .put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(getRandom(), Rebalance.values())) // index settings override cluster settings + .put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), useClusterSetting ? Rebalance.NONE: RandomPicks.randomFrom(random(), Rebalance.values())) // index settings override cluster settings .put(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING.getKey(), 3) .build(); ClusterSettings clusterSettings = new ClusterSettings(build, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - AllocationService strategy = createAllocationService(build, clusterSettings, getRandom()); + AllocationService strategy = createAllocationService(build, clusterSettings, random()); Settings indexSettings = useClusterSetting ? Settings.EMPTY : settingsBuilder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), Rebalance.NONE).build(); logger.info("Building initial routing table"); diff --git a/core/src/test/java/org/elasticsearch/common/bytes/BytesReferenceTests.java b/core/src/test/java/org/elasticsearch/common/bytes/BytesReferenceTests.java index b18e6f62d25..60f4983dd19 100644 --- a/core/src/test/java/org/elasticsearch/common/bytes/BytesReferenceTests.java +++ b/core/src/test/java/org/elasticsearch/common/bytes/BytesReferenceTests.java @@ -30,10 +30,10 @@ public class BytesReferenceTests extends ESTestCase { final int len = randomIntBetween(0, randomBoolean() ? 10: 100000); final int offset1 = randomInt(5); final byte[] array1 = new byte[offset1 + len + randomInt(5)]; - getRandom().nextBytes(array1); + random().nextBytes(array1); final int offset2 = randomInt(offset1); final byte[] array2 = Arrays.copyOfRange(array1, offset1 - offset2, array1.length); - + final BytesArray b1 = new BytesArray(array1, offset1, len); final BytesArray b2 = new BytesArray(array2, offset2, len); assertTrue(BytesReference.Helper.bytesEqual(b1, b2)); diff --git a/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java b/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java index 7b34685da7d..90b253ec441 100644 --- a/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java +++ b/core/src/test/java/org/elasticsearch/common/bytes/PagedBytesReferenceTests.java @@ -115,7 +115,7 @@ public class PagedBytesReferenceTests extends ESTestCase { // buffer for bulk reads byte[] origBuf = new byte[length]; - getRandom().nextBytes(origBuf); + random().nextBytes(origBuf); byte[] targetBuf = Arrays.copyOf(origBuf, origBuf.length); // bulk-read 0 bytes: must not modify buffer @@ -172,7 +172,7 @@ public class PagedBytesReferenceTests extends ESTestCase { byte[] pbrBytesWithOffset = Arrays.copyOfRange(pbr.toBytes(), offset, length); // randomized target buffer to ensure no stale slots byte[] targetBytes = new byte[pbrBytesWithOffset.length]; - getRandom().nextBytes(targetBytes); + random().nextBytes(targetBytes); // bulk-read all si.readFully(targetBytes); @@ -574,7 +574,7 @@ public class PagedBytesReferenceTests extends ESTestCase { ReleasableBytesStreamOutput out = new ReleasableBytesStreamOutput(length, bigarrays); try { for (int i = 0; i < length; i++) { - out.writeByte((byte) getRandom().nextInt(1 << 8)); + out.writeByte((byte) random().nextInt(1 << 8)); } } catch (IOException e) { fail("should not happen " + e.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedStreamTestCase.java b/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedStreamTestCase.java index 88f152725d9..0e94f6eaf80 100644 --- a/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedStreamTestCase.java +++ b/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedStreamTestCase.java @@ -46,7 +46,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRandom() throws IOException { - Random r = getRandom(); + Random r = random(); for (int i = 0; i < 10; i++) { byte bytes[] = new byte[TestUtil.nextInt(r, 1, 100000)]; r.nextBytes(bytes); @@ -55,7 +55,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRandomThreads() throws Exception { - final Random r = getRandom(); + final Random r = random(); int threadCount = TestUtil.nextInt(r, 2, 6); Thread[] threads = new Thread[threadCount]; final CountDownLatch startingGun = new CountDownLatch(1); @@ -86,7 +86,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testLineDocs() throws IOException { - Random r = getRandom(); + Random r = random(); LineFileDocs lineFileDocs = new LineFileDocs(r); for (int i = 0; i < 10; i++) { int numDocs = TestUtil.nextInt(r, 1, 200); @@ -101,7 +101,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testLineDocsThreads() throws Exception { - final Random r = getRandom(); + final Random r = random(); int threadCount = TestUtil.nextInt(r, 2, 6); Thread[] threads = new Thread[threadCount]; final CountDownLatch startingGun = new CountDownLatch(1); @@ -138,7 +138,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsL() throws IOException { - Random r = getRandom(); + Random r = random(); for (int i = 0; i < 10; i++) { int numLongs = TestUtil.nextInt(r, 1, 10000); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -161,7 +161,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsLThreads() throws Exception { - final Random r = getRandom(); + final Random r = random(); int threadCount = TestUtil.nextInt(r, 2, 6); Thread[] threads = new Thread[threadCount]; final CountDownLatch startingGun = new CountDownLatch(1); @@ -206,7 +206,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsI() throws IOException { - Random r = getRandom(); + Random r = random(); for (int i = 0; i < 10; i++) { int numInts = TestUtil.nextInt(r, 1, 20000); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -225,7 +225,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsIThreads() throws Exception { - final Random r = getRandom(); + final Random r = random(); int threadCount = TestUtil.nextInt(r, 2, 6); Thread[] threads = new Thread[threadCount]; final CountDownLatch startingGun = new CountDownLatch(1); @@ -266,7 +266,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsS() throws IOException { - Random r = getRandom(); + Random r = random(); for (int i = 0; i < 10; i++) { int numShorts = TestUtil.nextInt(r, 1, 40000); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -283,7 +283,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testMixed() throws IOException { - Random r = getRandom(); + Random r = random(); LineFileDocs lineFileDocs = new LineFileDocs(r); for (int i = 0; i < 2; ++i) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -349,7 +349,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { } public void testRepetitionsSThreads() throws Exception { - final Random r = getRandom(); + final Random r = random(); int threadCount = TestUtil.nextInt(r, 2, 6); Thread[] threads = new Thread[threadCount]; final CountDownLatch startingGun = new CountDownLatch(1); @@ -396,8 +396,8 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { OutputStreamStreamOutput rawOs = new OutputStreamStreamOutput(bos); StreamOutput os = c.streamOutput(rawOs); - Random r = getRandom(); - int bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(getRandom(), 1, 70000); + Random r = random(); + int bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000); int prepadding = r.nextInt(70000); int postpadding = r.nextInt(70000); byte buffer[] = new byte[prepadding + bufferSize + postpadding]; @@ -417,7 +417,7 @@ public abstract class AbstractCompressedStreamTestCase extends ESTestCase { StreamInput in = c.streamInput(compressedIn); // randomize constants again - bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(getRandom(), 1, 70000); + bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000); prepadding = r.nextInt(70000); postpadding = r.nextInt(70000); buffer = new byte[prepadding + bufferSize + postpadding]; diff --git a/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedXContentTestCase.java b/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedXContentTestCase.java index e5d627f35bb..d1c862f8a69 100644 --- a/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedXContentTestCase.java +++ b/core/src/test/java/org/elasticsearch/common/compress/AbstractCompressedXContentTestCase.java @@ -72,7 +72,7 @@ public abstract class AbstractCompressedXContentTestCase extends ESTestCase { Compressor defaultCompressor = CompressorFactory.defaultCompressor(); try { CompressorFactory.setDefaultCompressor(compressor); - Random r = getRandom(); + Random r = random(); for (int i = 0; i < 1000; i++) { String string = TestUtil.randomUnicodeString(r, 10000); // hack to make it detected as YAML diff --git a/core/src/test/java/org/elasticsearch/common/geo/builders/EnvelopeBuilderTests.java b/core/src/test/java/org/elasticsearch/common/geo/builders/EnvelopeBuilderTests.java index c2730f91df6..b5fe3222b73 100644 --- a/core/src/test/java/org/elasticsearch/common/geo/builders/EnvelopeBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/common/geo/builders/EnvelopeBuilderTests.java @@ -72,7 +72,7 @@ public class EnvelopeBuilderTests extends AbstractShapeBuilderTestCase r = newRecycler(limit); Recycler.V o = r.obtain(); assertFresh(o.v()); - getRandom().nextBytes(o.v()); + random().nextBytes(o.v()); o.close(); o = r.obtain(); assertRecycled(o.v()); @@ -166,7 +166,7 @@ public abstract class AbstractRecyclerTestCase extends ESTestCase { assertFresh(data); // randomize & return to pool - getRandom().nextBytes(data); + random().nextBytes(data); o.close(); // verify that recycle() ran diff --git a/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java b/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java index 85c2be77af5..033b4f4ad69 100644 --- a/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java +++ b/core/src/test/java/org/elasticsearch/common/regex/RegexTests.java @@ -31,7 +31,7 @@ public class RegexTests extends ESTestCase { "LITERAL", "COMMENTS", "UNICODE_CHAR_CLASS", "UNICODE_CHARACTER_CLASS"}; int[] flags = new int[]{Pattern.CASE_INSENSITIVE, Pattern.MULTILINE, Pattern.DOTALL, Pattern.UNICODE_CASE, Pattern.CANON_EQ, Pattern.UNIX_LINES, Pattern.LITERAL, Pattern.COMMENTS, Regex.UNICODE_CHARACTER_CLASS}; - Random random = getRandom(); + Random random = random(); int num = 10 + random.nextInt(100); for (int i = 0; i < num; i++) { int numFlags = random.nextInt(flags.length + 1); @@ -63,4 +63,4 @@ public class RegexTests extends ESTestCase { assertTrue(Regex.simpleMatch("fff*******ddd", "fffabcddd")); assertFalse(Regex.simpleMatch("fff******ddd", "fffabcdd")); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/elasticsearch/common/util/BigArraysTests.java b/core/src/test/java/org/elasticsearch/common/util/BigArraysTests.java index 1735515bf3a..3192c8242b5 100644 --- a/core/src/test/java/org/elasticsearch/common/util/BigArraysTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/BigArraysTests.java @@ -235,7 +235,7 @@ public class BigArraysTests extends ESSingleNodeTestCase { public void testByteArrayBulkGet() { final byte[] array1 = new byte[randomIntBetween(1, 4000000)]; - getRandom().nextBytes(array1); + random().nextBytes(array1); final ByteArray array2 = bigArrays.newByteArray(array1.length, randomBoolean()); for (int i = 0; i < array1.length; ++i) { array2.set(i, array1[i]); @@ -252,7 +252,7 @@ public class BigArraysTests extends ESSingleNodeTestCase { public void testByteArrayBulkSet() { final byte[] array1 = new byte[randomIntBetween(1, 4000000)]; - getRandom().nextBytes(array1); + random().nextBytes(array1); final ByteArray array2 = bigArrays.newByteArray(array1.length, randomBoolean()); for (int i = 0; i < array1.length; ) { final int len = Math.min(array1.length - i, randomBoolean() ? randomInt(10) : randomInt(3 * BigArrays.BYTE_PAGE_SIZE)); @@ -315,7 +315,7 @@ public class BigArraysTests extends ESSingleNodeTestCase { // large arrays should be different final byte[] array1 = new byte[randomIntBetween(1, 4000000)]; - getRandom().nextBytes(array1); + random().nextBytes(array1); final int array1Hash = Arrays.hashCode(array1); final ByteArray array2 = byteArrayWithBytes(array1); final int array2Hash = bigArrays.hashCode(array2); diff --git a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java index 01c27a65ab8..8b0051228b4 100644 --- a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java @@ -110,7 +110,7 @@ public class BytesRefHashTests extends ESSingleNodeTestCase { for (int i = 0; i < 797; i++) { String str; do { - str = TestUtil.randomRealisticUnicodeString(getRandom(), 1000); + str = TestUtil.randomRealisticUnicodeString(random(), 1000); } while (str.length() == 0); ref.copyChars(str); long count = hash.size(); @@ -142,7 +142,7 @@ public class BytesRefHashTests extends ESSingleNodeTestCase { for (int i = 0; i < 797; i++) { String str; do { - str = TestUtil.randomRealisticUnicodeString(getRandom(), 1000); + str = TestUtil.randomRealisticUnicodeString(random(), 1000); } while (str.length() == 0); ref.copyChars(str); long count = hash.size(); @@ -181,7 +181,7 @@ public class BytesRefHashTests extends ESSingleNodeTestCase { for (int i = 0; i < 797; i++) { String str; do { - str = TestUtil.randomRealisticUnicodeString(getRandom(), 1000); + str = TestUtil.randomRealisticUnicodeString(random(), 1000); } while (str.length() == 0); ref.copyChars(str); long count = hash.size(); @@ -216,7 +216,7 @@ public class BytesRefHashTests extends ESSingleNodeTestCase { for (int i = 0; i < 797; i++) { String str; do { - str = TestUtil.randomRealisticUnicodeString(getRandom(), 1000); + str = TestUtil.randomRealisticUnicodeString(random(), 1000); } while (str.length() == 0); ref.copyChars(str); long count = hash.size(); diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index f588652ac8c..2f131672880 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -218,7 +218,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { // Simulate a network issue between the unlucky node and elected master node in both directions. - NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(masterNode, unluckyNode, getRandom()); + NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(masterNode, unluckyNode, random()); setDisruptionScheme(networkDisconnect); networkDisconnect.startDisrupting(); @@ -562,7 +562,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { String oldMasterNode = internalCluster().getMasterName(); // a very long GC, but it's OK as we remove the disruption when it has had an effect - SingleNodeDisruption masterNodeDisruption = new IntermittentLongGCDisruption(oldMasterNode, getRandom(), 100, 200, 30000, 60000); + SingleNodeDisruption masterNodeDisruption = new IntermittentLongGCDisruption(oldMasterNode, random(), 100, 200, 30000, 60000); internalCluster().setDisruptionScheme(masterNodeDisruption); masterNodeDisruption.startDisrupting(); @@ -609,7 +609,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { assertMaster(oldMasterNode, nodes); // Simulating a painful gc by suspending all threads for a long time on the current elected master node. - SingleNodeDisruption masterNodeDisruption = new LongGCDisruption(getRandom(), oldMasterNode); + SingleNodeDisruption masterNodeDisruption = new LongGCDisruption(random(), oldMasterNode); // Save the majority side final List majoritySide = new ArrayList<>(nodes); @@ -779,7 +779,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { } // Simulate a network issue between the unlucky node and elected master node in both directions. - NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(masterNode, isolatedNode, getRandom()); + NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(masterNode, isolatedNode, random()); setDisruptionScheme(networkDisconnect); networkDisconnect.startDisrupting(); // Wait until elected master has removed that the unlucky node... @@ -816,7 +816,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { } // Simulate a network issue between the unicast target node and the rest of the cluster - NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(unicastTargetSide, restOfClusterSide, getRandom()); + NetworkDisconnectPartition networkDisconnect = new NetworkDisconnectPartition(unicastTargetSide, restOfClusterSide, random()); setDisruptionScheme(networkDisconnect); networkDisconnect.startDisrupting(); // Wait until elected master has removed that the unlucky node... @@ -955,7 +955,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { public void testClusterFormingWithASlowNode() throws Exception { configureUnicastCluster(3, null, 2); - SlowClusterStateProcessing disruption = new SlowClusterStateProcessing(getRandom(), 0, 0, 1000, 2000); + SlowClusterStateProcessing disruption = new SlowClusterStateProcessing(random(), 0, 0, 1000, 2000); // don't wait for initial state, wat want to add the disruption while the cluster is forming.. internalCluster().startNodesAsync(3, @@ -1035,7 +1035,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { indexRequestBuilderList.add(client().prepareIndex().setIndex("test").setType("doc").setSource("{\"int_field\":1}")); } indexRandom(true, indexRequestBuilderList); - SingleNodeDisruption disruption = new BlockClusterStateProcessing(node_2, getRandom()); + SingleNodeDisruption disruption = new BlockClusterStateProcessing(node_2, random()); internalCluster().setDisruptionScheme(disruption); MockTransportService transportServiceNode2 = (MockTransportService) internalCluster().getInstance(TransportService.class, node_2); @@ -1095,7 +1095,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { ensureYellow(); final String masterNode1 = internalCluster().getMasterName(); - NetworkPartition networkPartition = new NetworkUnresponsivePartition(masterNode1, dataNode.get(), getRandom()); + NetworkPartition networkPartition = new NetworkUnresponsivePartition(masterNode1, dataNode.get(), random()); internalCluster().setDisruptionScheme(networkPartition); networkPartition.startDisrupting(); // We know this will time out due to the partition, we check manually below to not proceed until @@ -1117,9 +1117,9 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { protected NetworkPartition addRandomPartition() { NetworkPartition partition; if (randomBoolean()) { - partition = new NetworkUnresponsivePartition(getRandom()); + partition = new NetworkUnresponsivePartition(random()); } else { - partition = new NetworkDisconnectPartition(getRandom()); + partition = new NetworkDisconnectPartition(random()); } setDisruptionScheme(partition); @@ -1135,9 +1135,9 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { NetworkPartition partition; if (randomBoolean()) { - partition = new NetworkUnresponsivePartition(side1, side2, getRandom()); + partition = new NetworkUnresponsivePartition(side1, side2, random()); } else { - partition = new NetworkDisconnectPartition(side1, side2, getRandom()); + partition = new NetworkDisconnectPartition(side1, side2, random()); } internalCluster().setDisruptionScheme(partition); @@ -1148,10 +1148,10 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { private ServiceDisruptionScheme addRandomDisruptionScheme() { // TODO: add partial partitions List list = Arrays.asList( - new NetworkUnresponsivePartition(getRandom()), - new NetworkDelaysPartition(getRandom()), - new NetworkDisconnectPartition(getRandom()), - new SlowClusterStateProcessing(getRandom()) + new NetworkUnresponsivePartition(random()), + new NetworkDelaysPartition(random()), + new NetworkDisconnectPartition(random()), + new SlowClusterStateProcessing(random()) ); Collections.shuffle(list, random()); setDisruptionScheme(list.get(0)); diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java index 115e5b68ff0..b2c6f121a14 100644 --- a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java @@ -349,7 +349,7 @@ public class MetaDataStateFormatTests extends ESTestCase { @Override protected Directory newDirectory(Path dir) throws IOException { - MockDirectoryWrapper mock = new MockDirectoryWrapper(getRandom(), super.newDirectory(dir)); + MockDirectoryWrapper mock = new MockDirectoryWrapper(random(), super.newDirectory(dir)); closeAfterSuite(mock); return mock; } diff --git a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java index a4a62a8f5e0..7ab136b4772 100644 --- a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java @@ -105,7 +105,7 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { * and find a better copy for the shard. */ public void testAsyncFetchOnAnythingButIndexCreation() { - UnassignedInfo.Reason reason = RandomPicks.randomFrom(getRandom(), EnumSet.complementOf(EnumSet.of(UnassignedInfo.Reason.INDEX_CREATED))); + UnassignedInfo.Reason reason = RandomPicks.randomFrom(random(), EnumSet.complementOf(EnumSet.of(UnassignedInfo.Reason.INDEX_CREATED))); RoutingAllocation allocation = onePrimaryOnNode1And1Replica(yesAllocationDeciders(), Settings.EMPTY, reason); testAllocator.clean(); testAllocator.allocateUnassigned(allocation); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java index f665de6216d..3c1e167fb2c 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java @@ -51,7 +51,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testDefaultAnalyzers() throws IOException { - Version version = VersionUtils.randomVersion(getRandom()); + Version version = VersionUtils.randomVersion(random()); Settings settings = Settings .builder() .put(IndexMetaData.SETTING_VERSION_CREATED, version) @@ -65,7 +65,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testOverrideDefaultAnalyzer() throws IOException { - Version version = VersionUtils.randomVersion(getRandom()); + Version version = VersionUtils.randomVersion(random()); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings("index", settings), Collections.singletonMap("default", analyzerProvider("default")), @@ -76,7 +76,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testOverrideDefaultIndexAnalyzer() { - Version version = VersionUtils.randomVersionBetween(getRandom(), Version.V_5_0_0_alpha1, Version.CURRENT); + Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0_alpha1, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); try { AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings("index", settings), @@ -90,7 +90,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testBackCompatOverrideDefaultIndexAnalyzer() { - Version version = VersionUtils.randomVersionBetween(getRandom(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1)); + Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1)); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings("index", settings), Collections.singletonMap("default_index", analyzerProvider("default_index")), @@ -101,7 +101,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testOverrideDefaultSearchAnalyzer() { - Version version = VersionUtils.randomVersion(getRandom()); + Version version = VersionUtils.randomVersion(random()); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings("index", settings), Collections.singletonMap("default_search", analyzerProvider("default_search")), @@ -112,7 +112,7 @@ public class AnalysisServiceTests extends ESTestCase { } public void testBackCompatOverrideDefaultIndexAndSearchAnalyzer() { - Version version = VersionUtils.randomVersionBetween(getRandom(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1)); + Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_0_0_alpha1)); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); Map analyzers = new HashMap<>(); analyzers.put("default_index", analyzerProvider("default_index")); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java index a6c4bb15c34..741a1b54526 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java @@ -246,11 +246,11 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI // missing value is set to an actual value final String[] values = new String[randomIntBetween(2, 30)]; for (int i = 1; i < values.length; ++i) { - values[i] = TestUtil.randomUnicodeString(getRandom()); + values[i] = TestUtil.randomUnicodeString(random()); } final int numDocs = scaledRandomIntBetween(10, 3072); for (int i = 0; i < numDocs; ++i) { - final String value = RandomPicks.randomFrom(getRandom(), values); + final String value = RandomPicks.randomFrom(random(), values); if (value == null) { writer.addDocument(new Document()); } else { @@ -302,11 +302,11 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI public void testSortMissing(boolean first, boolean reverse) throws IOException { final String[] values = new String[randomIntBetween(2, 10)]; for (int i = 1; i < values.length; ++i) { - values[i] = TestUtil.randomUnicodeString(getRandom()); + values[i] = TestUtil.randomUnicodeString(random()); } final int numDocs = scaledRandomIntBetween(10, 3072); for (int i = 0; i < numDocs; ++i) { - final String value = RandomPicks.randomFrom(getRandom(), values); + final String value = RandomPicks.randomFrom(random(), values); if (value == null) { writer.addDocument(new Document()); } else { @@ -355,7 +355,7 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI public void testNestedSorting(MultiValueMode sortMode) throws IOException { final String[] values = new String[randomIntBetween(2, 20)]; for (int i = 0; i < values.length; ++i) { - values[i] = TestUtil.randomSimpleString(getRandom()); + values[i] = TestUtil.randomSimpleString(random()); } final int numParents = scaledRandomIntBetween(10, 3072); List docs = new ArrayList<>(); @@ -367,14 +367,14 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI final Document child = new Document(); final int numValues = randomInt(3); for (int k = 0; k < numValues; ++k) { - final String value = RandomPicks.randomFrom(getRandom(), values); + final String value = RandomPicks.randomFrom(random(), values); addField(child, "text", value); } docs.add(child); } final Document parent = new Document(); parent.add(new StringField("type", "parent", Store.YES)); - final String value = RandomPicks.randomFrom(getRandom(), values); + final String value = RandomPicks.randomFrom(random(), values); if (value != null) { addField(parent, "text", value); } @@ -400,10 +400,10 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI missingValue = "_last"; break; case 2: - missingValue = new BytesRef(RandomPicks.randomFrom(getRandom(), values)); + missingValue = new BytesRef(RandomPicks.randomFrom(random(), values)); break; default: - missingValue = new BytesRef(TestUtil.randomSimpleString(getRandom())); + missingValue = new BytesRef(TestUtil.randomSimpleString(random())); break; } Query parentFilter = new TermQuery(new Term("type", "parent")); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java index 737d76fec73..5f8beb12424 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/BinaryDVFieldDataTests.java @@ -107,7 +107,7 @@ public class BinaryDVFieldDataTests extends AbstractFieldDataTestCase { private byte[] randomBytes() { int size = randomIntBetween(10, 1000); byte[] bytes = new byte[size]; - getRandom().nextBytes(bytes); + random().nextBytes(bytes); return bytes; } diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java index 9895acdc75d..cc50ba5edfa 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java @@ -39,7 +39,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase { } public void testFilterByFrequency() throws Exception { - Random random = getRandom(); + Random random = random(); for (int i = 0; i < 1000; i++) { Document d = new Document(); d.add(new StringField("id", "" + i, Field.Store.NO)); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java index 03cc8776e23..3f1e367952e 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/ordinals/MultiOrdinalsTests.java @@ -45,7 +45,7 @@ public class MultiOrdinalsTests extends ESTestCase { } public void testRandomValues() throws IOException { - Random random = getRandom(); + Random random = random(); int numDocs = 100 + random.nextInt(1000); int numOrdinals = 1 + random.nextInt(200); int numValues = 100 + random.nextInt(100000); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java index 74fc98fddbe..8ab89e83eca 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java @@ -83,7 +83,7 @@ public class BooleanFieldMapperTests extends ESSingleNodeTestCase { .bytes()); try (Directory dir = new RAMDirectory(); - IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(getRandom())))) { + IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())))) { w.addDocuments(doc.docs()); try (DirectoryReader reader = DirectoryReader.open(w)) { final LeafReader leaf = reader.leaves().get(0).reader(); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index c6577fa4c41..bc45ffc7df5 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -844,7 +844,7 @@ public abstract class AbstractQueryTestCase> } public static String randomGeohash(int minPrecision, int maxPrecision) { - return geohashGenerator.ofStringLength(getRandom(), minPrecision, maxPrecision); + return geohashGenerator.ofStringLength(random(), minPrecision, maxPrecision); } public static class GeohashGenerator extends CodepointSetGenerator { diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java index ca3be781566..7c8e69d6d94 100644 --- a/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilderTests.java @@ -47,7 +47,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase } public void testLocationParsing() throws IOException { - Point point = RandomShapeGenerator.xRandomPoint(getRandom()); + Point point = RandomShapeGenerator.xRandomPoint(random()); Builder pointTestBuilder = new GeohashCellQuery.Builder("pin", new GeoPoint(point.getY(), point.getX())); String pointTest1 = "{\"geohash_cell\": {\"pin\": {\"lat\": " + point.getY() + ",\"lon\": " + point.getX() + "}}}"; assertParsedQuery(pointTest1, pointTestBuilder); diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java index 5a42331c52d..46385f4ecf5 100644 --- a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java @@ -136,7 +136,7 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase docs = new ArrayList<>(numChildren + 1); for (int j = 0; j < numChildren; ++j) { Document doc = new Document(); - doc.add(new StringField("f", TestUtil.randomSimpleString(getRandom(), 2), Field.Store.NO)); + doc.add(new StringField("f", TestUtil.randomSimpleString(random(), 2), Field.Store.NO)); doc.add(new StringField("__type", "child", Field.Store.NO)); docs.add(doc); } @@ -96,7 +96,7 @@ public class NestedSortingTests extends AbstractFieldDataTestCase { IndexSearcher searcher = new IndexSearcher(reader); PagedBytesIndexFieldData indexFieldData1 = getForField("f"); IndexFieldData indexFieldData2 = NoOrdinalsStringFieldDataTests.hideOrdinals(indexFieldData1); - final String missingValue = randomBoolean() ? null : TestUtil.randomSimpleString(getRandom(), 2); + final String missingValue = randomBoolean() ? null : TestUtil.randomSimpleString(random(), 2); final int n = randomIntBetween(1, numDocs + 2); final boolean reverse = randomBoolean(); diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java index aaa1671f84b..b91cf428ee6 100644 --- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java +++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java @@ -608,7 +608,7 @@ public class CorruptedFileIT extends ESIntegTestCase { Index test = state.metaData().index("test").getIndex(); GroupShardsIterator shardIterators = state.getRoutingNodes().getRoutingTable().activePrimaryShardsGrouped(new String[]{"test"}, false); List iterators = iterableAsArrayList(shardIterators); - ShardIterator shardIterator = RandomPicks.randomFrom(getRandom(), iterators); + ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators); ShardRouting shardRouting = shardIterator.nextOrNull(); assertNotNull(shardRouting); assertTrue(shardRouting.primary()); @@ -632,7 +632,7 @@ public class CorruptedFileIT extends ESIntegTestCase { } } pruneOldDeleteGenerations(files); - CorruptionUtils.corruptFile(getRandom(), files.toArray(new Path[0])); + CorruptionUtils.corruptFile(random(), files.toArray(new Path[0])); return shardRouting; } diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java index 0a8cd9a6fe0..94ee490c729 100644 --- a/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java +++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedTranslogIT.java @@ -113,7 +113,7 @@ public class CorruptedTranslogIT extends ESIntegTestCase { GroupShardsIterator shardIterators = state.getRoutingNodes().getRoutingTable().activePrimaryShardsGrouped(new String[]{"test"}, false); final Index test = state.metaData().index("test").getIndex(); List iterators = iterableAsArrayList(shardIterators); - ShardIterator shardIterator = RandomPicks.randomFrom(getRandom(), iterators); + ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators); ShardRouting shardRouting = shardIterator.nextOrNull(); assertNotNull(shardRouting); assertTrue(shardRouting.primary()); @@ -141,7 +141,7 @@ public class CorruptedTranslogIT extends ESIntegTestCase { if (!files.isEmpty()) { int corruptions = randomIntBetween(5, 20); for (int i = 0; i < corruptions; i++) { - fileToCorrupt = RandomPicks.randomFrom(getRandom(), files); + fileToCorrupt = RandomPicks.randomFrom(random(), files); try (FileChannel raf = FileChannel.open(fileToCorrupt, StandardOpenOption.READ, StandardOpenOption.WRITE)) { // read raf.position(randomIntBetween(0, (int) Math.min(Integer.MAX_VALUE, raf.size() - 1))); diff --git a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java index f4a70a2afa4..23925f574ff 100644 --- a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java +++ b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java @@ -132,7 +132,7 @@ public class IndexActionIT extends ESIntegTestCase { final AtomicIntegerArray createdCounts = new AtomicIntegerArray(docCount); ExecutorService threadPool = Executors.newFixedThreadPool(threadCount); List> tasks = new ArrayList<>(taskCount); - final Random random = getRandom(); + final Random random = random(); for (int i=0;i< taskCount; i++ ) { tasks.add(new Callable() { @Override diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/RecoverySourceHandlerTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/RecoverySourceHandlerTests.java index 280aac07e32..818fa28a214 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/RecoverySourceHandlerTests.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/RecoverySourceHandlerTests.java @@ -150,7 +150,7 @@ public class RecoverySourceHandlerTests extends ESTestCase { metas.add(md); } - CorruptionUtils.corruptFile(getRandom(), FileSystemUtils.files(tempDir, (p) -> + CorruptionUtils.corruptFile(random(), FileSystemUtils.files(tempDir, (p) -> (p.getFileName().toString().equals("write.lock") || p.getFileName().toString().startsWith("extra")) == false)); Store targetStore = newStore(createTempDir(), false); diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java index 8ce4229172f..efdae8106a4 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java @@ -187,7 +187,7 @@ public class RareClusterStateIT extends ESIntegTestCase { nodes.remove(internalCluster().getMasterName()); // block none master node. - BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(nodes.iterator().next(), getRandom()); + BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(nodes.iterator().next(), random()); internalCluster().setDisruptionScheme(disruption); logger.info("--> indexing a doc"); index("test", "type", "1"); @@ -247,7 +247,7 @@ public class RareClusterStateIT extends ESIntegTestCase { } // Block cluster state processing where our shard is - BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(otherNode, getRandom()); + BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(otherNode, random()); internalCluster().setDisruptionScheme(disruption); disruption.startDisrupting(); @@ -365,7 +365,7 @@ public class RareClusterStateIT extends ESIntegTestCase { } // Block cluster state processing on the replica - BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(otherNode, getRandom()); + BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(otherNode, random()); internalCluster().setDisruptionScheme(disruption); disruption.startDisrupting(); final AtomicReference putMappingResponse = new AtomicReference<>(); diff --git a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java index 5fca4fa37ec..492c78842b6 100644 --- a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java +++ b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java @@ -592,7 +592,7 @@ public class IndexStatsIT extends ESIntegTestCase { assertThat(isSet(flag, stats.getPrimaries()), equalTo(true)); assertThat(isSet(flag, stats.getTotal()), equalTo(true)); } - Random random = getRandom(); + Random random = random(); EnumSet flags = EnumSet.noneOf(Flag.class); for (Flag flag : values) { if (random.nextBoolean()) { @@ -638,7 +638,7 @@ public class IndexStatsIT extends ESIntegTestCase { flags.set(flag, true); } assertThat(flags.anySet(), equalTo(true)); - Random random = getRandom(); + Random random = random(); flags.set(values[random.nextInt(values.length)], false); assertThat(flags.anySet(), equalTo(true)); diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java index 84d86324fee..4251241c62e 100644 --- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java @@ -140,7 +140,7 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase { logger.info("--> move shard from node_1 to node_3, and wait for relocation to finish"); if (randomBoolean()) { // sometimes add cluster-state delay to trigger observers in IndicesStore.ShardActiveRequestHandler - SingleNodeDisruption disruption = new BlockClusterStateProcessing(node_3, getRandom()); + SingleNodeDisruption disruption = new BlockClusterStateProcessing(node_3, random()); internalCluster().setDisruptionScheme(disruption); MockTransportService transportServiceNode3 = (MockTransportService) internalCluster().getInstance(TransportService.class, node_3); CountDownLatch beginRelocationLatch = new CountDownLatch(1); diff --git a/core/src/test/java/org/elasticsearch/search/MultiValueModeTests.java b/core/src/test/java/org/elasticsearch/search/MultiValueModeTests.java index 8c18d1dd74b..a4837e382ac 100644 --- a/core/src/test/java/org/elasticsearch/search/MultiValueModeTests.java +++ b/core/src/test/java/org/elasticsearch/search/MultiValueModeTests.java @@ -369,7 +369,7 @@ public class MultiValueModeTests extends ESTestCase { final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs); for (int i = 0; i < array.length; ++i) { if (randomBoolean()) { - array[i] = new BytesRef(RandomStrings.randomAsciiOfLength(getRandom(), 8)); + array[i] = new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8)); if (docsWithValue != null) { docsWithValue.set(i); } @@ -399,7 +399,7 @@ public class MultiValueModeTests extends ESTestCase { for (int i = 0; i < numDocs; ++i) { final BytesRef[] values = new BytesRef[randomInt(4)]; for (int j = 0; j < values.length; ++j) { - values[j] = new BytesRef(RandomStrings.randomAsciiOfLength(getRandom(), 8)); + values[j] = new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8)); } Arrays.sort(values); array[i] = values; @@ -429,7 +429,7 @@ public class MultiValueModeTests extends ESTestCase { } private void verify(SortedBinaryDocValues values, int maxDoc) { - for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(getRandom(), 8)) }) { + for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8)) }) { for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) { final BinaryDocValues selected = mode.select(values, missingValue); for (int i = 0; i < maxDoc; ++i) { @@ -463,7 +463,7 @@ public class MultiValueModeTests extends ESTestCase { } private void verify(SortedBinaryDocValues values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException { - for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(getRandom(), 8)) }) { + for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8)) }) { for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) { final BinaryDocValues selected = mode.select(values, missingValue, rootDocs, new BitSetIterator(innerDocs, 0L), maxDoc); int prevRoot = -1; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java index 698882c5cde..bb9e2f4b328 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorParsingTests.java @@ -260,7 +260,7 @@ public class AggregatorParsingTests extends ESTestCase { public void testInvalidAggregationName() throws Exception { Matcher matcher = Pattern.compile("[^\\[\\]>]+").matcher(""); String name; - Random rand = getRandom(); + Random rand = random(); int len = randomIntBetween(1, 5); char[] word = new char[len]; while (true) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceRangeTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceRangeTests.java index b1fa01c5f19..89dd3e3b137 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceRangeTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceRangeTests.java @@ -32,7 +32,7 @@ public class GeoDistanceRangeTests extends BaseAggregationTestCase cities = new ArrayList<>(); - Random random = getRandom(); + Random random = random(); expectedDocCountsForGeoHash = new ObjectIntHashMap<>(numDocs * 2); for (int i = 0; i < numDocs; i++) { //generate random point diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java index e6b0981f544..4f3b3db7c94 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java @@ -139,7 +139,7 @@ public class ScriptValuesTests extends ESTestCase { for (int i = 0; i < values.length; ++i) { String[] strings = new String[randomInt(8)]; for (int j = 0; j < strings.length; ++j) { - strings[j] = RandomStrings.randomAsciiOfLength(getRandom(), 5); + strings[j] = RandomStrings.randomAsciiOfLength(random(), 5); } Arrays.sort(strings); values[i] = strings; diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java index 83e89592b8e..ccc4909155c 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java @@ -567,7 +567,7 @@ public class GeoFilterIT extends ESIntegTestCase { } protected static String randomhash(int length) { - return randomhash(getRandom(), length); + return randomhash(random(), length); } protected static String randomhash(Random random) { @@ -575,7 +575,7 @@ public class GeoFilterIT extends ESIntegTestCase { } protected static String randomhash() { - return randomhash(getRandom()); + return randomhash(random()); } protected static String randomhash(Random random, int length) { diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java index d124fcf6386..0fe90f133b5 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java @@ -297,7 +297,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { public void testShapeFilterWithRandomGeoCollection() throws Exception { // Create a random geometry collection. - GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(getRandom()); + GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(random()); logger.info("Created Random GeometryCollection containing {} shapes", gcb.numShapes()); @@ -319,8 +319,8 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { public void testContainsShapeQuery() throws Exception { // Create a random geometry collection. - Rectangle mbr = xRandomRectangle(getRandom(), xRandomPoint(getRandom()), true); - GeometryCollectionBuilder gcb = createGeometryCollectionWithin(getRandom(), mbr); + Rectangle mbr = xRandomRectangle(random(), xRandomPoint(random()), true); + GeometryCollectionBuilder gcb = createGeometryCollectionWithin(random(), mbr); client().admin().indices().prepareCreate("test").addMapping("type", "location", "type=geo_shape,tree=quadtree" ) .execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java index fa8caaf0ed3..6839188ca4a 100644 --- a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java @@ -2030,7 +2030,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { refresh(); final int iters = scaledRandomIntBetween(20, 30); for (int i = 0; i < iters; i++) { - String highlighterType = rarely() ? null : RandomPicks.randomFrom(getRandom(), highlighterTypes); + String highlighterType = rarely() ? null : RandomPicks.randomFrom(random(), highlighterTypes); MultiMatchQueryBuilder.Type[] supportedQueryTypes; if ("postings".equals(highlighterType)) { //phrase_prefix is not supported by postings highlighter, as it rewrites against an empty reader, the prefix will never match any term @@ -2038,7 +2038,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { } else { supportedQueryTypes = MultiMatchQueryBuilder.Type.values(); } - MultiMatchQueryBuilder.Type matchQueryType = RandomPicks.randomFrom(getRandom(), supportedQueryTypes); + MultiMatchQueryBuilder.Type matchQueryType = RandomPicks.randomFrom(random(), supportedQueryTypes); final MultiMatchQueryBuilder multiMatchQueryBuilder = multiMatchQuery("the quick brown fox", "field1", "field2").type(matchQueryType); SearchSourceBuilder source = searchSource() diff --git a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java index 8b3df394479..e480c5369bb 100644 --- a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java @@ -130,7 +130,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { fill(lastNames, "Captain", between(3, 7)); fillRandom(lastNames, between(30, 40)); for (int i = 0; i < numDocs; i++) { - String first = RandomPicks.randomFrom(getRandom(), firstNames); + String first = RandomPicks.randomFrom(random(), firstNames); String last = randomPickExcept(lastNames, first); builders.add(client().prepareIndex("test", "test", "" + i).setSource( "full_name", first + " " + last, @@ -245,11 +245,11 @@ public class MultiMatchQueryIT extends ESIntegTestCase { // check if it's equivalent to a match query. int numIters = scaledRandomIntBetween(10, 100); for (int i = 0; i < numIters; i++) { - String field = RandomPicks.randomFrom(getRandom(), fields); + String field = RandomPicks.randomFrom(random(), fields); int numTerms = randomIntBetween(1, query.length); StringBuilder builder = new StringBuilder(); for (int j = 0; j < numTerms; j++) { - builder.append(RandomPicks.randomFrom(getRandom(), query)).append(" "); + builder.append(RandomPicks.randomFrom(random(), query)).append(" "); } MultiMatchQueryBuilder multiMatchQueryBuilder = randomizeType(multiMatchQuery(builder.toString(), field)); SearchResponse multiMatchResp = client().prepareSearch("test") @@ -661,7 +661,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { public T randomPickExcept(List fromList, T butNot) { while (true) { - T t = RandomPicks.randomFrom(getRandom(), fromList); + T t = RandomPicks.randomFrom(random(), fromList); if (t.equals(butNot)) { continue; } diff --git a/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java b/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java index 9643f248d3e..5bbae82b7d7 100644 --- a/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java +++ b/core/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java @@ -73,7 +73,7 @@ public class QueryPhaseTests extends ESTestCase { private void countTestCase(boolean withDeletions) throws Exception { Directory dir = newDirectory(); IndexWriterConfig iwc = newIndexWriterConfig().setMergePolicy(NoMergePolicy.INSTANCE); - RandomIndexWriter w = new RandomIndexWriter(getRandom(), dir, iwc); + RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc); final int numDocs = scaledRandomIntBetween(100, 200); for (int i = 0; i < numDocs; ++i) { Document doc = new Document(); diff --git a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index 271d1f4aadf..3119a6602b9 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -206,7 +206,7 @@ public class SearchQueryIT extends ESIntegTestCase { // see #3521 public void testConstantScoreQuery() throws Exception { - Random random = getRandom(); + Random random = random(); createIndex("test"); indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), client().prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox")); @@ -218,11 +218,11 @@ public class SearchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery( boolQuery().must(matchAllQuery()).must( - constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + getRandom().nextFloat()))).get(); + constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + random().nextFloat()))).get(); assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).score())); - client().prepareSearch("test").setQuery(constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + getRandom().nextFloat())).get(); + client().prepareSearch("test").setQuery(constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + random().nextFloat())).get(); assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).score())); diff --git a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java index ed7ee493c31..0ece1e5d83e 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java @@ -203,7 +203,7 @@ public class DuelScrollIT extends ESIntegTestCase { } sort.order(randomBoolean() ? SortOrder.ASC : SortOrder.DESC); - SearchType searchType = RandomPicks.randomFrom(getRandom(), Arrays.asList(searchTypes)); + SearchType searchType = RandomPicks.randomFrom(random(), Arrays.asList(searchTypes)); logger.info("numDocs={}, scrollRequestSize={}, sort={}, searchType={}", numDocs, scrollRequestSize, sort, searchType); return new TestContext(numDocs, scrollRequestSize, sort, searchType); diff --git a/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java b/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java index 445f2a66e0f..97c592deb9b 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java @@ -221,7 +221,7 @@ public class FieldSortIT extends ESIntegTestCase { } public void testRandomSorting() throws IOException, InterruptedException, ExecutionException { - Random random = getRandom(); + Random random = random(); assertAcked(prepareCreate("test") .addMapping("type", XContentFactory.jsonBuilder() diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java index 378a6a4536e..f13518dc3fb 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java @@ -54,13 +54,13 @@ public class GeoDistanceSortBuilderTests extends AbstractSortTestCase contextMappings = null; public CompletionMappingBuilder searchAnalyzer(String searchAnalyzer) { diff --git a/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java index 256d44769a0..db5902c70f4 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java @@ -55,9 +55,9 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke @SuppressCodecs("*") // requires custom completion format public class ContextCompletionSuggestSearchIT extends ESIntegTestCase { - private final String INDEX = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); - private final String TYPE = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); - private final String FIELD = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); + private final String INDEX = RandomStrings.randomAsciiOfLength(random(), 10).toLowerCase(Locale.ROOT); + private final String TYPE = RandomStrings.randomAsciiOfLength(random(), 10).toLowerCase(Locale.ROOT); + private final String FIELD = RandomStrings.randomAsciiOfLength(random(), 10).toLowerCase(Locale.ROOT); @Override protected int numberOfReplicas() { diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java index 5dbd082ec8c..229fc865404 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggesterBuilderTests.java @@ -145,7 +145,7 @@ public class CompletionSuggesterBuilderTests extends AbstractSuggestionBuilderTe * Test that a malformed JSON suggestion request fails. */ public void testMalformedJsonRequestPayload() throws Exception { - final String field = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); + final String field = RandomStrings.randomAsciiOfLength(random(), 10).toLowerCase(Locale.ROOT); final String payload = "{\n" + " \"bad-payload\" : { \n" + " \"prefix\" : \"sug\",\n" + diff --git a/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java index df576169f3f..588957137ff 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java @@ -151,7 +151,7 @@ public class TermSuggestionBuilderTests extends AbstractSuggestionBuilderTestCas assertEquals("suggestion field name is empty", e.getMessage()); TermSuggestionBuilder builder = new TermSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); - + // test invalid accuracy values expectThrows(IllegalArgumentException.class, () -> builder.accuracy(-0.5f)); expectThrows(IllegalArgumentException.class, () -> builder.accuracy(1.1f)); @@ -206,7 +206,7 @@ public class TermSuggestionBuilderTests extends AbstractSuggestionBuilderTestCas } public void testMalformedJson() { - final String field = RandomStrings.randomAsciiOfLength(getRandom(), 10).toLowerCase(Locale.ROOT); + final String field = RandomStrings.randomAsciiOfLength(random(), 10).toLowerCase(Locale.ROOT); String suggest = "{\n" + " \"bad-payload\" : {\n" + " \"text\" : \"the amsterdma meetpu\",\n" + diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java index b3f466cdcc8..bb95d10f181 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotBackwardsCompatibilityIT.java @@ -72,11 +72,11 @@ public class SnapshotBackwardsCompatibilityIT extends ESBackcompatTestCase { logger.info("--> indexing some data"); IndexRequestBuilder[] buildersBefore = new IndexRequestBuilder[randomIntBetween(10, 200)]; for (int i = 0; i < buildersBefore.length; i++) { - buildersBefore[i] = client().prepareIndex(RandomPicks.randomFrom(getRandom(), indicesBefore), "foo", Integer.toString(i)).setSource("{ \"foo\" : \"bar\" } "); + buildersBefore[i] = client().prepareIndex(RandomPicks.randomFrom(random(), indicesBefore), "foo", Integer.toString(i)).setSource("{ \"foo\" : \"bar\" } "); } IndexRequestBuilder[] buildersAfter = new IndexRequestBuilder[randomIntBetween(10, 200)]; for (int i = 0; i < buildersAfter.length; i++) { - buildersAfter[i] = client().prepareIndex(RandomPicks.randomFrom(getRandom(), indicesBefore), "bar", Integer.toString(i)).setSource("{ \"foo\" : \"bar\" } "); + buildersAfter[i] = client().prepareIndex(RandomPicks.randomFrom(random(), indicesBefore), "bar", Integer.toString(i)).setSource("{ \"foo\" : \"bar\" } "); } indexRandom(true, buildersBefore); indexRandom(true, buildersAfter); @@ -97,7 +97,7 @@ public class SnapshotBackwardsCompatibilityIT extends ESBackcompatTestCase { int howMany = randomIntBetween(1, buildersBefore.length); for (int i = 0; i < howMany; i++) { - IndexRequestBuilder indexRequestBuilder = RandomPicks.randomFrom(getRandom(), buildersBefore); + IndexRequestBuilder indexRequestBuilder = RandomPicks.randomFrom(random(), buildersBefore); IndexRequest request = indexRequestBuilder.request(); client().prepareDelete(request.index(), request.type(), request.id()).get(); } @@ -144,7 +144,7 @@ public class SnapshotBackwardsCompatibilityIT extends ESBackcompatTestCase { // Test restore after index deletion logger.info("--> delete indices"); - String index = RandomPicks.randomFrom(getRandom(), indices); + String index = RandomPicks.randomFrom(random(), indices); cluster().wipeIndices(index); logger.info("--> restore one index after deletion"); restoreSnapshotResponse = client().admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-2").setWaitForCompletion(true).setIndices(index).execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 7313d880a63..86d5ca09fde 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -95,9 +95,9 @@ public class TribeIT extends ESIntegTestCase { }; cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(), randomLong(), createTempDir(), 2, 2, - Strings.randomBase64UUID(getRandom()), nodeConfigurationSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, Collections.emptyList(), Function.identity()); + Strings.randomBase64UUID(random()), nodeConfigurationSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, Collections.emptyList(), Function.identity()); - cluster2.beforeTest(getRandom(), 0.1); + cluster2.beforeTest(random(), 0.1); cluster2.ensureAtLeastNumDataNodes(2); } diff --git a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index 4e319c65bac..5787df3cd72 100644 --- a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -350,7 +350,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { private IDSource getRandomIDs() { IDSource ids; - final Random random = getRandom(); + final Random random = random(); switch (random.nextInt(6)) { case 0: // random simple @@ -516,7 +516,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { newSettings.put("index.gc_deletes", "1000000h"); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(newSettings).execute().actionGet()); - Random random = getRandom(); + Random random = random(); // Generate random IDs: IDSource idSource = getRandomIDs(); @@ -596,7 +596,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { public void run() { try { //final Random threadRandom = RandomizedContext.current().getRandom(); - final Random threadRandom = getRandom(); + final Random threadRandom = random(); startingGun.await(); while (true) { diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java index 738b4c4a844..e00ac3320d1 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java @@ -84,7 +84,7 @@ public class MinDocCountTests extends AbstractTermsTestCase { for (int i = 0; i < cardinality; ++i) { String stringTerm; do { - stringTerm = RandomStrings.randomAsciiOfLength(getRandom(), 8); + stringTerm = RandomStrings.randomAsciiOfLength(random(), 8); } while (!stringTerms.add(stringTerm)); long longTerm; do { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java index 34e8c8c18ca..d7d5df54240 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java @@ -73,7 +73,7 @@ public abstract class ESAllocationTestCase extends ESTestCase { } public static MockAllocationService createAllocationService(Settings settings) { - return createAllocationService(settings, getRandom()); + return createAllocationService(settings, random()); } public static MockAllocationService createAllocationService(Settings settings, Random random) { @@ -88,13 +88,13 @@ public abstract class ESAllocationTestCase extends ESTestCase { public static MockAllocationService createAllocationService(Settings settings, ClusterInfoService clusterInfoService) { return new MockAllocationService(settings, - randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()), + randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random()), NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(settings), clusterInfoService); } public static MockAllocationService createAllocationService(Settings settings, GatewayAllocator gatewayAllocator) { return new MockAllocationService(settings, - randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), getRandom()), + randomAllocationDeciders(settings, new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random()), gatewayAllocator, new BalancedShardsAllocator(settings), EmptyClusterInfoService.INSTANCE); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 6920ba4a8e0..e9096275d5d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -345,7 +345,7 @@ public abstract class ESIntegTestCase extends ESTestCase { default: fail("Unknown Scope: [" + currentClusterScope + "]"); } - cluster().beforeTest(getRandom(), getPerTestTransportClientRatio()); + cluster().beforeTest(random(), getPerTestTransportClientRatio()); cluster().wipe(excludeTemplates()); randomIndexTemplate(); } @@ -367,10 +367,10 @@ public abstract class ESIntegTestCase extends ESTestCase { // TODO move settings for random directory etc here into the index based randomized settings. if (cluster().size() > 0) { Settings.Builder randomSettingsBuilder = - setRandomIndexSettings(getRandom(), Settings.builder()); + setRandomIndexSettings(random(), Settings.builder()); if (isInternalCluster()) { // this is only used by mock plugins and if the cluster is not internal we just can't set it - randomSettingsBuilder.put(INDEX_TEST_SEED_SETTING.getKey(), getRandom().nextLong()); + randomSettingsBuilder.put(INDEX_TEST_SEED_SETTING.getKey(), random().nextLong()); } randomSettingsBuilder.put(SETTING_NUMBER_OF_SHARDS, numberOfShards()) @@ -609,7 +609,7 @@ public abstract class ESIntegTestCase extends ESTestCase { } Client client = cluster().client(); if (frequently()) { - client = new RandomizingClient(client, getRandom()); + client = new RandomizingClient(client, random()); } return client; } @@ -617,7 +617,7 @@ public abstract class ESIntegTestCase extends ESTestCase { public static Client dataNodeClient() { Client client = internalCluster().dataNodeClient(); if (frequently()) { - client = new RandomizingClient(client, getRandom()); + client = new RandomizingClient(client, random()); } return client; } @@ -1318,7 +1318,7 @@ public abstract class ESIntegTestCase extends ESTestCase { */ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean maybeFlush, List builders) throws InterruptedException, ExecutionException { - Random random = getRandom(); + Random random = random(); Set indicesSet = new HashSet<>(); for (IndexRequestBuilder builder : builders) { indicesSet.add(builder.request().index()); @@ -1992,7 +1992,7 @@ public abstract class ESIntegTestCase extends ESTestCase { * of the provided index. */ protected String routingKeyForShard(String index, String type, int shard) { - return internalCluster().routingKeyForShard(resolveIndex(index), type, shard, getRandom()); + return internalCluster().routingKeyForShard(resolveIndex(index), type, shard, random()); } /** diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index d2cc23349fc..23ae1d514ee 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -208,16 +208,9 @@ public abstract class ESTestCase extends LuceneTestCase { // Test facilities and facades for subclasses. // ----------------------------------------------------------------- - // TODO: replaces uses of getRandom() with random() // TODO: decide on one set of naming for between/scaledBetween and remove others // TODO: replace frequently() with usually() - /** Shortcut for {@link RandomizedContext#getRandom()}. Use {@link #random()} instead. */ - public static Random getRandom() { - // TODO: replace uses of this function with random() - return random(); - } - /** * Returns a "scaled" random number between min and max (inclusive). * diff --git a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java index b1ce97374a4..af16c2a888c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java +++ b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java @@ -36,7 +36,7 @@ public class NetworkPartitionIT extends ESIntegTestCase { public void testNetworkPartitionWithNodeShutdown() throws IOException { internalCluster().ensureAtLeastNumDataNodes(2); String[] nodeNames = internalCluster().getNodeNames(); - NetworkPartition networkPartition = new NetworkUnresponsivePartition(nodeNames[0], nodeNames[1], getRandom()); + NetworkPartition networkPartition = new NetworkUnresponsivePartition(nodeNames[0], nodeNames[1], random()); internalCluster().setDisruptionScheme(networkPartition); networkPartition.startDisrupting(); internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodeNames[0]));