upgrade randomized-testing to 2.1.1
Note that the standard `atLeast` implementation has now Integer.MAX_VALUE as upper bound, thus it behaves differently from what we expect in our tests, as we never expect the upper bound to be that high. Added our own `atLeast` to `AbstractRandomizedTest` so that it has the expected behaviour with a reasonable upper bound. See https://github.com/carrotsearch/randomizedtesting/issues/131
This commit is contained in:
parent
767bef0596
commit
d80dd00424
4
pom.xml
4
pom.xml
|
@ -48,7 +48,7 @@
|
|||
<dependency>
|
||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||
<artifactId>randomizedtesting-runner</artifactId>
|
||||
<version>2.0.15</version>
|
||||
<version>2.1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -356,7 +356,7 @@
|
|||
<plugin>
|
||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||
<artifactId>junit4-maven-plugin</artifactId>
|
||||
<version>2.0.15</version>
|
||||
<version>2.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>tests</id>
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BlendedTermQueryTest extends ElasticsearchLuceneTestCase {
|
|||
d.add(new TextField("surname", surNames[i], Field.Store.NO));
|
||||
w.addDocument(d);
|
||||
}
|
||||
int iters = atLeast(25);
|
||||
int iters = scaledRandomIntBetween(25, 100);
|
||||
for (int j = 0; j < iters; j++) {
|
||||
Document d = new Document();
|
||||
d.add(new TextField("id", Integer.toString(firstNames.length + j), Field.Store.YES));
|
||||
|
@ -123,7 +123,7 @@ public class BlendedTermQueryTest extends ElasticsearchLuceneTestCase {
|
|||
d.add(new Field("song", song[i], ft));
|
||||
w.addDocument(d);
|
||||
}
|
||||
int iters = atLeast(25);
|
||||
int iters = scaledRandomIntBetween(25, 100);
|
||||
for (int j = 0; j < iters; j++) {
|
||||
Document d = new Document();
|
||||
d.add(new TextField("id", Integer.toString(username.length + j), Field.Store.YES));
|
||||
|
@ -171,7 +171,7 @@ public class BlendedTermQueryTest extends ElasticsearchLuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testBasics() {
|
||||
final int iters = atLeast(5);
|
||||
final int iters = scaledRandomIntBetween(5, 25);
|
||||
for (int j = 0; j < iters; j++) {
|
||||
String[] fields = new String[1 + random().nextInt(10)];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
|
@ -210,7 +210,7 @@ public class BlendedTermQueryTest extends ElasticsearchLuceneTestCase {
|
|||
@Test
|
||||
public void testExtractTerms() {
|
||||
Set<Term> terms = new HashSet<Term>();
|
||||
int num = atLeast(1);
|
||||
int num = scaledRandomIntBetween(1, 10);
|
||||
for (int i = 0; i < num; i++) {
|
||||
terms.add(new Term(_TestUtil.randomRealisticUnicodeString(random(), 1, 10), _TestUtil.randomRealisticUnicodeString(random(), 1, 10)));
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ public class CustomPostingsHighlighterTests extends ElasticsearchLuceneTestCase
|
|||
Snippet[] snippets = highlighter.highlightDoc("body", filteredQueryTerms, searcher, docId, 5);
|
||||
assertThat(snippets.length, equalTo(0));
|
||||
|
||||
highlighter = new CustomPostingsHighlighter(passageFormatter, values, true, Integer.MAX_VALUE - 1, atLeast(1));
|
||||
highlighter = new CustomPostingsHighlighter(passageFormatter, values, true, Integer.MAX_VALUE - 1, scaledRandomIntBetween(1, 10));
|
||||
snippets = highlighter.highlightDoc("body", filteredQueryTerms, searcher, docId, 5);
|
||||
assertThat(snippets.length, equalTo(1));
|
||||
assertThat(snippets[0].getText(), equalTo("This is a test."));
|
||||
|
|
|
@ -1484,7 +1484,7 @@ public class XPostingsHighlighterTests extends ElasticsearchLuceneTestCase {
|
|||
FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
|
||||
offsetsType.setIndexOptions(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
|
||||
|
||||
int numDocs = atLeast(100);
|
||||
int numDocs = scaledRandomIntBetween(100, 1000);
|
||||
for(int i=0;i<numDocs;i++) {
|
||||
Document doc = new Document();
|
||||
String content = "the answer is " + i;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.junit.Test;
|
|||
import static org.elasticsearch.Version.V_0_20_0;
|
||||
import static org.elasticsearch.Version.V_0_90_0;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
|
||||
|
@ -54,7 +53,7 @@ public class VersionTests extends ElasticsearchTestCase {
|
|||
public void testVersionConstantPresent() {
|
||||
assertThat(Version.CURRENT, sameInstance(Version.fromId(Version.CURRENT.id)));
|
||||
assertThat(Version.CURRENT.luceneVersion.ordinal(), equalTo(org.apache.lucene.util.Version.LUCENE_CURRENT.ordinal() - 1));
|
||||
final int iters = atLeast(20);
|
||||
final int iters = scaledRandomIntBetween(20, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
Version version = randomVersion();
|
||||
assertThat(version, sameInstance(Version.fromId(version.id)));
|
||||
|
|
|
@ -51,7 +51,7 @@ public class HotThreadsTest extends ElasticsearchIntegrationTest {
|
|||
* This test just checks if nothing crashes or gets stuck etc.
|
||||
*/
|
||||
createIndex("test");
|
||||
final int iters = atLeast(2);
|
||||
final int iters = scaledRandomIntBetween(2, 20);
|
||||
final AtomicBoolean hasErrors = new AtomicBoolean(false);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
final String type;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DiskUsageTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void randomDiskUsageTest() {
|
||||
int iters = atLeast(1000);
|
||||
int iters = scaledRandomIntBetween(1000, 10000);
|
||||
for (int i = 1; i < iters; i++) {
|
||||
long total = between(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
long free = between(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
|
|
|
@ -191,7 +191,7 @@ public class NodeVersionAllocationDeciderTests extends ElasticsearchAllocationTe
|
|||
assertThat(routingTable.shardsWithState(UNASSIGNED).size(), equalTo(routingTable.allShards().size()));
|
||||
List<DiscoveryNode> nodes = new ArrayList<DiscoveryNode>();
|
||||
int nodeIdx = 0;
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();
|
||||
int numNodes = between(1, 20);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class RandomAllocationDeciderTests extends ElasticsearchAllocationTestCas
|
|||
|
||||
RoutingTable routingTable = routingTableBuilder.build();
|
||||
ClusterState clusterState = ClusterState.builder().metaData(metaData).routingTable(routingTable).build();
|
||||
int numIters = atLeast(20);
|
||||
int numIters = scaledRandomIntBetween(20, 100);;
|
||||
int nodeIdCounter = 0;
|
||||
int atMostNodes = between(Math.max(1, maxNumReplicas), numIters);
|
||||
final boolean frequentNodes = randomBoolean();
|
||||
|
@ -90,7 +90,7 @@ public class RandomAllocationDeciderTests extends ElasticsearchAllocationTestCas
|
|||
|
||||
if (clusterState.nodes().size() <= atMostNodes &&
|
||||
(nodeIdCounter == 0 || (frequentNodes ? frequently() : rarely()))) {
|
||||
int numNodes = atLeast(1);
|
||||
int numNodes = scaledRandomIntBetween(1, 15);
|
||||
for (int j = 0; j < numNodes; j++) {
|
||||
logger.info("adding node [{}]", nodeIdCounter);
|
||||
newNodesBuilder.put(newNode("NODE_" + (nodeIdCounter++)));
|
||||
|
|
|
@ -31,14 +31,14 @@ import java.nio.LongBuffer;
|
|||
public class MurmurHash3Tests extends ElasticsearchTestCase {
|
||||
|
||||
public void testHash128() {
|
||||
final int iters = atLeast(100);
|
||||
final int iters = scaledRandomIntBetween(100, 5000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final int seed = randomInt();
|
||||
final int offset = randomInt(20);
|
||||
final int len = randomInt(randomBoolean() ? 20 : 200);
|
||||
final byte[] bytes = new byte[len + offset + randomInt(3)];
|
||||
getRandom().nextBytes(bytes);
|
||||
HashCode h1 = Hashing.murmur3_128(seed).hashBytes(bytes, offset, len);;
|
||||
HashCode h1 = Hashing.murmur3_128(seed).hashBytes(bytes, offset, len);
|
||||
MurmurHash3.Hash128 h2 = MurmurHash3.hash128(bytes, offset, len, seed, new MurmurHash3.Hash128());
|
||||
assertEquals(h1, h2);
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ public class XBooleanFilterTests extends ElasticsearchLuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testRandom() throws IOException {
|
||||
int iterations = atLeast(400); // don't worry that is fast!
|
||||
int iterations = scaledRandomIntBetween(100, 1000); // don't worry that is fast!
|
||||
for (int iter = 0; iter < iterations; iter++) {
|
||||
int numClauses = 1 + random().nextInt(10);
|
||||
FilterClause[] clauses = new FilterClause[numClauses];
|
||||
|
|
|
@ -45,7 +45,7 @@ public class FuzzinessTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testParseFromXContent() throws IOException {
|
||||
final int iters = atLeast(10);
|
||||
final int iters = randomIntBetween(10, 50);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
{
|
||||
XContent xcontent = XContentType.JSON.xContent();
|
||||
|
@ -165,7 +165,7 @@ public class FuzzinessTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testAsDistance() {
|
||||
final int iters = atLeast(10);
|
||||
final int iters = randomIntBetween(10, 50);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
Integer integer = Integer.valueOf(randomIntBetween(0, 10));
|
||||
String value = "" + (randomBoolean() ? integer.intValue() : integer.floatValue());
|
||||
|
@ -183,7 +183,7 @@ public class FuzzinessTests extends ElasticsearchTestCase {
|
|||
assertThat((double) Fuzziness.TWO.asSimilarity("abcefg"), closeTo(0.66f, 0.05));
|
||||
assertThat((double) Fuzziness.ONE.asSimilarity("ab"), closeTo(0.5f, 0.05));
|
||||
|
||||
int iters = atLeast(100);
|
||||
int iters = randomIntBetween(100, 1000);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
Fuzziness fuzziness = Fuzziness.fromEdits(between(1, 2));
|
||||
String string = rarely() ? randomRealisticUnicodeOfLengthBetween(2, 4) :
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ByteUtilsTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
public void testFloat() throws IOException {
|
||||
final float[] data = new float[atLeast(1000)];
|
||||
final float[] data = new float[scaledRandomIntBetween(1000, 10000)];
|
||||
final byte[] encoded = new byte[data.length * 4];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
data[i] = randomFloat();
|
||||
|
@ -57,7 +57,7 @@ public class ByteUtilsTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
public void testDouble() throws IOException {
|
||||
final double[] data = new double[atLeast(1000)];
|
||||
final double[] data = new double[scaledRandomIntBetween(1000, 10000)];
|
||||
final byte[] encoded = new byte[data.length * 8];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
data[i] = randomDouble();
|
||||
|
@ -69,7 +69,7 @@ public class ByteUtilsTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
public void testVLong() throws IOException {
|
||||
final long[] data = new long[atLeast(1000)];
|
||||
final long[] data = new long[scaledRandomIntBetween(1000, 10000)];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
switch (randomInt(4)) {
|
||||
case 0:
|
||||
|
|
|
@ -94,7 +94,7 @@ public class BytesRefHashTests extends ElasticsearchTestCase {
|
|||
@Test
|
||||
public void testSize() {
|
||||
BytesRef ref = new BytesRef();
|
||||
int num = atLeast(2);
|
||||
int num = scaledRandomIntBetween(2, 20);
|
||||
for (int j = 0; j < num; j++) {
|
||||
final int mod = 1+randomInt(40);
|
||||
for (int i = 0; i < 797; i++) {
|
||||
|
@ -126,7 +126,7 @@ public class BytesRefHashTests extends ElasticsearchTestCase {
|
|||
public void testGet() {
|
||||
BytesRef ref = new BytesRef();
|
||||
BytesRef scratch = new BytesRef();
|
||||
int num = atLeast(2);
|
||||
int num = scaledRandomIntBetween(2, 20);
|
||||
for (int j = 0; j < num; j++) {
|
||||
Map<String, Long> strings = new HashMap<String, Long>();
|
||||
int uniqueCount = 0;
|
||||
|
@ -166,7 +166,7 @@ public class BytesRefHashTests extends ElasticsearchTestCase {
|
|||
public void testAdd() {
|
||||
BytesRef ref = new BytesRef();
|
||||
BytesRef scratch = new BytesRef();
|
||||
int num = atLeast(2);
|
||||
int num = scaledRandomIntBetween(2, 20);
|
||||
for (int j = 0; j < num; j++) {
|
||||
Set<String> strings = new HashSet<String>();
|
||||
int uniqueCount = 0;
|
||||
|
@ -202,7 +202,7 @@ public class BytesRefHashTests extends ElasticsearchTestCase {
|
|||
public void testFind() throws Exception {
|
||||
BytesRef ref = new BytesRef();
|
||||
BytesRef scratch = new BytesRef();
|
||||
int num = atLeast(2);
|
||||
int num = scaledRandomIntBetween(2, 20);
|
||||
for (int j = 0; j < num; j++) {
|
||||
Set<String> strings = new HashSet<String>();
|
||||
int uniqueCount = 0;
|
||||
|
|
|
@ -30,7 +30,7 @@ public class DoubleObjectHashMapTests extends ElasticsearchTestCase {
|
|||
final DoubleObjectOpenHashMap<Object> map1 = new DoubleObjectOpenHashMap<Object>();
|
||||
final DoubleObjectPagedHashMap<Object> map2 = new DoubleObjectPagedHashMap<Object>(randomInt(42), 0.6f + randomFloat() * 0.39f, BigArraysTests.randombigArrays());
|
||||
final int maxKey = randomIntBetween(1, 10000);
|
||||
final int iters = atLeast(10000);
|
||||
final int iters = scaledRandomIntBetween(10000, 100000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final boolean put = randomBoolean();
|
||||
final int iters2 = randomIntBetween(1, 100);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class LongObjectHashMapTests extends ElasticsearchTestCase {
|
|||
final LongObjectOpenHashMap<Object> map1 = new LongObjectOpenHashMap<Object>();
|
||||
final LongObjectPagedHashMap<Object> map2 = new LongObjectPagedHashMap<Object>(randomInt(42), 0.6f + randomFloat() * 0.39f, BigArraysTests.randombigArrays());
|
||||
final int maxKey = randomIntBetween(1, 10000);
|
||||
final int iters = atLeast(10000);
|
||||
final int iters = scaledRandomIntBetween(10000, 100000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final boolean put = randomBoolean();
|
||||
final int iters2 = randomIntBetween(1, 100);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.common.util.concurrent;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
@ -33,11 +32,11 @@ import static org.hamcrest.Matchers.greaterThan;
|
|||
|
||||
public class CountDownTest extends ElasticsearchTestCase {
|
||||
|
||||
@Test @Repeat(iterations = 1000)
|
||||
@Test
|
||||
public void testConcurrent() throws InterruptedException {
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final CountDown countDown = new CountDown(atLeast(10));
|
||||
Thread[] threads = new Thread[atLeast(3)];
|
||||
final CountDown countDown = new CountDown(scaledRandomIntBetween(10, 1000));
|
||||
Thread[] threads = new Thread[between(3, 10)];
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i] = new Thread() {
|
||||
|
@ -83,7 +82,7 @@ public class CountDownTest extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testSingleThreaded() {
|
||||
int atLeast = atLeast(10);
|
||||
int atLeast = scaledRandomIntBetween(10, 1000);
|
||||
final CountDown countDown = new CountDown(atLeast);
|
||||
while(!countDown.isCountedDown()) {
|
||||
atLeast--;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SimpleCountTests extends ElasticsearchIntegrationTest {
|
|||
client().prepareIndex("test", "type", "5").setSource("field", "value"),
|
||||
client().prepareIndex("test", "type", "6").setSource("field", "value"));
|
||||
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
// id is not indexed, but lets see that we automatically convert to
|
||||
CountResponse countResponse = client().prepareCount().setQuery(QueryBuilders.matchAllQuery()).setPreference(randomUnicodeOfLengthBetween(0, 4)).get();
|
||||
|
|
|
@ -125,7 +125,7 @@ public class DeleteByQueryTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
public void testDeleteByFieldQuery() throws Exception {
|
||||
client().admin().indices().prepareCreate("test").execute().actionGet();
|
||||
int numDocs = atLeast(10);
|
||||
int numDocs = scaledRandomIntBetween(10, 100);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
client().prepareIndex("test", "test", Integer.toString(i))
|
||||
.setRouting(randomAsciiOfLengthBetween(1, 5))
|
||||
|
|
|
@ -280,26 +280,37 @@ public class IndexGatewayTests extends ElasticsearchIntegrationTest {
|
|||
logger.info("--> refreshing and checking count");
|
||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||
assertThat(client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount(), equalTo(0l));
|
||||
|
||||
logger.info("--> indexing 1234 docs");
|
||||
for (long i = 0; i < 1234; i++) {
|
||||
long numDocs = between(100, rarely() ? 2000 : 1000);
|
||||
logger.info("--> indexing " + numDocs + " docs");
|
||||
boolean hasSnapshoted = false;
|
||||
boolean hasFlushed = false;
|
||||
for (long i = 0; i < numDocs; i++) {
|
||||
client().prepareIndex("test", "type1", Long.toString(i))
|
||||
.setCreate(true) // make sure we use create, so if we recover wrongly, we will get increments...
|
||||
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + i).map()).execute().actionGet();
|
||||
|
||||
// snapshot every 100 so we get some actions going on in the gateway
|
||||
if ((i % 11) == 0) {
|
||||
// snapshot every 100 so we get some actions going on in the gateway
|
||||
if (rarely()) {
|
||||
hasSnapshoted = true;
|
||||
client().admin().indices().prepareGatewaySnapshot().execute().actionGet();
|
||||
}
|
||||
// flush every once is a while, so we get different data
|
||||
if ((i % 55) == 0) {
|
||||
if (rarely()) {
|
||||
hasFlushed = true;
|
||||
client().admin().indices().prepareFlush().execute().actionGet();
|
||||
}
|
||||
}
|
||||
if (!hasSnapshoted) {
|
||||
client().admin().indices().prepareGatewaySnapshot().execute().actionGet();
|
||||
}
|
||||
|
||||
if (!hasFlushed) {
|
||||
client().admin().indices().prepareFlush().execute().actionGet();
|
||||
}
|
||||
|
||||
logger.info("--> refreshing and checking count");
|
||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||
assertThat(client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount(), equalTo(1234l));
|
||||
assertThat(client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount(), equalTo(numDocs));
|
||||
|
||||
|
||||
logger.info("--> closing the server");
|
||||
|
@ -319,7 +330,7 @@ public class IndexGatewayTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
|
||||
|
||||
logger.info("--> checking count");
|
||||
assertThat(client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount(), equalTo(1234l));
|
||||
assertThat(client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount(), equalTo(numDocs));
|
||||
|
||||
logger.info("--> checking reuse / recovery status");
|
||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().setRecovery(true).execute().actionGet();
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.junit.Ignore;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.scaledRandomIntBetween;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +33,7 @@ public class AnalyzerBackwardsCompatTests extends ElasticsearchTokenStreamTestCa
|
|||
|
||||
@Ignore
|
||||
private void testNoStopwordsAfter(org.elasticsearch.Version noStopwordVersion, String type) throws IOException {
|
||||
final int iters = atLeast(10);
|
||||
final int iters = scaledRandomIntBetween(10, 100);
|
||||
org.elasticsearch.Version version = org.elasticsearch.Version.CURRENT;
|
||||
for (int i = 0; i < iters; i++) {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder().put("index.analysis.filter.my_stop.type", "stop");
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.scaledRandomIntBetween;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
public class NGramTokenizerFactoryTests extends ElasticsearchTokenStreamTestCase {
|
||||
|
@ -108,7 +109,7 @@ public class NGramTokenizerFactoryTests extends ElasticsearchTokenStreamTestCase
|
|||
|
||||
@Test
|
||||
public void testBackwardsCompatibilityEdgeNgramTokenizer() throws IllegalArgumentException, IllegalAccessException {
|
||||
int iters = atLeast(20);
|
||||
int iters = scaledRandomIntBetween(20, 100);
|
||||
final Index index = new Index("test");
|
||||
final String name = "ngr";
|
||||
for (int i = 0; i < iters; i++) {
|
||||
|
@ -150,7 +151,7 @@ public class NGramTokenizerFactoryTests extends ElasticsearchTokenStreamTestCase
|
|||
|
||||
@Test
|
||||
public void testBackwardsCompatibilityNgramTokenizer() throws IllegalArgumentException, IllegalAccessException {
|
||||
int iters = atLeast(20);
|
||||
int iters = scaledRandomIntBetween(20, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
final Index index = new Index("test");
|
||||
final String name = "ngr";
|
||||
|
@ -183,7 +184,7 @@ public class NGramTokenizerFactoryTests extends ElasticsearchTokenStreamTestCase
|
|||
|
||||
@Test
|
||||
public void testBackwardsCompatibilityEdgeNgramTokenFilter() throws IllegalArgumentException, IllegalAccessException {
|
||||
int iters = atLeast(20);
|
||||
int iters = scaledRandomIntBetween(20, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
final Index index = new Index("test");
|
||||
final String name = "ngr";
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PreBuiltAnalyzerTests extends ElasticsearchTestCase {
|
|||
// special case, these two are the same instance
|
||||
assertThat(currentDefaultAnalyzer, is(currentStandardAnalyzer));
|
||||
PreBuiltAnalyzers.DEFAULT.getAnalyzer(Version.V_1_0_0_Beta1);
|
||||
final int n = atLeast(10);
|
||||
final int n = scaledRandomIntBetween(10, 100);
|
||||
Version version = Version.CURRENT;
|
||||
for(int i = 0; i < n; i++) {
|
||||
if (version.equals(Version.V_1_0_0_Beta1)) {
|
||||
|
@ -95,7 +95,7 @@ public class PreBuiltAnalyzerTests extends ElasticsearchTestCase {
|
|||
public void testAnalyzerChangedIn10RC1() throws IOException {
|
||||
Analyzer pattern = PreBuiltAnalyzers.PATTERN.getAnalyzer(Version.V_1_0_0_RC1);
|
||||
Analyzer standardHtml = PreBuiltAnalyzers.STANDARD_HTML_STRIP.getAnalyzer(Version.V_1_0_0_RC1);
|
||||
final int n = atLeast(10);
|
||||
final int n = scaledRandomIntBetween(10, 100);
|
||||
Version version = Version.CURRENT;
|
||||
for(int i = 0; i < n; i++) {
|
||||
if (version.equals(Version.V_1_0_0_RC1)) {
|
||||
|
|
|
@ -222,7 +222,7 @@ public abstract class AbstractStringFieldDataTests extends AbstractFieldDataImpl
|
|||
for (int i = 1; i < values.length; ++i) {
|
||||
values[i] = _TestUtil.randomUnicodeString(getRandom());
|
||||
}
|
||||
final int numDocs = atLeast(100);
|
||||
final int numDocs = scaledRandomIntBetween(100, 10000);
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
final String value = RandomPicks.randomFrom(getRandom(), values);
|
||||
if (value == null) {
|
||||
|
@ -284,7 +284,7 @@ public abstract class AbstractStringFieldDataTests extends AbstractFieldDataImpl
|
|||
for (int i = 1; i < values.length; ++i) {
|
||||
values[i] = _TestUtil.randomUnicodeString(getRandom());
|
||||
}
|
||||
final int numDocs = atLeast(100);
|
||||
final int numDocs = scaledRandomIntBetween(100, 10000);
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
final String value = RandomPicks.randomFrom(getRandom(), values);
|
||||
if (value == null) {
|
||||
|
@ -338,7 +338,7 @@ public abstract class AbstractStringFieldDataTests extends AbstractFieldDataImpl
|
|||
for (int i = 0; i < values.length; ++i) {
|
||||
values[i] = _TestUtil.randomSimpleString(getRandom());
|
||||
}
|
||||
final int numParents = atLeast(100);
|
||||
final int numParents = scaledRandomIntBetween(100, 10000);
|
||||
List<Document> docs = new ArrayList<Document>();
|
||||
final OpenBitSet parents = new OpenBitSet();
|
||||
for (int i = 0; i < numParents; ++i) {
|
||||
|
|
|
@ -53,12 +53,6 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static int atLeast(Random random, int i) {
|
||||
int min = i;
|
||||
int max = min + (min / 2);
|
||||
return min + random.nextInt(max - min);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuelAllTypesSingleValue() throws Exception {
|
||||
final String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
|
@ -73,7 +67,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
.endObject().endObject().endObject().string();
|
||||
final DocumentMapper mapper = MapperTestUtils.newParser().parse(mapping);
|
||||
Random random = getRandom();
|
||||
int atLeast = atLeast(random, 1000);
|
||||
int atLeast = scaledRandomIntBetween(1000, 1500);
|
||||
for (int i = 0; i < atLeast; i++) {
|
||||
String s = Integer.toString(randomByte());
|
||||
|
||||
|
@ -152,7 +146,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
|
||||
final DocumentMapper mapper = MapperTestUtils.newParser().parse(mapping);
|
||||
Random random = getRandom();
|
||||
int atLeast = atLeast(random, 1000);
|
||||
int atLeast = scaledRandomIntBetween(1000, 1500);
|
||||
final int maxNumValues = randomBoolean() ? 1 : randomIntBetween(2, 40);
|
||||
byte[] values = new byte[maxNumValues];
|
||||
for (int i = 0; i < atLeast; i++) {
|
||||
|
@ -230,7 +224,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
|
||||
final DocumentMapper mapper = MapperTestUtils.newParser().parse(mapping);
|
||||
Random random = getRandom();
|
||||
int atLeast = atLeast(random, 1000);
|
||||
int atLeast = scaledRandomIntBetween(1000, 1500);
|
||||
final int maxNumValues = randomBoolean() ? 1 : randomIntBetween(2, 40);
|
||||
float[] values = new float[maxNumValues];
|
||||
for (int i = 0; i < atLeast; i++) {
|
||||
|
@ -302,7 +296,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
@Test
|
||||
public void testDuelStrings() throws Exception {
|
||||
Random random = getRandom();
|
||||
int atLeast = atLeast(random, 1000);
|
||||
int atLeast = scaledRandomIntBetween(1000, 1500);
|
||||
for (int i = 0; i < atLeast; i++) {
|
||||
Document d = new Document();
|
||||
d.add(new StringField("_id", "" + i, Field.Store.NO));
|
||||
|
@ -377,7 +371,7 @@ public class DuelFieldDataTests extends AbstractFieldDataTests {
|
|||
final DocumentMapper mapper = MapperTestUtils.newParser().parse(mapping);
|
||||
|
||||
Random random = getRandom();
|
||||
int atLeast = atLeast(random, 1000);
|
||||
int atLeast = scaledRandomIntBetween(1000, 1500);
|
||||
int maxValuesPerDoc = randomBoolean() ? 1 : randomIntBetween(2, 40);
|
||||
// to test deduplication
|
||||
double defaultLat = randomDouble() * 180 - 90;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FieldDataFilterIntegrationTests extends ElasticsearchIntegrationTes
|
|||
.endObject().endObject();
|
||||
assertAcked(builder.addMapping("type", mapping));
|
||||
ensureGreen();
|
||||
int numDocs = atLeast(5);
|
||||
int numDocs = scaledRandomIntBetween(5, 50);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
client().prepareIndex("test", "type", "" + 0).setSource("name", "bacon bastards", "not_filtered", "bacon bastards").get();
|
||||
}
|
||||
|
|
|
@ -1702,7 +1702,7 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
|
|||
"{\"flt\": {\"fields\": [\"comment\"], \"like_text\": \"FFFdfds\",\"fuzziness\": 4}}",
|
||||
"{\"flt\": {\"fields\": [\"comment\"], \"like_text\": \"FFFdfds\",\"fuzziness\": 4.0}}"
|
||||
};
|
||||
int iters = atLeast(5);
|
||||
int iters = scaledRandomIntBetween(5, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
parsedQuery = queryParser.parse(new BytesArray((String) randomFrom(queries))).query();
|
||||
parsedQuery1 = queryParser.parse(new BytesArray((String) randomFrom(queries))).query();
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CircuitBreakerServiceTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
try {
|
||||
// index some different terms so we have some field data for loading
|
||||
int docCount = atLeast(300);
|
||||
int docCount = scaledRandomIntBetween(300, 1000);
|
||||
for (long id = 0; id < docCount; id++) {
|
||||
client.prepareIndex("cb-test", "type", Long.toString(id))
|
||||
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + id).map()).execute().actionGet();
|
||||
|
@ -108,7 +108,7 @@ public class CircuitBreakerServiceTests extends ElasticsearchIntegrationTest {
|
|||
client.admin().cluster().prepareHealth("ramtest").setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
|
||||
|
||||
// index some different terms so we have some field data for loading
|
||||
int docCount = atLeast(300);
|
||||
int docCount = scaledRandomIntBetween(300, 1000);
|
||||
for (long id = 0; id < docCount; id++) {
|
||||
client.prepareIndex("ramtest", "type", Long.toString(id))
|
||||
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + id).map()).execute().actionGet();
|
||||
|
|
|
@ -140,7 +140,7 @@ public class RandomExceptionCircuitBreakerTests extends ElasticsearchIntegration
|
|||
logger.info("Refresh failed: [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ",
|
||||
refreshFailed, refreshResponse.getFailedShards(), refreshResponse.getShardFailures().length,
|
||||
refreshResponse.getSuccessfulShards(), refreshResponse.getTotalShards());
|
||||
final int numSearches = atLeast(50);
|
||||
final int numSearches = scaledRandomIntBetween(50, 150);
|
||||
NodesStatsResponse resp = client().admin().cluster().prepareNodesStats()
|
||||
.clear().setBreaker(true).execute().actionGet();
|
||||
for (NodeStats stats : resp.getNodes()) {
|
||||
|
|
|
@ -50,13 +50,13 @@ public class ConcurrentDynamicTemplateTests extends ElasticsearchIntegrationTest
|
|||
// The 'fieldNames' array is used to help with retrieval of index terms
|
||||
// after testing
|
||||
|
||||
int iters = atLeast(5);
|
||||
int iters = scaledRandomIntBetween(5, 15);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
wipeIndices("test");
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping(mappingType, mapping));
|
||||
ensureYellow();
|
||||
int numDocs = atLeast(10);
|
||||
int numDocs = scaledRandomIntBetween(10, 100);
|
||||
final CountDownLatch latch = new CountDownLatch(numDocs);
|
||||
final List<Throwable> throwable = new CopyOnWriteArrayList<Throwable>();
|
||||
int currentID = 0;
|
||||
|
|
|
@ -79,7 +79,7 @@ public class IndexTemplateFileLoadingTests extends ElasticsearchIntegrationTest
|
|||
|
||||
@Test
|
||||
public void testThatLoadingTemplateFromFileWorks() throws Exception {
|
||||
final int iters = atLeast(5);
|
||||
final int iters = scaledRandomIntBetween(5, 20);
|
||||
Set<String> indices = new HashSet<String>();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
String indexName = "foo" + randomRealisticUnicodeOfLengthBetween(0, 5);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PercolatorFacetsAndAggregationsTests extends ElasticsearchIntegrati
|
|||
client().admin().indices().prepareCreate("test").execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
int numQueries = atLeast(250);
|
||||
int numQueries = scaledRandomIntBetween(250, 500);
|
||||
int numUniqueQueries = between(1, numQueries / 2);
|
||||
String[] values = new String[numUniqueQueries];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
|
|
|
@ -310,7 +310,7 @@ public class RecoveryWhileUnderLoadTests extends ElasticsearchIntegrationTest {
|
|||
final AtomicLong idGenerator = new AtomicLong();
|
||||
final AtomicLong indexCounter = new AtomicLong();
|
||||
final AtomicBoolean stop = new AtomicBoolean(false);
|
||||
Thread[] writers = new Thread[atLeast(3)];
|
||||
Thread[] writers = new Thread[scaledRandomIntBetween(3, 10)];
|
||||
final CountDownLatch stopLatch = new CountDownLatch(writers.length);
|
||||
logger.info("--> starting {} indexing threads", writers.length);
|
||||
final CopyOnWriteArrayList<Throwable> failures = new CopyOnWriteArrayList<Throwable>();
|
||||
|
|
|
@ -108,8 +108,8 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
@Slow
|
||||
public void testPrimaryRelocationWhileIndexingRandom() throws Exception {
|
||||
int numRelocations = atLeast(rarely() ? 3 : 1);
|
||||
int numWriters = atLeast(rarely() ? 3 : 1);
|
||||
int numRelocations = scaledRandomIntBetween(1, rarely() ? 10 : 4);
|
||||
int numWriters = scaledRandomIntBetween(1, rarely() ? 10 : 4);
|
||||
boolean batch = getRandom().nextBoolean();
|
||||
logger.info("testPrimaryRelocationWhileIndexingRandom(numRelocations={}, numWriters={}, batch={}",
|
||||
numRelocations, numWriters, batch);
|
||||
|
@ -261,8 +261,8 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
@Slow
|
||||
public void testReplicaRelocationWhileIndexingRandom() throws Exception {
|
||||
int numRelocations = atLeast(rarely() ? 3 : 1);
|
||||
int numWriters = atLeast(rarely() ? 3 : 1);
|
||||
int numRelocations = scaledRandomIntBetween(1, rarely() ? 10 : 4);
|
||||
int numWriters = scaledRandomIntBetween(1, rarely() ? 10 : 4);
|
||||
boolean batch = getRandom().nextBoolean();
|
||||
logger.info("testReplicaRelocationWhileIndexing(numRelocations={}, numWriters={}, batch={}", numRelocations, numWriters, batch);
|
||||
testReplicaRelocationWhileIndexing(numRelocations, numWriters, batch);
|
||||
|
|
|
@ -26,13 +26,13 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.ElasticsearchIntegrationTest.*;
|
||||
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.*;
|
||||
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.SUITE;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class StressSearchServiceReaperTest extends ElasticsearchIntegrationTest
|
|||
@Slow
|
||||
@Test // see issue #5165 - this test fails each time without the fix in pull #5170
|
||||
public void testStressReaper() throws ExecutionException, InterruptedException {
|
||||
int num = atLeast(100);
|
||||
int num = randomIntBetween(100, 150);
|
||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[num];
|
||||
for (int i = 0; i < builders.length; i++) {
|
||||
builders[i] = client().prepareIndex("test", "type", "" + i).setSource("f", English.intToEnglish(i));
|
||||
|
@ -56,7 +56,7 @@ public class StressSearchServiceReaperTest extends ElasticsearchIntegrationTest
|
|||
createIndex("test");
|
||||
indexRandom(true, builders);
|
||||
ensureYellow();
|
||||
final int iterations = atLeast(500);
|
||||
final int iterations = scaledRandomIntBetween(500, 1000);
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).setSize(num).get();
|
||||
assertNoFailures(searchResponse);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class RandomTests extends ElasticsearchIntegrationTest {
|
|||
// Make sure that unordered, reversed, disjoint and/or overlapping ranges are supported
|
||||
// Duel with filters
|
||||
public void testRandomRanges() throws Exception {
|
||||
final int numDocs = atLeast(1000);
|
||||
final int numDocs = scaledRandomIntBetween(1000, 10000);
|
||||
final double[][] docs = new double[numDocs][];
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
final int numValues = randomInt(5);
|
||||
|
@ -142,7 +142,7 @@ public class RandomTests extends ElasticsearchIntegrationTest {
|
|||
// test long/double/string terms aggs with high number of buckets that require array growth
|
||||
public void testDuelTerms() throws Exception {
|
||||
// These high numbers of docs and terms are important to trigger page recycling
|
||||
final int numDocs = atLeast(10000);
|
||||
final int numDocs = scaledRandomIntBetween(10000, 20000);
|
||||
final int maxNumTerms = randomIntBetween(10, 100000);
|
||||
|
||||
final IntOpenHashSet valuesSet = new IntOpenHashSet();
|
||||
|
@ -221,7 +221,7 @@ public class RandomTests extends ElasticsearchIntegrationTest {
|
|||
public void testDuelTermsHistogram() throws Exception {
|
||||
createIndex("idx");
|
||||
|
||||
final int numDocs = atLeast(1000);
|
||||
final int numDocs = scaledRandomIntBetween(1000, 5000);
|
||||
final int maxNumTerms = randomIntBetween(10, 2000);
|
||||
final int interval = randomIntBetween(1, 100);
|
||||
|
||||
|
@ -267,7 +267,8 @@ public class RandomTests extends ElasticsearchIntegrationTest {
|
|||
// test high numbers of percentile buckets to make sure paging and release work correctly
|
||||
createIndex("idx");
|
||||
|
||||
final int numDocs = atLeast(25000);
|
||||
final int numDocs = scaledRandomIntBetween(25000, 50000);
|
||||
logger.info("Indexing [" + numDocs +"] docs");
|
||||
int t = 0;
|
||||
for (int i = 0; i < numDocs; ) {
|
||||
BulkRequestBuilder request = client().prepareBulk();
|
||||
|
|
|
@ -37,7 +37,7 @@ public class GroupTreeTests extends ElasticsearchTestCase {
|
|||
GroupRedBlackTree tree2 = new GroupRedBlackTree(randomInt(100));
|
||||
|
||||
// Add elements
|
||||
final int elements = atLeast(100);
|
||||
final int elements = scaledRandomIntBetween(100, 1000);
|
||||
for (int i = 0; i < elements; ++i) {
|
||||
final double centroid = randomDouble();
|
||||
final int count = randomIntBetween(1, 5);
|
||||
|
|
|
@ -106,7 +106,7 @@ public class RedBlackTreeTests extends ElasticsearchTestCase {
|
|||
public void testAdd() {
|
||||
Map<Integer, Integer> map = Maps.newHashMap();
|
||||
IntRedBlackTree tree = new IntRedBlackTree();
|
||||
final int iters = atLeast(1000);
|
||||
final int iters = scaledRandomIntBetween(1000, 10000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final int value = randomInt(200);
|
||||
final boolean added = tree.add(value);
|
||||
|
@ -133,7 +133,7 @@ public class RedBlackTreeTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
public void testRemove() {
|
||||
final int numValues = atLeast(200);
|
||||
final int numValues = scaledRandomIntBetween(200, 1000);
|
||||
final FixedBitSet values = new FixedBitSet(numValues);
|
||||
values.set(0, numValues);
|
||||
IntRedBlackTree tree = new IntRedBlackTree();
|
||||
|
@ -141,7 +141,7 @@ public class RedBlackTreeTests extends ElasticsearchTestCase {
|
|||
tree.add(i);
|
||||
}
|
||||
|
||||
final int iters = atLeast(300);
|
||||
final int iters = scaledRandomIntBetween(300, 1000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final int value = randomInt(numValues - 1);
|
||||
final boolean removed = tree.remove(value);
|
||||
|
@ -165,7 +165,7 @@ public class RedBlackTreeTests extends ElasticsearchTestCase {
|
|||
|
||||
public void testReverse() {
|
||||
IntRedBlackTree tree = new IntRedBlackTree();
|
||||
final int iters = atLeast(1000);
|
||||
final int iters = scaledRandomIntBetween(1000, 10000);
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final int value = randomInt(2000);
|
||||
tree.add(value);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class HyperLogLogPlusPlusTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void encodeDecode() {
|
||||
final int iters = atLeast(100000);
|
||||
final int iters = scaledRandomIntBetween(100000, 500000);
|
||||
// random hashes
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
final int p1 = randomIntBetween(4, 24);
|
||||
|
|
|
@ -72,11 +72,11 @@ public class SearchWhileRelocatingTests extends ElasticsearchIntegrationTest {
|
|||
}
|
||||
indexRandom(true, indexBuilders.toArray(new IndexRequestBuilder[indexBuilders.size()]));
|
||||
assertHitCount(client().prepareSearch().get(), (long) (numDocs));
|
||||
final int numIters = atLeast(10);
|
||||
final int numIters = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < numIters; i++) {
|
||||
final AtomicBoolean stop = new AtomicBoolean(false);
|
||||
final List<Throwable> thrownExceptions = new CopyOnWriteArrayList<Throwable>();
|
||||
Thread[] threads = new Thread[atLeast(1)];
|
||||
Thread[] threads = new Thread[scaledRandomIntBetween(1, 3)];
|
||||
for (int j = 0; j < threads.length; j++) {
|
||||
threads[j] = new Thread() {
|
||||
public void run() {
|
||||
|
|
|
@ -126,12 +126,11 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes
|
|||
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().get(); // don't assert on failures here
|
||||
final boolean refreshFailed = refreshResponse.getShardFailures().length != 0 || refreshResponse.getFailedShards() != 0;
|
||||
logger.info("Refresh failed [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ", refreshFailed, refreshResponse.getFailedShards(), refreshResponse.getShardFailures().length, refreshResponse.getSuccessfulShards(), refreshResponse.getTotalShards());
|
||||
final int numSearches = atLeast(10);
|
||||
final int numSearches = scaledRandomIntBetween(10, 20);
|
||||
// we don't check anything here really just making sure we don't leave any open files or a broken index behind.
|
||||
for (int i = 0; i < numSearches; i++) {
|
||||
try {
|
||||
int docToQuery = between(0, numDocs-1);
|
||||
long expectedResults = added[docToQuery] ? 1 : 0;
|
||||
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery))).get();
|
||||
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), test.numPrimaries);
|
||||
|
@ -212,7 +211,7 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes
|
|||
logger.info("Refresh failed [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ", refreshFailed, refreshResponse.getFailedShards(), refreshResponse.getShardFailures().length, refreshResponse.getSuccessfulShards(), refreshResponse.getTotalShards());
|
||||
|
||||
NumShards test = getNumShards("test");
|
||||
final int numSearches = atLeast(100);
|
||||
final int numSearches = scaledRandomIntBetween(100, 200);
|
||||
// we don't check anything here really just making sure we don't leave any open files or a broken index behind.
|
||||
for (int i = 0; i < numSearches; i++) {
|
||||
try {
|
||||
|
|
|
@ -70,7 +70,7 @@ public class SimpleFacetsTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
protected int numberOfRuns() {
|
||||
if (numRuns == -1) {
|
||||
numRuns = atLeast(3);
|
||||
numRuns = scaledRandomIntBetween(3, 10);
|
||||
}
|
||||
return numRuns;
|
||||
}
|
||||
|
|
|
@ -41,17 +41,17 @@ public class RandomScoreFunctionTests extends ElasticsearchIntegrationTest {
|
|||
public void consistentHitsWithSameSeed() throws Exception {
|
||||
createIndex("test");
|
||||
ensureGreen(); // make sure we are done otherwise preference could change?
|
||||
int docCount = atLeast(100);
|
||||
int docCount = randomIntBetween(100, 200);
|
||||
for (int i = 0; i < docCount; i++) {
|
||||
index("test", "type", "" + i, jsonBuilder().startObject().endObject());
|
||||
}
|
||||
flush();
|
||||
refresh();
|
||||
int outerIters = atLeast(10);
|
||||
int outerIters = scaledRandomIntBetween(10, 20);
|
||||
for (int o = 0; o < outerIters; o++) {
|
||||
final long seed = randomLong();
|
||||
final String preference = randomRealisticUnicodeOfLengthBetween(1, 10); // at least one char!!
|
||||
int innerIters = atLeast(2);
|
||||
int innerIters = scaledRandomIntBetween(2, 5);
|
||||
SearchHits hits = null;
|
||||
for (int i = 0; i < innerIters; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
|
|
|
@ -2091,7 +2091,7 @@ public class HighlighterSearchTests extends ElasticsearchIntegrationTest {
|
|||
.setSource("field1", "The quick brown fox jumps over",
|
||||
"field2", "The quick brown fox jumps over").get();
|
||||
refresh();
|
||||
final int iters = atLeast(20);
|
||||
final int iters = scaledRandomIntBetween(20, 30);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
MultiMatchQueryBuilder.Type matchQueryType = rarely() ? null : RandomPicks.randomFrom(getRandom(), MultiMatchQueryBuilder.Type.values());
|
||||
final MultiMatchQueryBuilder multiMatchQueryBuilder = multiMatchQuery("the quick brown fox", "field1", "field2").type(matchQueryType);
|
||||
|
|
|
@ -217,7 +217,7 @@ public class MatchedQueriesTests extends ElasticsearchIntegrationTest {
|
|||
refresh();
|
||||
|
||||
// Execute search at least two times to load it in cache
|
||||
int iter = atLeast(2);
|
||||
int iter = scaledRandomIntBetween(2, 10);
|
||||
for (int i = 0; i < iter; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(
|
||||
|
|
|
@ -64,7 +64,7 @@ public class MultiMatchQueryTests extends ElasticsearchIntegrationTest {
|
|||
);
|
||||
assertAcked(builder.addMapping("test", createMapping()));
|
||||
ensureGreen();
|
||||
int numDocs = atLeast(50);
|
||||
int numDocs = scaledRandomIntBetween(50, 100);
|
||||
List<IndexRequestBuilder> builders = new ArrayList<IndexRequestBuilder>();
|
||||
builders.add(client().prepareIndex("test", "test", "theone").setSource(
|
||||
"full_name", "Captain America",
|
||||
|
@ -275,7 +275,7 @@ public class MultiMatchQueryTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
final int numDocs = (int) client().prepareCount("test")
|
||||
.setQuery(matchAllQuery()).get().getCount();
|
||||
int numIters = atLeast(5);
|
||||
int numIters = scaledRandomIntBetween(5, 10);
|
||||
for (int i = 0; i < numIters; i++) {
|
||||
{
|
||||
MatchQueryBuilder.Type type = randomBoolean() ? null : MatchQueryBuilder.Type.BOOLEAN;
|
||||
|
|
|
@ -196,7 +196,7 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
|
|||
assertSearchHit(searchHit, hasScore(1.0f));
|
||||
}
|
||||
|
||||
int num = atLeast(100);
|
||||
int num = scaledRandomIntBetween(100, 200);
|
||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[num];
|
||||
for (int i = 0; i < builders.length; i++) {
|
||||
builders[i] = client().prepareIndex("test", "type", "" + i).setSource("f", English.intToEnglish(i));
|
||||
|
@ -204,7 +204,7 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
|
|||
createIndex("test_1");
|
||||
indexRandom(true, builders);
|
||||
ensureYellow();
|
||||
int queryRounds = atLeast(10);
|
||||
int queryRounds = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < queryRounds; i++) {
|
||||
MatchQueryBuilder matchQuery = matchQuery("f", English.intToEnglish(between(0, num)));
|
||||
searchResponse = client().prepareSearch("test_1").setQuery(matchQuery).setSize(num).get();
|
||||
|
@ -241,7 +241,7 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
|
|||
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("foo", "bar"),
|
||||
client().prepareIndex("test", "type1", "2").setSource("foo", "bar")
|
||||
);
|
||||
int iters = atLeast(100);
|
||||
int iters = scaledRandomIntBetween(100, 200);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setQuery(queryString("*:*^10.0").boost(10.0f)).get();
|
||||
assertHitCount(searchResponse, 2l);
|
||||
|
@ -356,7 +356,7 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
public void testOmitTermFreqsAndPositions() throws Exception {
|
||||
Version version = Version.CURRENT;
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
try {
|
||||
// backwards compat test!
|
||||
|
|
|
@ -55,7 +55,7 @@ public class QueryRescorerTests extends ElasticsearchIntegrationTest {
|
|||
public void testEnforceWindowSize() {
|
||||
createIndex("test");
|
||||
// this
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < iters; i ++) {
|
||||
client().prepareIndex("test", "type", Integer.toString(i)).setSource("f", Integer.toString(i)).execute().actionGet();
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class QueryRescorerTests extends ElasticsearchIntegrationTest {
|
|||
public void testEquivalence() throws Exception {
|
||||
int numDocs = indexRandomNumbers("whitespace");
|
||||
|
||||
final int iters = atLeast(50);
|
||||
final int iters = scaledRandomIntBetween(50, 100);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
int resultSize = between(5, 30);
|
||||
int rescoreWindow = between(1, 3) * resultSize;
|
||||
|
@ -542,7 +542,7 @@ public class QueryRescorerTests extends ElasticsearchIntegrationTest {
|
|||
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
|
||||
.field("analyzer", analyzer).field("type", "string").endObject().endObject().endObject().endObject())
|
||||
.setSettings(builder));
|
||||
int numDocs = atLeast(100);
|
||||
int numDocs = randomIntBetween(100, 150);
|
||||
IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs];
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
docs[i] = client().prepareIndex("test", "type1", String.valueOf(i)).setSource("field1", English.intToEnglish(i));
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SearchScanScrollingTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void testRandomized() throws Exception {
|
||||
testScroll(atLeast(100), between(1, 300), getRandom().nextBoolean(), getRandom().nextBoolean());
|
||||
testScroll(scaledRandomIntBetween(100, 200), between(1, 300), getRandom().nextBoolean(), getRandom().nextBoolean());
|
||||
}
|
||||
|
||||
private void testScroll(long numberOfDocs, int size, boolean unbalanced, boolean trackScores) throws Exception {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SearchScanTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
Set<String> ids = Sets.newHashSet();
|
||||
Set<String> expectedIds = Sets.newHashSet();
|
||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[atLeast(50)];
|
||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[scaledRandomIntBetween(50, 100)];
|
||||
for (int i = 0; i < builders.length/2; i++) {
|
||||
expectedIds.add(Integer.toString(i));
|
||||
builders[i] = client().prepareIndex("test", "tweet", Integer.toString(i)).setSource(
|
||||
|
|
|
@ -33,9 +33,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
||||
|
||||
public class SimpleSearchTests extends ElasticsearchIntegrationTest {
|
||||
|
||||
|
@ -66,7 +64,7 @@ public class SimpleSearchTests extends ElasticsearchIntegrationTest {
|
|||
client().prepareIndex("test", "type", "5").setSource("field", "value"),
|
||||
client().prepareIndex("test", "type", "6").setSource("field", "value"));
|
||||
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
// id is not indexed, but lets see that we automatically convert to
|
||||
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).setPreference(randomUnicodeOfLengthBetween(0, 4)).get();
|
||||
|
|
|
@ -122,7 +122,7 @@ public class SimpleSortTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
TreeMap<BytesRef, String> sparseBytes = new TreeMap<BytesRef, String>();
|
||||
TreeMap<BytesRef, String> denseBytes = new TreeMap<BytesRef, String>();
|
||||
int numDocs = atLeast(200);
|
||||
int numDocs = randomIntBetween(200, 300);
|
||||
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
String docId = Integer.toString(i);
|
||||
|
@ -1458,7 +1458,7 @@ public class SimpleSortTests extends ElasticsearchIntegrationTest {
|
|||
.startObject("_timestamp").field("enabled", true).field("store", true).field("index", !timestampDocValues || randomBoolean() ? "not_analyzed" : "no").startObject("fielddata").field("format", timestampDocValues ? "doc_values" : null).endObject().endObject()
|
||||
.endObject().endObject()));
|
||||
ensureGreen();
|
||||
final int numDocs = atLeast(10);
|
||||
final int numDocs = randomIntBetween(10, 20);
|
||||
IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs];
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
indexReqs[i] = client().prepareIndex("test", "typ", Integer.toString(i)).setTimestamp(Integer.toString(randomInt(1000))).setSource();
|
||||
|
|
|
@ -977,10 +977,10 @@ public class CompletionSuggestSearchTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
public void testMaxFieldLength() throws IOException {
|
||||
client().admin().indices().prepareCreate(INDEX).get();
|
||||
int iters = atLeast(10);
|
||||
int iters = scaledRandomIntBetween(10, 20);
|
||||
for (int i = 0; i < iters; i++) {
|
||||
int maxInputLen = between(3, 50);
|
||||
String str = replaceReservedChars(randomRealisticUnicodeOfCodepointLengthBetween(maxInputLen + 1, atLeast(maxInputLen + 2)), (char) 0x01);
|
||||
String str = replaceReservedChars(randomRealisticUnicodeOfCodepointLengthBetween(maxInputLen + 1, maxInputLen + scaledRandomIntBetween(2, 50)), (char) 0x01);
|
||||
ElasticsearchAssertions.assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject()
|
||||
.startObject(TYPE).startObject("properties")
|
||||
.startObject(FIELD)
|
||||
|
@ -1025,7 +1025,7 @@ public class CompletionSuggestSearchTests extends ElasticsearchIntegrationTest {
|
|||
.endObject()));
|
||||
ensureYellow();
|
||||
// can cause stack overflow without the default max_input_length
|
||||
String longString = replaceReservedChars(randomRealisticUnicodeOfLength(atLeast(5000)), (char) 0x01);
|
||||
String longString = replaceReservedChars(randomRealisticUnicodeOfLength(randomIntBetween(5000, 10000)), (char) 0x01);
|
||||
client().prepareIndex(INDEX, TYPE, "1").setSource(jsonBuilder()
|
||||
.startObject().startObject(FIELD)
|
||||
.startArray("input").value(longString).endArray()
|
||||
|
|
|
@ -128,7 +128,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase {
|
|||
XAnalyzingSuggester reference = new XAnalyzingSuggester(new StandardAnalyzer(TEST_VERSION_CURRENT), null, new StandardAnalyzer(
|
||||
TEST_VERSION_CURRENT), options, 256, -1, preservePositionIncrements, null, false, 1, XAnalyzingSuggester.SEP_LABEL, XAnalyzingSuggester.PAYLOAD_SEP, XAnalyzingSuggester.END_BYTE, XAnalyzingSuggester.HOLE_CHARACTER);
|
||||
LineFileDocs docs = new LineFileDocs(getRandom());
|
||||
int num = atLeast(150);
|
||||
int num = scaledRandomIntBetween(150, 300);
|
||||
final String[] titles = new String[num];
|
||||
final long[] weights = new long[num];
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||
import com.carrotsearch.randomizedtesting.annotations.*;
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
|
@ -48,4 +49,8 @@ public abstract class ElasticsearchLuceneTestCase extends LuceneTestCase {
|
|||
public static void forceDefaultCodec() {
|
||||
Codec.setDefault(DEFAULT_CODEC);
|
||||
}
|
||||
|
||||
public static int scaledRandomIntBetween(int min, int max) {
|
||||
return RandomizedTest.scaledRandomIntBetween(min, max);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ReproduceInfoPrinter extends RunListener {
|
|||
|
||||
public ReproduceErrorMessageBuilder appendESProperties() {
|
||||
appendProperties("es.logger.level", "es.node.mode", "es.node.local", TestCluster.TESTS_ENABLE_MOCK_MODULES,
|
||||
"tests.assertion.disabled", "tests.security.manager");
|
||||
"tests.assertion.disabled", "tests.security.manager", "tests.nighly");
|
||||
if (System.getProperty("tests.jvm.argline") != null && !System.getProperty("tests.jvm.argline").isEmpty()) {
|
||||
appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class KeyedLockTests extends ElasticsearchTestCase {
|
|||
KeyedLock<String> connectionLock = new KeyedLock<String>();
|
||||
String[] names = new String[randomIntBetween(1, 40)];
|
||||
connectionLock = new KeyedLock<String>();
|
||||
String name = randomRealisticUnicodeOfLength(atLeast(10));
|
||||
String name = randomRealisticUnicodeOfLength(scaledRandomIntBetween(10, 50));
|
||||
connectionLock.acquire(name);
|
||||
connectionLock.acquire(name);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class KeyedLockTests extends ElasticsearchTestCase {
|
|||
KeyedLock<String> connectionLock = new KeyedLock<String>();
|
||||
String[] names = new String[randomIntBetween(1, 40)];
|
||||
connectionLock = new KeyedLock<String>();
|
||||
String name = randomRealisticUnicodeOfLength(atLeast(10));
|
||||
String name = randomRealisticUnicodeOfLength(scaledRandomIntBetween(10, 50));
|
||||
connectionLock.release(name);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class KeyedLockTests extends ElasticsearchTestCase {
|
|||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
int numRuns = atLeast(500);
|
||||
int numRuns = scaledRandomIntBetween(500, 5000);
|
||||
for (int i = 0; i < numRuns; i++) {
|
||||
String curName = names[randomInt(names.length - 1)];
|
||||
connectionLock.acquire(curName);
|
||||
|
|
Loading…
Reference in New Issue