fix randomization of tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145730 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-07-12 19:23:57 +00:00
parent a540f48f07
commit 766261d06b
8 changed files with 33 additions and 9 deletions

View File

@ -67,7 +67,7 @@ public class BaseTestRangeFilter extends LuceneTestCase {
static TestIndex unsignedIndexDir; static TestIndex unsignedIndexDir;
static int minId = 0; static int minId = 0;
static int maxId = atLeast(500); static int maxId;
static final int intLength = Integer.toString(Integer.MAX_VALUE).length(); static final int intLength = Integer.toString(Integer.MAX_VALUE).length();
@ -93,6 +93,7 @@ public class BaseTestRangeFilter extends LuceneTestCase {
@BeforeClass @BeforeClass
public static void beforeClassBaseTestRangeFilter() throws Exception { public static void beforeClassBaseTestRangeFilter() throws Exception {
maxId = atLeast(500);
signedIndexDir = new TestIndex(random, Integer.MAX_VALUE, Integer.MIN_VALUE, true); signedIndexDir = new TestIndex(random, Integer.MAX_VALUE, Integer.MIN_VALUE, true);
unsignedIndexDir = new TestIndex(random, Integer.MAX_VALUE, 0, false); unsignedIndexDir = new TestIndex(random, Integer.MAX_VALUE, 0, false);
signedIndexReader = build(random, signedIndexDir); signedIndexReader = build(random, signedIndexDir);

View File

@ -39,7 +39,7 @@ public class TestCustomSearcherSort extends LuceneTestCase {
private IndexReader reader; private IndexReader reader;
private Query query = null; private Query query = null;
// reduced from 20000 to 2000 to speed up test... // reduced from 20000 to 2000 to speed up test...
private final static int INDEX_SIZE = atLeast(2000); private int INDEX_SIZE;
/** /**
* Create index and query for test cases. * Create index and query for test cases.
@ -47,6 +47,7 @@ public class TestCustomSearcherSort extends LuceneTestCase {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
INDEX_SIZE = atLeast(2000);
index = newDirectory(); index = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, index); RandomIndexWriter writer = new RandomIndexWriter(random, index);
RandomGen random = new RandomGen(this.random); RandomGen random = new RandomGen(this.random);

View File

@ -33,13 +33,14 @@ import java.io.PrintStream;
public class TestFieldCache extends LuceneTestCase { public class TestFieldCache extends LuceneTestCase {
protected IndexReader reader; protected IndexReader reader;
private static final int NUM_DOCS = atLeast(1000); private int NUM_DOCS;
private String[] unicodeStrings; private String[] unicodeStrings;
private Directory directory; private Directory directory;
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
NUM_DOCS = atLeast(1000);
directory = newDirectory(); directory = newDirectory();
RandomIndexWriter writer= new RandomIndexWriter(random, directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy())); RandomIndexWriter writer= new RandomIndexWriter(random, directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));
long theLong = Long.MAX_VALUE; long theLong = Long.MAX_VALUE;

View File

@ -44,7 +44,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
// shift the starting of the values to the left, to also have negative values: // shift the starting of the values to the left, to also have negative values:
private static final int startOffset = - 1 << 15; private static final int startOffset = - 1 << 15;
// number of docs to generate for testing // number of docs to generate for testing
private static final int noDocs = atLeast(4096); private static int noDocs;
private static Directory directory = null; private static Directory directory = null;
private static IndexReader reader = null; private static IndexReader reader = null;
@ -52,6 +52,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
@BeforeClass @BeforeClass
public static void beforeClass() throws Exception { public static void beforeClass() throws Exception {
noDocs = atLeast(4096);
directory = newDirectory(); directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory, RandomIndexWriter writer = new RandomIndexWriter(random, directory,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)) newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))

View File

@ -41,7 +41,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
// shift the starting of the values to the left, to also have negative values: // shift the starting of the values to the left, to also have negative values:
private static final long startOffset = - 1L << 31; private static final long startOffset = - 1L << 31;
// number of docs to generate for testing // number of docs to generate for testing
private static final int noDocs = atLeast(4096); private static int noDocs;
private static Directory directory = null; private static Directory directory = null;
private static IndexReader reader = null; private static IndexReader reader = null;
@ -49,6 +49,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
@BeforeClass @BeforeClass
public static void beforeClass() throws Exception { public static void beforeClass() throws Exception {
noDocs = atLeast(4096);
directory = newDirectory(); directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, directory, RandomIndexWriter writer = new RandomIndexWriter(random, directory,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)) newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))

View File

@ -53,6 +53,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.DocIdBitSet; import org.apache.lucene.util.DocIdBitSet;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil; import org.apache.lucene.util._TestUtil;
import org.junit.BeforeClass;
/** /**
* Unit tests for sorting code. * Unit tests for sorting code.
@ -65,7 +66,7 @@ import org.apache.lucene.util._TestUtil;
public class TestSort extends LuceneTestCase { public class TestSort extends LuceneTestCase {
// true if our codec supports docvalues: true unless codec is preflex (3.x) // true if our codec supports docvalues: true unless codec is preflex (3.x)
boolean supportsDocValues = CodecProvider.getDefault().getDefaultFieldCodec().equals("PreFlex") == false; boolean supportsDocValues = CodecProvider.getDefault().getDefaultFieldCodec().equals("PreFlex") == false;
private static final int NUM_STRINGS = atLeast(6000); private static int NUM_STRINGS;
private IndexSearcher full; private IndexSearcher full;
private IndexSearcher searchX; private IndexSearcher searchX;
private IndexSearcher searchY; private IndexSearcher searchY;
@ -78,6 +79,10 @@ public class TestSort extends LuceneTestCase {
private Query queryM; private Query queryM;
private Sort sort; private Sort sort;
@BeforeClass
public static void beforeClass() throws Exception {
NUM_STRINGS = atLeast(6000);
}
// document data: // document data:
// the tracer field is used to determine which document was hit // the tracer field is used to determine which document was hit
// the contents field is used to search and sort by relevance // the contents field is used to search and sort by relevance

View File

@ -32,13 +32,19 @@ import org.apache.lucene.search.FieldCache;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.FixedBitSet;
import org.junit.BeforeClass;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
public class TestEntryCreators extends LuceneTestCase { public class TestEntryCreators extends LuceneTestCase {
protected IndexReader reader; protected IndexReader reader;
private static final int NUM_DOCS = atLeast(500); private static int NUM_DOCS;
private Directory directory; private Directory directory;
@BeforeClass
public static void beforeClass() throws Exception {
NUM_DOCS = atLeast(500);
}
static class NumberTypeTester { static class NumberTypeTester {
String funcName; String funcName;

View File

@ -1,5 +1,7 @@
package org.apache.lucene.util; package org.apache.lucene.util;
import org.junit.BeforeClass;
/** /**
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -22,8 +24,14 @@ package org.apache.lucene.util;
*/ */
@Deprecated @Deprecated
public class TestIndexableBinaryStringTools extends LuceneTestCase { public class TestIndexableBinaryStringTools extends LuceneTestCase {
private static final int NUM_RANDOM_TESTS = atLeast(200); private static int NUM_RANDOM_TESTS;
private static final int MAX_RANDOM_BINARY_LENGTH = atLeast(300); private static int MAX_RANDOM_BINARY_LENGTH;
@BeforeClass
public static void beforeClass() throws Exception {
NUM_RANDOM_TESTS = atLeast(200);
MAX_RANDOM_BINARY_LENGTH = atLeast(300);
}
public void testSingleBinaryRoundTrip() { public void testSingleBinaryRoundTrip() {
byte[] binary = new byte[] { (byte) 0x23, (byte) 0x98, (byte) 0x13, byte[] binary = new byte[] { (byte) 0x23, (byte) 0x98, (byte) 0x13,