You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/11 22:42:56 UTC
[lucene-solr] 02/02: @512 Reduce non Nightly heavy garbage
generating tests.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit a21f2f6bd63957f6587cd5564a8f20f678c5df98
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Aug 11 17:40:48 2020 -0500
@512 Reduce non Nightly heavy garbage generating tests.
---
.../lucene/util/StressRamUsageEstimator.java | 3 ---
.../apache/lucene/util/TestWeakIdentityMap.java | 1 -
.../src/test/org/apache/solr/CursorPagingTest.java | 6 +++---
.../apache/solr/internal/csv/CSVPrinterTest.java | 22 ++++++++++---------
.../solr/legacy/TestNumericRangeQuery64.java | 25 ++++++++++++++++------
.../org/apache/solr/request/TestWriterPerf.java | 1 -
.../solr/uninverting/TestNumericTerms32.java | 6 +++---
.../solr/common/util/TestJsonRecordReader.java | 1 +
8 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java b/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java
index b66da5a..b400198 100644
--- a/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java
+++ b/lucene/core/src/test/org/apache/lucene/util/StressRamUsageEstimator.java
@@ -40,13 +40,11 @@ public class StressRamUsageEstimator extends LuceneTestCase {
@Nightly
public void testLargeSetOfByteArrays() {
- System.gc();
long before = Runtime.getRuntime().totalMemory();
Object [] all = new Object [1000000];
for (int i = 0; i < all.length; i++) {
all[i] = new byte[random().nextInt(3)];
}
- System.gc();
long after = Runtime.getRuntime().totalMemory();
System.out.println("mx: " + RamUsageEstimator.humanReadableUnits(after - before));
System.out.println("rue: " + RamUsageEstimator.humanReadableUnits(shallowSizeOf(all)));
@@ -79,7 +77,6 @@ public class StressRamUsageEstimator extends LuceneTestCase {
try {
while (true) {
// Check the current memory consumption and provide the estimate.
- System.gc();
long estimated = shallowSizeOf(all);
if (estimated > 50 * RamUsageEstimator.ONE_MB) {
break;
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java b/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
index c1a868d..46af2dc 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
@@ -119,7 +119,6 @@ public class TestWeakIdentityMap extends LuceneTestCase {
int size = map.size();
for (int i = 0; size > 0 && i < 10; i++) try {
System.runFinalization();
- System.gc();
int newSize = map.size();
assertTrue("previousSize("+size+")>=newSize("+newSize+")", size >= newSize);
size = newSize;
diff --git a/solr/core/src/test/org/apache/solr/CursorPagingTest.java b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
index 566611e..5aa8fef 100644
--- a/solr/core/src/test/org/apache/solr/CursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
@@ -559,8 +559,8 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
public void testRandomSortsOnLargeIndex() throws Exception {
final Collection<String> allFieldNames = getAllSortFieldNames();
- final int initialDocs = TestUtil.nextInt(random(), 100, TEST_NIGHTLY ? 200 : 115);
- final int totalDocs = TEST_NIGHTLY ? atLeast(500) : 120;
+ final int initialDocs = TestUtil.nextInt(random(), 100, TEST_NIGHTLY ? 200 : 102);
+ final int totalDocs = TEST_NIGHTLY ? atLeast(500) : 105;
// start with a smallish number of documents, and test that we can do a full walk using a
// sort on *every* field in the schema...
@@ -639,7 +639,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
*/
public static List<String> pruneAndDeterministicallySort(Collection<String> raw) {
- ArrayList<String> names = new ArrayList<>(37);
+ ArrayList<String> names = new ArrayList<>(raw.size());
for (String f : raw) {
if (f.equals("_version_")) {
continue;
diff --git a/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java b/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
index 199717b..4de8e5d 100644
--- a/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
+++ b/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
@@ -22,11 +22,15 @@ import java.io.StringWriter;
import java.util.Random;
import junit.framework.TestCase;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
+
+import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY;
/**
* CSVPrinterTest
*/
-public class CSVPrinterTest extends TestCase {
+public class CSVPrinterTest extends SolrTestCase {
String lineSeparator = "\n";
@@ -73,7 +77,7 @@ public class CSVPrinterTest extends TestCase {
public void testRandom() throws Exception {
- int iter=10000;
+ int iter= TEST_NIGHTLY ? 10000 : 27;
strategy = CSVStrategy.DEFAULT_STRATEGY;
doRandom(iter);
strategy = CSVStrategy.EXCEL_STRATEGY;
@@ -84,8 +88,6 @@ public class CSVPrinterTest extends TestCase {
('\t', CSVStrategy.ENCAPSULATOR_DISABLED, CSVStrategy.COMMENTS_DISABLED,'\\',false, false, false, false, "\n");
doRandom(iter);
}
-
- Random r = new Random();
CSVStrategy strategy;
public void doRandom(int iter) throws Exception {
@@ -95,8 +97,8 @@ public class CSVPrinterTest extends TestCase {
}
public void doOneRandom() throws Exception {
- int nLines = r.nextInt(4)+1;
- int nCol = r.nextInt(3)+1;
+ int nLines = random().nextInt(4)+1;
+ int nCol = random().nextInt(3)+1;
// nLines=1;nCol=2;
String[][] lines = new String[nLines][];
for (int i=0; i<nLines; i++) {
@@ -107,7 +109,7 @@ public class CSVPrinterTest extends TestCase {
}
}
- StringWriter sw = new StringWriter();
+ StringWriter sw = new StringWriter(128);
CSVPrinter printer = new CSVPrinter(sw, strategy);
for (int i=0; i<nLines; i++) {
@@ -167,13 +169,13 @@ public class CSVPrinterTest extends TestCase {
}
public String randStr() {
- int sz = r.nextInt(20);
+ int sz = random().nextInt(20);
// sz = r.nextInt(3);
char[] buf = new char[sz];
for (int i=0; i<sz; i++) {
// stick in special chars with greater frequency
char ch;
- int what = r.nextInt(20);
+ int what = random().nextInt(20);
switch (what) {
case 0: ch = '\r'; break;
case 1: ch = '\n'; break;
@@ -184,7 +186,7 @@ public class CSVPrinterTest extends TestCase {
case 6: ch = '"'; break;
case 7: ch = '\''; break;
case 8: ch = '\\'; break;
- default: ch = (char)r.nextInt(300); break;
+ default: ch = (char)random().nextInt(300); break;
// default: ch = 'a'; break;
}
buf[i] = ch;
diff --git a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java
index c401bd1..291bfd8 100644
--- a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java
+++ b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java
@@ -54,12 +54,12 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
@BeforeClass
public static void beforeClass() throws Exception {
- noDocs = atLeast(4096);
+ noDocs = TEST_NIGHTLY ? atLeast(4096) : 406;
distance = (1L << 60) / noDocs;
directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
newIndexWriterConfig(new MockAnalyzer(random()))
- .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
+ .setMaxBufferedDocs(TEST_NIGHTLY ? TestUtil.nextInt(random(), 100, 1000) : 1000)
.setMergePolicy(newLogMergePolicy()));
final LegacyFieldType storedLong = new LegacyFieldType(LegacyLongField.TYPE_NOT_STORED);
@@ -209,7 +209,12 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
@Test
public void testOneMatchQuery() throws Exception {
- LegacyNumericRangeQuery<Long> q = LegacyNumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
+ LegacyNumericRangeQuery<Long> q;
+ if (TEST_NIGHTLY) {
+ q = LegacyNumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
+ } else {
+ q = LegacyNumericRangeQuery.newLongRange("ascfield8", 8, 200L, 200L, true, true);
+ }
TopDocs topDocs = searcher.search(q, noDocs);
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
@@ -218,7 +223,7 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
private void testLeftOpenRange(int precisionStep) throws Exception {
String field="field"+precisionStep;
- int count=3000;
+ int count= TEST_NIGHTLY ? 3000 : 405;
long upper=(count-1)*distance + (distance/3) + startOffset;
LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, null, upper, true, true);
@@ -264,7 +269,7 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
private void testRightOpenRange(int precisionStep) throws Exception {
String field="field"+precisionStep;
- int count=3000;
+ int count=TEST_NIGHTLY ? 3000 : 400;
long lower=(count-1)*distance + (distance/3) +startOffset;
LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, true);
TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
@@ -381,7 +386,7 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
private void testRangeSplit(int precisionStep) throws Exception {
String field="ascfield"+precisionStep;
// 10 random tests
- int num = TestUtil.nextInt(random(), 10, 20);
+ int num = TEST_NIGHTLY ? TestUtil.nextInt(random(), 10, 20) : 5;
for (int i = 0; i < num; i++) {
long lower=(long)(random().nextDouble()*noDocs - noDocs/2);
long upper=(long)(random().nextDouble()*noDocs - noDocs/2);
@@ -438,7 +443,13 @@ public class TestNumericRangeQuery64 extends SolrTestCase {
/** we fake a double test using long2double conversion of LegacyNumericUtils */
private void testDoubleRange(int precisionStep) throws Exception {
final String field="ascfield"+precisionStep;
- final long lower=-1000L, upper=+2000L;
+
+ long lower=-1000L, upper=+2000L;
+
+ if (!TEST_NIGHTLY) {
+ lower=-100;
+ upper=+202L;
+ }
Query tq= LegacyNumericRangeQuery.newDoubleRange(field, precisionStep,
NumericUtils.sortableLongToDouble(lower), NumericUtils.sortableLongToDouble(upper), true, true);
diff --git a/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java b/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
index d484b35..faa7d97 100644
--- a/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
+++ b/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
@@ -110,7 +110,6 @@ public class TestWriterPerf extends SolrTestCaseJ4 {
ByteArrayOutputStream out=null;
- System.gc();
RTimer timer = new RTimer();
for (int i=0; i<encIter; i++) {
if (w instanceof BinaryQueryResponseWriter) {
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestNumericTerms32.java b/solr/core/src/test/org/apache/solr/uninverting/TestNumericTerms32.java
index 70451c0..1798591 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestNumericTerms32.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestNumericTerms32.java
@@ -54,13 +54,13 @@ public class TestNumericTerms32 extends SolrTestCase {
@BeforeClass
public static void beforeClass() throws Exception {
- noDocs = atLeast(4096);
+ noDocs = TEST_NIGHTLY ? atLeast(4096) : 406;
distance = (1 << 30) / noDocs;
directory = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
newIndexWriterConfig(new MockAnalyzer(random()))
- .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
- .setMergePolicy(newLogMergePolicy()));
+ .setMaxBufferedDocs(TEST_NIGHTLY ? TestUtil.nextInt(random(), 100, 1000) : 1000)
+ .setMergePolicy(newLogMergePolicy()));
final LegacyFieldType storedInt = new LegacyFieldType(LegacyIntField.TYPE_NOT_STORED);
storedInt.setStored(true);
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java b/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java
index 58ddb53..363c0cd 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestJsonRecordReader.java
@@ -362,6 +362,7 @@ public class TestJsonRecordReader extends SolrTestCaseJ4 {
}
}
+ @Nightly // calls System.gc
public void testArrayOfRootObjects() throws Exception {
String json = "[{'fieldA':'A1'}, {'fieldB':'B2'}]";
JsonRecordReader streamer;