Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-945: tests failed to find data dirs. Added sys-prop benchmark.work.dir and cfg-prop work.dir.

Doron Cohend9b6aa9c0bf3
diff --git a/common-build.xml b/common-build.xml
index bd78c1caba0..28cde3fc50b 100644
--- a/common-build.xml
+++ b/common-build.xml
@@ -310,8 +310,9 @@
<sysproperty key="docs.dir" file="src/test"/>
<sysproperty key="index.dir" file="${build.dir}/test/index"/>
- <!-- contrib/benchmark uses this system property to locate defined tasks -->
+ <!-- contrib/benchmark uses this system property to locate docs data and defined tasks -->
<sysproperty key="tasks.dir" file="${build.dir}/classes/java/org/apache/lucene/benchmark/byTask/tasks"/>
+ <sysproperty key="benchmark.work.dir" file="${common.dir}/contrib/benchmark/work"/>
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
diff --git a/contrib/benchmark/CHANGES.txt b/contrib/benchmark/CHANGES.txt
index de8c664b10a..407018fbe23 100644
--- a/contrib/benchmark/CHANGES.txt
+++ b/contrib/benchmark/CHANGES.txt
@@ -5,8 +5,9 @@ The Benchmark contrib package contains code for benchmarking Lucene in a variety
$Id:$
6/25/07
-- LUCENE-940: Multi-threaded issues fixed: SimpleDateFormat;
- logging for addDoc/deleteDoc tasks. (Doron Cohen)
+- LUCENE-940: Multi-threaded issues fixed: SimpleDateFormat; logging for addDoc/deleteDoc tasks.
+- LUCENE-945: tests fail to find data dirs. Added sys-prop benchmark.work.dir and cfg-prop work.dir.
+(Doron Cohen)
4/17/07
- LUCENE-863: Deprecated StandardBenchmarker in favour of byTask code.
diff --git a/contrib/benchmark/build.xml b/contrib/benchmark/build.xml
index 022ea7348e1..b6b64078c72 100644
--- a/contrib/benchmark/build.xml
+++ b/contrib/benchmark/build.xml
@@ -28,7 +28,6 @@
<target name="check-files">
-
<available file="temp/news20.tar.gz" property="news20.exists"/>
<available file="${working.dir}/20_newsgroup" property="news20.expanded"/>
@@ -152,4 +151,9 @@
<target name="init" depends="contrib-build.init,compile-demo,check-files"/>
+ <!-- make sure online collections (reuters) are first downloaded -->
+ <target name="test" depends="init,get-files">
+ <antcall target="common.test" inheritRefs="true" />
+ </target>
+
</project>
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
index 696a61514a3..9e6bd9ba1ae 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
@@ -48,6 +48,8 @@ import org.apache.lucene.benchmark.byTask.utils.FileUtils;
* <li>Analyzer.
* <li>Statistics data which updated during the run.
* </ul>
+ * Config properties: work.dir=&lt;path to root of docs and index dirs| Default: work&gt;
+ * </ul>
*/
public class PerfRunData {
@@ -117,7 +119,7 @@ public class PerfRunData {
// directory (default is ram-dir).
if ("FSDirectory".equals(config.get("directory","RAMDirectory"))) {
- File workDir = new File("work");
+ File workDir = new File(config.get("work.dir","work"));
File indexDir = new File(workDir,"index");
if (eraseIndex && indexDir.exists()) {
FileUtils.fullyDelete(indexDir);
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersDocMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersDocMaker.java
index 051cf10d6d5..adb7dd109e4 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersDocMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersDocMaker.java
@@ -31,11 +31,11 @@ import java.util.Locale;
/**
* A DocMaker using the Reuters collection for its input.
- *
- * Config properties:
- * docs.dir=&lt;path to the docs dir| Default: reuters-out&gt;
-
- *
+ * <p>
+ * Config properties:<ul>
+ * <li>work.dir=&lt;path to the root of docs and indexes dirs| Default: work&gt;</li>
+ * <li>docs.dir=&lt;path to the docs dir| Default: reuters-out&gt;</li>
+ * </ul>
*/
public class ReutersDocMaker extends BasicDocMaker {
@@ -50,9 +50,9 @@ public class ReutersDocMaker extends BasicDocMaker {
*/
public void setConfig(Config config) {
super.setConfig(config);
+ File workDir = new File(config.get("work.dir","work"));
String d = config.get("docs.dir","reuters-out");
- dataDir = new File(new File("work"),d);
-
+ dataDir = new File(workDir,d);
collectFiles(dataDir,inputFiles);
if (inputFiles.size()==0) {
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocMaker.java
index 97beebfb2ba..af3c00eaef0 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocMaker.java
@@ -36,6 +36,11 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
/**
* A DocMaker using the (compressed) Trec collection for its input.
+ * <p>
+ * Config properties:<ul>
+ * <li>work.dir=&lt;path to the root of docs and indexes dirs| Default: work&gt;</li>
+ * <li>docs.dir=&lt;path to the docs dir| Default: trec&gt;</li>
+ * </ul>
*/
public class TrecDocMaker extends BasicDocMaker {
@@ -61,8 +66,9 @@ public class TrecDocMaker extends BasicDocMaker {
*/
public void setConfig(Config config) {
super.setConfig(config);
+ File workDir = new File(config.get("work.dir","work"));
String d = config.get("docs.dir","trec");
- dataDir = new File(new File("work"),d);
+ dataDir = new File(workDir,d);
collectFiles(dataDir,inputFiles);
if (inputFiles.size()==0) {
throw new RuntimeException("No txt files in dataDir: "+dataDir.getAbsolutePath());
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
index a55bcce22c6..ea5bc00fd68 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
@@ -506,6 +506,11 @@ Here is a list of currently defined properties:
</p>
<ol>
+ <li><b>Root directory for data and indexes:</b></li>
+ <ul><li>work.dir (default is System property "benchmark.work.dir" or "work".)
+ </li></ul>
+ </li>
+
<li><b>Docs and queries creation:</b></li>
<ul><li>analyzer
</li><li>doc.maker
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
index 41ede6bee32..af6f0b161bd 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java
@@ -29,9 +29,17 @@ import java.util.StringTokenizer;
/**
* Perf run configuration properties.
+ * <p>
* Numeric peroperty containing ":", e.g. "10:100:5" is interpreted
* as array of numeric values. It is extracted once, on first use, and
- * maintain an round number to return the appropriate value.
+ * maintain a round number to return the appropriate value.
+ * <p>
+ * The config property "work.dir" tells where is the root of
+ * docs data dirs and indexes dirs. It is set to either of: <ul>
+ * <li>value supplied for it in the alg file;</li>
+ * <li>otherwise, value of System property "benchmark.work.dir";</li>
+ * <li>otherwise, "work".</li>
+ * </ul>
*/
public class Config {
@@ -70,6 +78,11 @@ public class Config {
this.props = new Properties();
props.load(new ByteArrayInputStream(sb.toString().getBytes()));
+ // make sure work dir is set properly
+ if (props.get("work.dir")==null) {
+ props.setProperty("work.dir",System.getProperty("benchmark.work.dir","work"));
+ }
+
if (Boolean.valueOf(props.getProperty("print.props","true")).booleanValue()) {
printProps();
}