Apache Solr open-source search software
make apps/SolarTest runnable via ant test
Yonik Seeleyd978defacf12
diff --git a/build.xml b/build.xmlindex ebca302bbce..634fafcda94 100644--- a/build.xml+++ b/build.xml@@ -70,6 +70,12 @@<!-- For now, it's the same as main classpath. Later it will have JUnit, Clover, etc. --><path id="test.compile.classpath"><path refid="compile.classpath" />+ <pathelement location="${dest}"/>+ </path>++ <path id="test.run.classpath">+ <path refid="test.compile.classpath" />+ <pathelement location="${dest}/tests"/></path><!-- Compile unit tests. -->@@ -77,10 +83,11 @@description="Compile unit tests."depends="compile"><mkdir dir="${dest}/tests" />- <javac destdir="${dest}/tests"- classpathref="test.compile.classpath">- <src dir="${src}/test" />- <src dir="${src}/apps/SolarTest/src" />+ <javac+ destdir="${dest}/tests"+ classpathref="test.compile.classpath">+ <src path="${src}/test" />+ <src path="${src}/apps/SolarTest/src" /></javac></target>@@ -89,6 +96,14 @@description="Runs the unit tests."depends="compileTests"><echo message="TO-DO later or after we convert tests to JUnit." />++ <java classname="SolrTest" fork="true" dir="src/apps/SolarTest" failonerror="true">+ <arg line="-test newtest.txt"/>+ <classpath>+ <path refid="test.run.classpath" />+ </classpath>+ </java>+</target>@@ -103,7 +118,7 @@description="Creates the Solr distribution files."depends="dist-src, dist-war, dist-bin" />- <!-- Creates the demo WAR file. -->+ <!-- Creates the Solr WAR file. --><target name="dist-war"description="Creates the demo WAR file."depends="compile">diff --git a/src/apps/SolarTest/protwords.txt b/src/apps/SolarTest/conf/protwords.txtsimilarity index 100%rename from src/apps/SolarTest/protwords.txtrename to src/apps/SolarTest/conf/protwords.txtdiff --git a/src/apps/SolarTest/schema.xml b/src/apps/SolarTest/conf/schema.xmlsimilarity index 100%rename from src/apps/SolarTest/schema.xmlrename to src/apps/SolarTest/conf/schema.xmldiff --git a/src/apps/SolarTest/solrconfig.xml b/src/apps/SolarTest/conf/solrconfig.xmlsimilarity index 100%rename from src/apps/SolarTest/solrconfig.xmlrename to src/apps/SolarTest/conf/solrconfig.xmldiff --git a/src/apps/SolarTest/stopwords.txt b/src/apps/SolarTest/conf/stopwords.txtsimilarity index 100%rename from src/apps/SolarTest/stopwords.txtrename to src/apps/SolarTest/conf/stopwords.txtdiff --git a/src/apps/SolarTest/synonyms.txt b/src/apps/SolarTest/conf/synonyms.txtsimilarity index 100%rename from src/apps/SolarTest/synonyms.txtrename to src/apps/SolarTest/conf/synonyms.txtdiff --git a/src/apps/SolarTest/run b/src/apps/SolarTest/rundeleted file mode 100755index 639600fa881..00000000000--- a/src/apps/SolarTest/run+++ /dev/null@@ -1 +0,0 @@-java -cp "../solar/classes;classes;../../lucene/lucene-1.4.3.jar" SolarPerf -schema test_schema.xml -index F:/root/index -verbose -test newtest.txtdiff --git a/src/apps/SolarTest/src/SolrTest.java b/src/apps/SolarTest/src/SolrTest.javaindex 04894bf9d9b..24e601fa223 100644--- a/src/apps/SolarTest/src/SolrTest.java+++ b/src/apps/SolarTest/src/SolrTest.java@@ -83,7 +83,9 @@ public class SolrTest extends Thread {boolean sequenceTest=false;public void run() {+if (sequenceTest) {+ try {for (int i=0; i<testDict.length; i++) {String s = testDict[i];int lineno = testDictLineno.get(i);@@ -112,9 +114,9 @@ public class SolrTest extends Thread {if (startParams > 0) params = s.substring(startParams+2,endParams).trim();if (startTests > 0) test = s.substring(startTests+1,endTests).trim();- System.out.println("###req=" + req);- System.out.println("###params=" + params);- System.out.println("###tests=" + test);+ // System.out.println("###req=" + req);+ // System.out.println("###params=" + params);+ // System.out.println("###tests=" + test);if (req.startsWith("<")) {resp = doUpdate(req);@@ -127,6 +129,11 @@ public class SolrTest extends Thread {System.out.println("#### no validation performed");}}+ } catch (RuntimeException e) {+ numErr++;+ throw(e);+ }+System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> SUCCESS <<<<<<<<<<<<<<<<<<<<<<<<<<");}@@ -322,47 +329,61 @@ public class SolrTest extends Thread {try {- IndexSchema schema = schemaFile==null ? null : new IndexSchema(schemaFile);- countdown = requests;- core=new SolrCore(dataDir,schema);+ IndexSchema schema = schemaFile==null ? null : new IndexSchema(schemaFile);+ countdown = requests;+ core=new SolrCore(dataDir,schema);- try {- if (testFile != null) {- testDict = readDict(testFile);- testDictLineno = lineno;- } else {- if (readers > 0) requestDict = readDict(filename);- if (writers > 0) updateDict = readDict(updateFilename);+ try {+ if (testFile != null) {+ testDict = readDict(testFile);+ testDictLineno = lineno;+ } else {+ if (readers > 0) requestDict = readDict(filename);+ if (writers > 0) updateDict = readDict(updateFilename);+ }+ } catch (IOException e) {+ e.printStackTrace();+ System.out.println("Can't read "+filename);+ return;}- } catch (IOException e) {- e.printStackTrace();- System.out.println("Can't read "+filename);- return;- }- SolrTest[] clients = new SolrTest[readers+writers];- for (i=0; i<readers; i++) {- clients[i] = new SolrTest();- if (testFile != null) clients[i].sequenceTest=true;- clients[i].start();- }- for (i=readers; i<readers+writers; i++) {- clients[i] = new SolrTest();- clients[i].isWriter = true;- clients[i].start();- }+ SolrTest[] clients = new SolrTest[readers+writers];+ for (i=0; i<readers; i++) {+ clients[i] = new SolrTest();+ if (testFile != null) clients[i].sequenceTest=true;+ clients[i].start();+ }+ for (i=readers; i<readers+writers; i++) {+ clients[i] = new SolrTest();+ clients[i].isWriter = true;+ clients[i].start();+ }- for (i=0; i<readers; i++) {- clients[i].join();- }- for (i=readers; i<readers+writers; i++) {- clients[i].join();- }+ for (i=0; i<readers; i++) {+ clients[i].join();+ }+ for (i=readers; i<readers+writers; i++) {+ clients[i].join();+ }++ core.close();+ core=null;- } finally {- if (core != null) core.close();+ if (testFile!=null) {+ if (clients[0].numErr == 0) {+ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> SUCCESS <<<<<<<<<<<<<<<<<<<<<<<<<<");+ } else {+ System.exit(1);+ }+ }++ } catch (Throwable e) {+ if (core!=null) {try{core.close();} catch (Throwable th){}}+ e.printStackTrace();+ System.exit(1);}+}}