mirror of https://github.com/apache/lucene.git
tests: use Lucene's static random
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1049131 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3afc5c146b
commit
2d7f826781
|
@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||
* @since solr 1.5
|
||||
*/
|
||||
public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
||||
public static Random r = new Random(0);
|
||||
public static Random r = random;
|
||||
|
||||
protected int shardCount = 4;
|
||||
/**
|
||||
|
@ -581,7 +581,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
public static abstract class RandVal {
|
||||
public static Random r = new Random();
|
||||
public static Random r = random;
|
||||
public static Set uniqueValues = new HashSet();
|
||||
|
||||
public abstract Object val();
|
||||
|
|
|
@ -56,7 +56,7 @@ public class JettyWebappTest extends LuceneTestCase
|
|||
|
||||
server = new Server(port);
|
||||
// insecure: only use for tests!!!!
|
||||
server.setSessionIdManager(new HashSessionIdManager(new Random()));
|
||||
server.setSessionIdManager(new HashSessionIdManager(new Random(random.nextLong())));
|
||||
new WebAppContext(server, path, context );
|
||||
|
||||
SocketConnector connector = new SocketConnector();
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TestHash extends LuceneTestCase {
|
|||
|
||||
|
||||
public void testHash() {
|
||||
Random r = new Random(0);
|
||||
Random r = random;
|
||||
int[] utf32 = new int[20];
|
||||
tstEquiv(utf32,0);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class TestNamedListCodec extends LuceneTestCase {
|
|||
return lst;
|
||||
}
|
||||
|
||||
Random r = new Random();
|
||||
Random r = random;
|
||||
|
||||
public Object makeRandom(int lev) {
|
||||
switch (r.nextInt(10)) {
|
||||
|
@ -231,7 +231,7 @@ public class TestNamedListCodec extends LuceneTestCase {
|
|||
|
||||
|
||||
public void testRandom() throws Exception {
|
||||
Random r = new Random(0);
|
||||
// Random r = random;
|
||||
// let's keep it deterministic since just the wrong
|
||||
// random stuff could cause failure because of an OOM (too big)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.lucene.search.DocIdSetIterator;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class TestDocSet extends LuceneTestCase {
|
||||
Random rand = new Random();
|
||||
Random rand = random;
|
||||
float loadfactor;
|
||||
|
||||
public OpenBitSet getRandomSet(int sz, int bitsToSet) {
|
||||
|
|
|
@ -260,7 +260,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
int lowerWaterMark = cacheSize;
|
||||
int upperWaterMark = (int)(lowerWaterMark * 1.1);
|
||||
|
||||
Random r = new Random(0);
|
||||
Random r = random;
|
||||
ConcurrentLRUCache cache = new ConcurrentLRUCache(upperWaterMark, lowerWaterMark, (upperWaterMark+lowerWaterMark)/2, upperWaterMark, false, false, null);
|
||||
boolean getSize=false;
|
||||
int minSize=0,maxSize=0;
|
||||
|
@ -310,9 +310,8 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
}
|
||||
|
||||
void fillCache(SolrCache sc, int cacheSize, int maxKey) {
|
||||
Random r = new Random(0);
|
||||
for (int i=0; i<cacheSize; i++) {
|
||||
Integer kv = r.nextInt(maxKey);
|
||||
Integer kv = random.nextInt(maxKey);
|
||||
sc.put(kv,kv);
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +332,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
Thread[] threads = new Thread[nThreads];
|
||||
final AtomicInteger puts = new AtomicInteger(0);
|
||||
for (int i=0; i<threads.length; i++) {
|
||||
final int seed=i;
|
||||
final int seed=random.nextInt();
|
||||
threads[i] = new Thread() {
|
||||
public void run() {
|
||||
int ret = useCache(sc, numGets/nThreads, maxKey, seed);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TestSearchPerf extends AbstractSolrTestCase {
|
|||
return String.format("%08d", tnum);
|
||||
}
|
||||
|
||||
Random r = new Random(0);
|
||||
Random r = new Random(0); // specific seed for reproducible perf testing
|
||||
int nDocs;
|
||||
void createIndex(int nDocs) {
|
||||
this.nDocs = nDocs;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TestSort extends AbstractSolrTestCase {
|
|||
public String getSchemaFile() { return null; }
|
||||
public String getSolrConfigFile() { return null; }
|
||||
|
||||
Random r = new Random();
|
||||
Random r = random;
|
||||
|
||||
int ndocs = 77;
|
||||
int iter = 50;
|
||||
|
|
|
@ -220,7 +220,7 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
|
|||
assertTrue(orig != FileFloatSource.onlyForTesting);
|
||||
|
||||
|
||||
Random r = new Random();
|
||||
Random r = random;
|
||||
for (int i=0; i<10; i++) { // do more iterations for a thorough test
|
||||
int len = r.nextInt(ids.length+1);
|
||||
boolean sorted = r.nextBoolean();
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TestNumberUtils extends LuceneTestCase {
|
|||
return str+"]";
|
||||
}
|
||||
|
||||
static Random rng = new Random();
|
||||
static Random rng = random;
|
||||
|
||||
static int[] special = {0,10,100,1000,10000,Integer.MAX_VALUE, Integer.MIN_VALUE};
|
||||
static int getSpecial() {
|
||||
|
|
Loading…
Reference in New Issue