make apps/SolarTest runnable via ant test

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@375736 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-02-07 22:04:39 +00:00
parent 773ec8344b
commit d978defacf
8 changed files with 79 additions and 44 deletions

View File

@ -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">

View File

@ -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.txt

View File

@ -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,46 +329,60 @@ 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) {
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();
}
core.close();
core=null;
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.out.println("Can't read "+filename);
return;
System.exit(1);
}
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();
}
} finally {
if (core != null) core.close();
}
}