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 2012/10/26 20:39:02 UTC
svn commit: r1402613 [3/3] - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/cloud/ core/src/java/org/apache/solr/core/
core/src/java/org/apache/solr/handler/
core/src/java/org/apache/solr/handler/admin/
core/src/java/org/apache/solr/search...
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Fri Oct 26 18:38:59 2012
@@ -54,8 +54,8 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.util.AbstractSolrTestCase;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
/**
* Test for ReplicationHandler
@@ -72,9 +72,9 @@ public class TestReplicationHandler exte
+ File.separator + "collection1" + File.separator + "conf"
+ File.separator;
- static JettySolrRunner masterJetty, slaveJetty;
- static SolrServer masterClient, slaveClient;
- static SolrInstance master = null, slave = null;
+ JettySolrRunner masterJetty, slaveJetty;
+ SolrServer masterClient, slaveClient;
+ SolrInstance master = null, slave = null;
static String context = "/solr";
@@ -83,9 +83,11 @@ public class TestReplicationHandler exte
static int nDocs = 500;
- @BeforeClass
- public static void beforeClass() throws Exception {
- useFactory(null); // need an FS factory
+ @Before
+ public void setup() throws Exception {
+ super.setUp();
+ // For manual testing only
+ // useFactory(null); // force an FS factory
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@@ -109,8 +111,9 @@ public class TestReplicationHandler exte
}
}
- @AfterClass
- public static void afterClass() throws Exception {
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
masterJetty.stop();
slaveJetty.stop();
master.tearDown();
@@ -415,7 +418,7 @@ public class TestReplicationHandler exte
// setup an xslt dir to force subdir file replication
File masterXsltDir = new File(master.getConfDir() + File.separator + "xslt");
File masterXsl = new File(masterXsltDir, "dummy.xsl");
- assertTrue(masterXsltDir.mkdir());
+ assertTrue("could not make dir " + masterXsltDir, masterXsltDir.mkdirs());
assertTrue(masterXsl.createNewFile());
File slaveXsltDir = new File(slave.getConfDir() + File.separator + "xslt");
@@ -596,14 +599,10 @@ public class TestReplicationHandler exte
nDocs--;
masterClient.deleteByQuery("*:*");
- for (int i = 0; i < nDocs; i++)
- index(masterClient, "id", i, "name", "name = " + i);
masterClient.commit();
- NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
- SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
- assertEquals(nDocs, masterQueryResult.getNumFound());
+
//change solrconfig having 'replicateAfter startup' option on master
master.copyConfigFile(CONF_DIR + "solrconfig-master2.xml",
@@ -613,6 +612,16 @@ public class TestReplicationHandler exte
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
+
+ for (int i = 0; i < nDocs; i++)
+ index(masterClient, "id", i, "name", "name = " + i);
+
+ masterClient.commit();
+
+ NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
+ SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
+ assertEquals(nDocs, masterQueryResult.getNumFound());
+
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
@@ -650,15 +659,6 @@ public class TestReplicationHandler exte
//stop slave
slaveJetty.stop();
- masterClient.deleteByQuery("*:*");
- for (int i = 0; i < 10; i++)
- index(masterClient, "id", i, "name", "name = " + i);
-
- masterClient.commit();
-
- NamedList masterQueryRsp = rQuery(10, "*:*", masterClient);
- SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
- assertEquals(10, masterQueryResult.getNumFound());
//change solrconfig having 'replicateAfter startup' option on master
master.copyConfigFile(CONF_DIR + "solrconfig-master3.xml",
@@ -669,6 +669,16 @@ public class TestReplicationHandler exte
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
+ masterClient.deleteByQuery("*:*");
+ for (int i = 0; i < 10; i++)
+ index(masterClient, "id", i, "name", "name = " + i);
+
+ masterClient.commit();
+
+ NamedList masterQueryRsp = rQuery(10, "*:*", masterClient);
+ SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
+ assertEquals(10, masterQueryResult.getNumFound());
+
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java Fri Oct 26 18:38:59 2012
@@ -17,28 +17,24 @@
package org.apache.solr.handler.admin;
+import java.util.Arrays;
+import java.util.EnumSet;
+
import org.apache.solr.common.luke.FieldFlag;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.EnumSet;
-import java.util.Arrays;
-
/**
* :TODO: currently only tests some of the utilities in the LukeRequestHandler
*/
public class LukeRequestHandlerTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
@Before
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java Fri Oct 26 18:38:59 2012
@@ -16,25 +16,23 @@ package org.apache.solr.handler.componen
* limitations under the License.
*/
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.HashMap;
import java.util.TimeZone;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.StatsParams;
-
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.schema.SchemaField;
-
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.schema.SchemaField;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
@@ -42,19 +40,15 @@ import org.apache.solr.util.AbstractSolr
*/
public class StatsComponentTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema11.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
}
@Override
public void setUp() throws Exception {
super.setUp();
+ clearIndex();
lrf = h.getRequestFactory("standard", 0, 20);
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/highlight/HighlighterConfigTest.java Fri Oct 26 18:38:59 2012
@@ -16,16 +16,19 @@
*/
package org.apache.solr.highlight;
+import java.util.HashMap;
+
import org.apache.solr.handler.component.HighlightComponent;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness;
-
-import java.util.HashMap;
+import org.junit.BeforeClass;
public class HighlighterConfigTest extends AbstractSolrTestCase {
- @Override public String getSchemaFile() { return "schema.xml"; }
- // the default case (i.e. <highlight> without a class attribute) is tested every time sorlconfig.xml is used
- @Override public String getSolrConfigFile() { return "solrconfig-highlight.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-highlight.xml", "schema.xml");
+ }
@Override
public void setUp() throws Exception {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java Fri Oct 26 18:38:59 2012
@@ -16,22 +16,22 @@
*/
package org.apache.solr.request;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Locale;
+import java.util.UUID;
+
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.JavaBinCodec;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.response.BinaryQueryResponseWriter;
import org.apache.solr.response.BinaryResponseWriter.Resolver;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.ReturnFields;
-
import org.apache.solr.util.AbstractSolrTestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Locale;
-import java.util.UUID;
+import org.junit.BeforeClass;
/**
* Test for BinaryResponseWriter
@@ -41,14 +41,10 @@ import java.util.UUID;
*/
public class TestBinaryResponseWriter extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
/**
@@ -96,7 +92,7 @@ public class TestBinaryResponseWriter ex
assertTrue("ddd_s not found", out.getFieldNames().contains("ddd_s"));
assertEquals("Wrong number of fields found",
2, out.getFieldNames().size());
-
+ req.close();
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/TestWriterPerf.java Fri Oct 26 18:38:59 2012
@@ -17,30 +17,34 @@
package org.apache.solr.request;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import org.apache.solr.client.solrj.ResponseParser;
+import org.apache.solr.client.solrj.impl.BinaryResponseParser;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.response.BinaryQueryResponseWriter;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.client.solrj.impl.BinaryResponseParser;
-import org.apache.solr.client.solrj.impl.XMLResponseParser;
-
+import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.io.*;
-
public class TestWriterPerf extends AbstractSolrTestCase {
public static final Logger log
= LoggerFactory.getLogger(TestWriterPerf.class);
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig-functionquery.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-functionquery.xml", "schema11.xml");
+ }
+
public String getCoreName() { return "basic"; }
@Override
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Fri Oct 26 18:38:59 2012
@@ -19,13 +19,16 @@ package org.apache.solr.search;
import org.apache.solr.common.SolrException;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
import org.junit.Test;
public class TestExtendedDismaxParser extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema12.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
+ }
+
// public String getCoreName() { return "collection1"; }
@Override
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java Fri Oct 26 18:38:59 2012
@@ -18,13 +18,15 @@ package org.apache.solr.search;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class TestQueryTypes extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+
public String getCoreName() { return "basic"; }
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java Fri Oct 26 18:38:59 2012
@@ -22,7 +22,9 @@ import org.apache.lucene.search.BooleanQ
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.Query;
import org.apache.lucene.index.Term;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
import java.util.List;
@@ -31,10 +33,11 @@ import java.util.List;
*/
public class TestQueryUtils extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
@Override
public void setUp() throws Exception {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSearchPerf.java Fri Oct 26 18:38:59 2012
@@ -19,6 +19,7 @@ package org.apache.solr.search;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.*;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -26,6 +27,7 @@ import org.apache.solr.update.processor.
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.common.SolrInputDocument;
+import org.junit.BeforeClass;
import java.util.*;
import java.io.IOException;
@@ -35,10 +37,12 @@ import java.io.IOException;
*/
public class TestSearchPerf extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema11.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+
@Override
public void setUp() throws Exception {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSurroundQueryParser.java Fri Oct 26 18:38:59 2012
@@ -19,13 +19,14 @@ package org.apache.solr.search;
*/
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class TestSurroundQueryParser extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schemasurround.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schemasurround.xml");
+ }
// public String getCoreName() { return "collection1"; }
@Override
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java Fri Oct 26 18:38:59 2012
@@ -17,6 +17,7 @@ package org.apache.solr.search.function;
*/
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
@@ -24,14 +25,18 @@ import org.apache.solr.util.AbstractSolr
*
**/
public class SortByFunctionTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
+
@Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ public void setUp() throws Exception {
+ super.setUp();
+
}
public void test() throws Exception {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/DirectSolrConnectionTest.java Fri Oct 26 18:38:59 2012
@@ -19,15 +19,19 @@ package org.apache.solr.servlet;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class DirectSolrConnectionTest extends AbstractSolrTestCase
{
- @Override
- public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solr/crazy-path-to-config.xml", "solr/crazy-path-to-schema.xml");
+ }
+
DirectSolrConnection direct;
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/AutoCommitTest.java Fri Oct 26 18:38:59 2012
@@ -34,6 +34,7 @@ import org.apache.solr.response.SolrQuer
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.RefCounted;
+import org.junit.BeforeClass;
class NewSearcherListener implements SolrEventListener {
@@ -108,10 +109,10 @@ class NewSearcherListener implements Sol
@Slow
public class AutoCommitTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
public static void verbose(Object... args) {
if (!VERBOSE) return;
@@ -125,6 +126,14 @@ public class AutoCommitTest extends Abst
log.info(sb.toString());
// System.out.println(sb.toString());
}
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
+ // reload the core to clear stats
+ h.getCoreContainer().reload(h.getCore().getName());
+ }
/**
* Take a string and make it an iterable ContentStream
@@ -141,8 +150,8 @@ public class AutoCommitTest extends Abst
}
public void testMaxDocs() throws Exception {
-
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
DirectUpdateHandler2 updateHandler = (DirectUpdateHandler2)core.getUpdateHandler();
@@ -190,6 +199,7 @@ public class AutoCommitTest extends Abst
public void testMaxTime() throws Exception {
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
core.registerNewSearcherListener(trigger);
DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
@@ -263,6 +273,7 @@ public class AutoCommitTest extends Abst
public void testCommitWithin() throws Exception {
SolrCore core = h.getCore();
+
NewSearcherListener trigger = new NewSearcherListener();
core.registerNewSearcherListener(trigger);
DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerOptimizeTest.java Fri Oct 26 18:38:59 2012
@@ -16,15 +16,15 @@ package org.apache.solr.update;
* limitations under the License.
*/
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import java.io.File;
+import java.io.FileFilter;
+
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
-
-import java.io.File;
-import java.io.FileFilter;
+import org.junit.BeforeClass;
/**
@@ -33,15 +33,9 @@ import java.io.FileFilter;
**/
public class DirectUpdateHandlerOptimizeTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- // return "solrconfig-duh-optimize.xml";
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java Fri Oct 26 18:38:59 2012
@@ -40,7 +40,6 @@ import org.junit.Test;
*/
public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
- // TODO: fix this test to not require FSDirectory
static String savedFactory;
@BeforeClass
public static void beforeClass() throws Exception {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java Fri Oct 26 18:38:59 2012
@@ -32,6 +32,7 @@ import org.apache.solr.core.SolrEventLis
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
+import org.junit.BeforeClass;
/**
* Test auto commit functionality in a way that doesn't suck.
@@ -55,10 +56,11 @@ import org.junit.Before;
@Slow
public class SoftAutoCommitTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
private MockEventListener monitor;
private DirectUpdateHandler2 updater;
@@ -77,6 +79,13 @@ public class SoftAutoCommitTest extends
updater.registerSoftCommitCallback(monitor);
updater.registerCommitCallback(monitor);
}
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // reset stats
+ h.getCoreContainer().reload("collection1");
+ }
public void testSoftAndHardCommitMaxTimeMixedAdds() throws Exception {
@@ -179,7 +188,7 @@ public class SoftAutoCommitTest extends
}
public void testSoftAndHardCommitMaxTimeDelete() throws Exception {
-
+
final int softCommitWaitMillis = 500;
final int hardCommitWaitMillis = 1200;
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java Fri Oct 26 18:38:59 2012
@@ -17,6 +17,7 @@
package org.apache.solr.update;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
@@ -41,9 +42,11 @@ public class TestIndexingPerformance ext
// TODO: fix this test to not require FSDirectory
static String savedFactory;
@BeforeClass
- public static void beforeClass() {
+ public static void beforeClass() throws Exception {
savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
+
+ initCore("solrconfig_perf.xml", "schema12.xml");
}
@AfterClass
public static void afterClass() {
@@ -56,11 +59,7 @@ public class TestIndexingPerformance ext
public static final Logger log
= LoggerFactory.getLogger(TestIndexingPerformance.class);
-
- @Override
- public String getSchemaFile() { return "schema12.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig_perf.xml"; }
+
public void testIndexingPerf() throws IOException {
int iter=1000;
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java Fri Oct 26 18:38:59 2012
@@ -21,21 +21,22 @@ import java.util.HashMap;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.UpdateParams;
-import org.apache.solr.core.*;
+import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.UpdateRequestHandler;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
public class UpdateParamsTest extends AbstractSolrTestCase {
- @Override
- public String getSchemaFile() { return "schema.xml"; }
- @Override
- public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+
/**
* Tests that only update.chain and not update.processor works (SOLR-2105)
*/
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java Fri Oct 26 18:38:59 2012
@@ -17,23 +17,24 @@
package org.apache.solr.update.processor;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.update.processor.UpdateRequestProcessorChain;
-import org.apache.solr.update.processor.CustomUpdateRequestProcessor;
-import org.apache.solr.util.AbstractSolrTestCase;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
import java.util.Arrays;
-import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
*
*/
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
-
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return "solrconfig-transformers.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-transformers.xml", "schema.xml");
+ }
public void testConfiguration() throws Exception
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java Fri Oct 26 18:38:59 2012
@@ -70,6 +70,7 @@ public class ClusterState implements JSO
*/
public ClusterState(Integer zkClusterStateVersion, Set<String> liveNodes,
Map<String, Map<String,Slice>> collectionStates) {
+ this.zkClusterStateVersion = zkClusterStateVersion;
this.liveNodes = new HashSet<String>(liveNodes.size());
this.liveNodes.addAll(liveNodes);
this.collectionStates = new HashMap<String, Map<String,Slice>>(collectionStates.size());
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Fri Oct 26 18:38:59 2012
@@ -197,9 +197,13 @@ public class ZkStateReader {
Stat stat = new Stat();
byte[] data = zkClient.getData(CLUSTER_STATE, thisWatch, stat ,
true);
-
- ClusterState clusterState = ClusterState.load(stat.getVersion(), data,
- ZkStateReader.this.clusterState.getLiveNodes());
+ List<String> liveNodes = zkClient.getChildren(
+ LIVE_NODES_ZKNODE, this, true);
+
+ Set<String> liveNodesSet = new HashSet<String>();
+ liveNodesSet.addAll(liveNodes);
+ Set<String> ln = ZkStateReader.this.clusterState.getLiveNodes();
+ ClusterState clusterState = ClusterState.load(stat.getVersion(), data, ln);
// update volatile
ZkStateReader.this.clusterState = clusterState;
}
@@ -301,9 +305,9 @@ public class ZkStateReader {
ZkStateReader.this.clusterState.getZkClusterStateVersion(), liveNodesSet,
ZkStateReader.this.clusterState.getCollectionStates());
}
+ this.clusterState = clusterState;
}
- this.clusterState = clusterState;
} else {
if (clusterStateUpdateScheduled) {
log.info("Cloud state update for ZooKeeper already scheduled");
@@ -330,7 +334,7 @@ public class ZkStateReader {
clusterState = ClusterState.load(zkClient, liveNodesSet);
} else {
log.info("Updating live nodes from ZooKeeper... ");
- clusterState = new ClusterState(ZkStateReader.this.clusterState .getZkClusterStateVersion(), liveNodesSet, ZkStateReader.this.clusterState.getCollectionStates());
+ clusterState = new ClusterState(ZkStateReader.this.clusterState.getZkClusterStateVersion(), liveNodesSet, ZkStateReader.this.clusterState.getCollectionStates());
}
ZkStateReader.this.clusterState = clusterState;
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Fri Oct 26 18:38:59 2012
@@ -20,6 +20,7 @@ package org.apache.solr.client.solrj;
import java.io.File;
import java.io.IOException;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -28,6 +29,8 @@ import org.apache.solr.common.SolrInputD
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
/**
* Abstract base class for testing merge indexes command
@@ -36,7 +39,6 @@ import org.apache.solr.util.ExternalPath
*
*/
public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
- // protected static final CoreContainer cores = new CoreContainer();
protected static CoreContainer cores;
private String saveProp;
private File dataDir2;
@@ -46,28 +48,30 @@ public abstract class MergeIndexesExampl
return ExternalPaths.EXAMPLE_MULTICORE_HOME;
}
- @Override
- public String getSchemaFile() {
- return getSolrHome() + "/core0/conf/schema.xml";
+ @BeforeClass
+ public static void beforeClass2() throws Exception {
+ if (dataDir == null) {
+ createTempDir();
+ }
+ cores = new CoreContainer();
}
-
- @Override
- public String getSolrConfigFile() {
- return getSolrHome() + "/core0/conf/solrconfig.xml";
+
+ @AfterClass
+ public static void afterClass() {
+ cores.shutdown();
}
-
+
@Override
public void setUp() throws Exception {
saveProp = System.getProperty("solr.directoryFactory");
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
super.setUp();
- cores = h.getCoreContainer();
SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
cores.setPersistent(false);
// setup datadirs
- System.setProperty( "solr.core0.data.dir", this.dataDir.getCanonicalPath() );
+ System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
dataDir2 = new File(TEMP_DIR, getClass().getName() + "-"
+ System.currentTimeMillis());
@@ -82,10 +86,10 @@ public abstract class MergeIndexesExampl
String skip = System.getProperty("solr.test.leavedatadir");
if (null != skip && 0 != skip.trim().length()) {
- System.err.println("NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath());
+ System.err.println("NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir2.getAbsolutePath());
} else {
- if (!recurseDelete(dataDir)) {
- System.err.println("!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!");
+ if (!recurseDelete(dataDir2)) {
+ System.err.println("!!!! WARNING: best effort to remove " + dataDir2.getAbsolutePath() + " FAILED !!!!!");
}
}
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java Fri Oct 26 18:38:59 2012
@@ -19,16 +19,19 @@ package org.apache.solr.client.solrj;
import java.io.File;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
-import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,18 +41,26 @@ import org.junit.Test;
*/
public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
{
- // protected static final CoreContainer cores = new CoreContainer();
- protected CoreContainer cores;
+ protected static CoreContainer cores;
+
private File dataDir2;
@Override public String getSolrHome() { return ExternalPaths.EXAMPLE_MULTICORE_HOME; }
+
- @Override public String getSchemaFile() { return getSolrHome()+"/core0/conf/schema.xml"; }
- @Override public String getSolrConfigFile() { return getSolrHome()+"/core0/conf/solrconfig.xml"; }
+ @BeforeClass
+ public static void beforeThisClass2() throws Exception {
+ cores = new CoreContainer();
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ cores.shutdown();
+ }
@Override public void setUp() throws Exception {
super.setUp();
- cores = h.getCoreContainer();
+
SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
cores.setPersistent(false);
@@ -57,7 +68,7 @@ public abstract class MultiCoreExampleTe
+ System.currentTimeMillis());
dataDir2.mkdirs();
- System.setProperty( "solr.core0.data.dir", this.dataDir.getCanonicalPath() );
+ System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
}
@@ -73,8 +84,6 @@ public abstract class MultiCoreExampleTe
System.err.println("!!!! WARNING: best effort to remove " + dataDir2.getAbsolutePath() + " FAILED !!!!!");
}
}
-
- cores = null;
}
@Override
@@ -208,6 +217,12 @@ public abstract class MultiCoreExampleTe
NamedList<Object> response = getSolrCore("corefoo").query(new SolrQuery().setRequestHandler("/admin/system")).getResponse();
NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
String indexDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("index");
+
+
+
+ System.out.println( (String) ((NamedList<Object>) coreInfo.get("directory")).get("dirimpl"));
+
+
// test delete index on core
CoreAdminRequest.unloadCore("corefoo", true, coreadmin);
File dir = new File(indexDir);
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java Fri Oct 26 18:38:59 2012
@@ -19,6 +19,7 @@ package org.apache.solr.client.solrj;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
/**
* This should include tests against the example solr config
@@ -32,9 +33,13 @@ abstract public class SolrExampleTestBas
{
@Override
public String getSolrHome() { return "../../../example/solr/"; }
-
- @Override public String getSchemaFile() { return getSolrHome()+"conf/schema.xml"; }
- @Override public String getSolrConfigFile() { return getSolrHome()+"conf/solrconfig.xml"; }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ if (dataDir == null) {
+ createTempDir();
+ }
+ }
@Override
public void setUp() throws Exception
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java Fri Oct 26 18:38:59 2012
@@ -56,7 +56,7 @@ public class MultiCoreExampleJettyTest e
jetty.start(false);
port = jetty.getLocalPort();
- h.getCoreContainer().setPersistent(false);
+ cores.setPersistent(false);
}
@Override public void tearDown() throws Exception
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Fri Oct 26 18:38:59 2012
@@ -178,6 +178,7 @@ public abstract class SolrTestCaseJ4 ext
/** Call initCore in @BeforeClass to instantiate a solr core in your test class.
* deleteCore will be called for you via SolrTestCaseJ4 @AfterClass */
public static void initCore(String config, String schema, String solrHome) throws Exception {
+ assertNotNull(solrHome);
configString = config;
schemaString = schema;
testSolrHome = solrHome;
@@ -378,6 +379,7 @@ public abstract class SolrTestCaseJ4 ext
}
public static void createCore() {
+ assertNotNull(testSolrHome);
solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile());
h = new TestHarness( dataDir.getAbsolutePath(),
solrConfig,
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java Fri Oct 26 18:38:59 2012
@@ -44,7 +44,8 @@ public abstract class AbstractDistribZkT
@BeforeClass
public static void beforeThisClass() throws Exception {
- useFactory(null);
+ // Only For Manual Testing: this will force an fs based dir factory
+ //useFactory(null);
}
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Fri Oct 26 18:38:59 2012
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.Atomi
import org.apache.http.params.CoreConnectionPNames;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.BaseDistributedSearchTestCase.RandVal;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -51,10 +52,12 @@ import org.apache.solr.common.cloud.ZkCo
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,9 +104,9 @@ public abstract class AbstractFullDistri
protected Map<String,List<CloudJettyRunner>> shardToJetty = new HashMap<String,List<CloudJettyRunner>>();
private AtomicInteger jettyIntCntr = new AtomicInteger(0);
protected ChaosMonkey chaosMonkey;
- protected volatile ZkStateReader zkStateReader;
protected Map<String,CloudJettyRunner> shardToLeaderJetty = new HashMap<String,CloudJettyRunner>();
+ private boolean cloudInit;
public static class CloudJettyRunner {
public JettySolrRunner jetty;
@@ -195,61 +198,28 @@ public abstract class AbstractFullDistri
}
protected void initCloud() throws Exception {
- if (zkStateReader == null) {
- synchronized (this) {
- if (zkStateReader != null) {
- return;
- }
- zkStateReader = new ZkStateReader(zkServer.getZkAddress(), 10000,
- AbstractZkTestCase.TIMEOUT);
-
- zkStateReader.createClusterStateWatchersAndUpdate();
- }
+ assert(cloudInit == false);
+ cloudInit = true;
+ try {
+ CloudSolrServer server = new CloudSolrServer(zkServer.getZkAddress());
+ server.setDefaultCollection(DEFAULT_COLLECTION);
+ server.getLbServer().getHttpClient().getParams()
+ .setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 5000);
+ server.getLbServer().getHttpClient().getParams()
+ .setParameter(CoreConnectionPNames.SO_TIMEOUT, 20000);
+ cloudClient = server;
- chaosMonkey = new ChaosMonkey(zkServer, zkStateReader,
- DEFAULT_COLLECTION, shardToJetty,
- shardToLeaderJetty);
+ cloudClient.connect();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
}
- // wait until shards have started registering...
- int cnt = 30;
- while (!zkStateReader.getClusterState().getCollections()
- .contains(DEFAULT_COLLECTION)) {
- if (cnt == 0) {
- throw new RuntimeException("timeout waiting for collection1 in cluster state");
- }
- cnt--;
- Thread.sleep(500);
- }
- cnt = 30;
- while (zkStateReader.getClusterState().getSlices(DEFAULT_COLLECTION).size() != sliceCount) {
- if (cnt == 0) {
- throw new RuntimeException("timeout waiting for collection shards to come up");
- }
- cnt--;
- Thread.sleep(500);
- }
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
- // use the distributed solrj client
- if (cloudClient == null) {
- synchronized (this) {
- if (cloudClient != null) {
- return;
- }
- try {
- CloudSolrServer server = new CloudSolrServer(zkServer.getZkAddress());
- server.setDefaultCollection(DEFAULT_COLLECTION);
- server.getLbServer().getHttpClient().getParams()
- .setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 5000);
- server.getLbServer().getHttpClient().getParams()
- .setParameter(CoreConnectionPNames.SO_TIMEOUT, 20000);
- cloudClient = server;
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
- }
+ chaosMonkey = new ChaosMonkey(zkServer, zkStateReader, DEFAULT_COLLECTION,
+ shardToJetty, shardToLeaderJetty);
}
+
@Override
protected void createServers(int numServers) throws Exception {
@@ -270,8 +240,31 @@ public abstract class AbstractFullDistri
}
controlClient = createNewSolrServer(controlJetty.getLocalPort());
+ initCloud();
+
createJettys(numServers, true);
+ // wait until shards have started registering...
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
+ int cnt = 30;
+ while (!zkStateReader.getClusterState().getCollections()
+ .contains(DEFAULT_COLLECTION)) {
+ if (cnt == 0) {
+ throw new RuntimeException(
+ "timeout waiting for collection1 in cluster state");
+ }
+ cnt--;
+ Thread.sleep(500);
+ }
+ cnt = 30;
+ while (zkStateReader.getClusterState().getSlices(DEFAULT_COLLECTION).size() != sliceCount) {
+ if (cnt == 0) {
+ throw new RuntimeException(
+ "timeout waiting for collection shards to come up");
+ }
+ cnt--;
+ Thread.sleep(500);
+ }
}
protected List<JettySolrRunner> createJettys(int numJettys) throws Exception {
@@ -302,9 +295,7 @@ public abstract class AbstractFullDistri
SolrServer client = createNewSolrServer(j.getLocalPort());
clients.add(client);
}
-
- initCloud();
-
+
this.jettys.addAll(jettys);
this.clients.addAll(clients);
@@ -324,6 +315,7 @@ public abstract class AbstractFullDistri
Thread.sleep(500);
}
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
// also make sure we have a leader for each shard
for (int i = 1; i <= sliceCount; i++) {
zkStateReader.getLeaderProps(DEFAULT_COLLECTION, "shard" + i, 10000);
@@ -346,7 +338,8 @@ public abstract class AbstractFullDistri
}
protected int getNumShards(String defaultCollection) {
- Map<String,Slice> slices = this.zkStateReader.getClusterState().getSlices(defaultCollection);
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
+ Map<String,Slice> slices = zkStateReader.getClusterState().getSlices(defaultCollection);
int cnt = 0;
for (Map.Entry<String,Slice> entry : slices.entrySet()) {
cnt += entry.getValue().getReplicasMap().size();
@@ -369,6 +362,7 @@ public abstract class AbstractFullDistri
protected void updateMappingsFromZk(List<JettySolrRunner> jettys,
List<SolrServer> clients) throws Exception {
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
zkStateReader.updateClusterState(true);
cloudJettys.clear();
shardToJetty.clear();
@@ -555,11 +549,13 @@ public abstract class AbstractFullDistri
protected void waitForRecoveriesToFinish(boolean verbose)
throws Exception {
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
super.waitForRecoveriesToFinish(DEFAULT_COLLECTION, zkStateReader, verbose);
}
protected void waitForRecoveriesToFinish(boolean verbose, int timeoutSeconds)
throws Exception {
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
super.waitForRecoveriesToFinish(DEFAULT_COLLECTION, zkStateReader, verbose, true, timeoutSeconds);
}
@@ -756,7 +752,7 @@ public abstract class AbstractFullDistri
String failMessage = null;
if (verbose) System.err.println("check const of " + shard);
int cnt = 0;
-
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
assertEquals(
"The client count does not match up with the shard count for slice:"
+ shard,
@@ -968,7 +964,7 @@ public abstract class AbstractFullDistri
}
}
}
-
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
long count = 0;
String currentState = cjetty.info.getStr(ZkStateReader.STATE_PROP);
if (currentState != null
@@ -1167,13 +1163,12 @@ public abstract class AbstractFullDistri
if (VERBOSE || printLayoutOnTearDown) {
super.printLayout();
}
- ((HttpSolrServer) controlClient).shutdown();
+ if (controlClient != null) {
+ ((HttpSolrServer) controlClient).shutdown();
+ }
if (cloudClient != null) {
cloudClient.shutdown();
}
- if (zkStateReader != null) {
- zkStateReader.close();
- }
super.tearDown();
System.clearProperty("zkHost");
@@ -1186,7 +1181,9 @@ public abstract class AbstractFullDistri
}
protected void destroyServers() throws Exception {
- ChaosMonkey.stop(controlJetty);
+ if (controlJetty != null) {
+ ChaosMonkey.stop(controlJetty);
+ }
for (JettySolrRunner jetty : jettys) {
try {
ChaosMonkey.stop(jetty);
@@ -1216,13 +1213,25 @@ public abstract class AbstractFullDistri
protected void waitToSeeNotLive(ZkStateReader zkStateReader,
CloudJettyRunner cjetty) throws InterruptedException {
+ waitToSeeNotLive(zkStateReader, cjetty, 0);
+ }
+
+ protected void waitToSeeNotLive(ZkStateReader zkStateReader,
+ CloudJettyRunner cjetty, int cnt) throws InterruptedException {
int tries = 0;
- while (zkStateReader.getClusterState()
- .liveNodesContain(cjetty.info.getStr(ZkStateReader.NODE_NAME_PROP))) {
- if (tries++ == 220) {
- fail("Shard still reported as live in zk");
+ ClusterState clusterState = zkStateReader.getClusterState();
+ while (clusterState.liveNodesContain(cjetty.info
+ .getStr(ZkStateReader.NODE_NAME_PROP))) {
+ System.out.println("scs:"
+ + zkStateReader.getClusterState().getZkClusterStateVersion() + " "
+ + zkStateReader.getClusterState().getLiveNodes());
+ System.out.println("see live nodes:"
+ + zkStateReader.getClusterState().getLiveNodes());
+ if (tries++ == 30) {
+ fail("Shard still reported as live in zk - " + cnt + " jetty");
}
- Thread.sleep(1000);
+
+ clusterState = zkStateReader.getClusterState();
}
}
}
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java Fri Oct 26 18:38:59 2012
@@ -189,7 +189,7 @@ public class ChaosMonkey {
}
private static void stopJettySolrRunner(JettySolrRunner jetty) throws Exception {
-
+ assert(jetty != null);
monkeyLog("stop shard! " + jetty.getLocalPort());
// get a clean shutdown so that no dirs are left open...
FilterHolder fh = jetty.getDispatchFilter();
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java Fri Oct 26 18:38:59 2012
@@ -17,7 +17,6 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import java.io.File;
import java.io.IOException;
import org.apache.lucene.store.Directory;
@@ -27,7 +26,7 @@ import org.apache.lucene.util.LuceneTest
/**
* Opens a directory with {@link LuceneTestCase#newDirectory()}
*/
-public class MockDirectoryFactory extends CachingDirectoryFactory {
+public class MockDirectoryFactory extends EphemeralDirectoryFactory {
@Override
protected Directory create(String path) throws IOException {
@@ -41,23 +40,13 @@ public class MockDirectoryFactory extend
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setAssertNoUnrefencedFilesOnClose(false);
}
- return dir;
- }
-
- @Override
- public boolean exists(String path) {
- String fullPath = new File(path).getAbsolutePath();
- synchronized (this) {
- CacheValue cacheValue = byPathCache.get(fullPath);
- Directory directory = null;
- if (cacheValue != null) {
- directory = cacheValue.directory;
- }
- if (directory == null) {
- return false;
- } else {
- return true;
- }
+
+ // ram dirs in cores that are restarted end up empty
+ // and check index fails
+ if (dir instanceof MockDirectoryWrapper) {
+ ((MockDirectoryWrapper)dir).setCheckIndexOnClose(false);
}
+ return dir;
}
+
}
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java Fri Oct 26 18:38:59 2012
@@ -27,7 +27,7 @@ import org.apache.lucene.util.LuceneTest
/**
* Opens a directory with {@link LuceneTestCase#newFSDirectory(File)}
*/
-public class MockFSDirectoryFactory extends CachingDirectoryFactory {
+public class MockFSDirectoryFactory extends StandardDirectoryFactory {
@Override
public Directory create(String path) throws IOException {
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java Fri Oct 26 18:38:59 2012
@@ -19,29 +19,18 @@
package org.apache.solr.util;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.util.HashSet;
-import javax.xml.xpath.XPathExpressionException;
-
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.QuickPatchThreadsFilter;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.*;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.XML;
+import org.apache.solr.common.SolrException;
import org.apache.solr.core.SolrConfig;
-import org.apache.solr.request.SolrQueryRequest;
-import org.junit.*;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xml.sax.SAXException;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
/**
* An Abstract base class that makes writing Solr JUnit tests "easier"
@@ -60,39 +49,9 @@ import com.carrotsearch.randomizedtestin
SolrIgnoredThreadsFilter.class,
QuickPatchThreadsFilter.class
})
-public abstract class AbstractSolrTestCase extends LuceneTestCase {
+public abstract class AbstractSolrTestCase extends SolrTestCaseJ4 {
protected SolrConfig solrConfig;
- /**
- * Harness initialized by initTestHarness.
- *
- * <p>
- * For use in test methods as needed.
- * </p>
- */
- protected TestHarness h;
-
- /**
- * LocalRequestFactory initialized by initTestHarness using sensible
- * defaults.
- *
- * <p>
- * For use in test methods as needed.
- * </p>
- */
- protected TestHarness.LocalRequestFactory lrf;
-
- /**
- * Subclasses must define this method to return the name of the
- * schema.xml they wish to use.
- */
- public abstract String getSchemaFile();
-
- /**
- * Subclasses must define this method to return the name of the
- * solrconfig.xml they wish to use.
- */
- public abstract String getSolrConfigFile();
/**
* Subclasses can override this to change a test's solr home
@@ -101,69 +60,9 @@ public abstract class AbstractSolrTestCa
public String getSolrHome() {
return SolrTestCaseJ4.TEST_HOME();
}
-
- @ClassRule
- public static TestRule solrClassRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule())
- .around(new RevertDefaultThreadHandlerRule());
-
- @Rule
- public TestRule solrTestRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule());
-
- @BeforeClass
- public static void beforeClassAbstractSolrTestCase() {
- SolrTestCaseJ4.startTrackingSearchers();
- }
-
- @AfterClass
- public static void afterClassAbstractSolrTestCase() {
- SolrTestCaseJ4.endTrackingSearchers();
- }
-
- /**
- * The directory used to story the index managed by the TestHarness h
- */
- protected File dataDir;
public static Logger log = LoggerFactory.getLogger(AbstractSolrTestCase.class);
- private String factoryProp;
-
- /**
- * Initializes things your test might need
- *
- * <ul>
- * <li>Creates a dataDir in the "java.io.tmpdir"</li>
- * <li>initializes the TestHarness h using this data directory, and getSchemaPath()</li>
- * <li>initializes the LocalRequestFactory lrf using sensible defaults.</li>
- * </ul>
- */
- @Override
- public void setUp() throws Exception {
- super.setUp();
- log.info("####SETUP_START " + getTestName());
- ignoreException("ignore_exception");
- factoryProp = System.getProperty("solr.directoryFactory");
- if (factoryProp == null) {
- System.setProperty("solr.directoryFactory","solr.RAMDirectoryFactory");
- }
- dataDir = new File(TEMP_DIR,
- getClass().getName() + "-" + System.currentTimeMillis());
- dataDir.mkdirs();
- String configFile = getSolrConfigFile();
- System.setProperty("solr.solr.home", getSolrHome());
- if (configFile != null) {
-
- solrConfig = TestHarness.createConfig(getSolrHome(), getSolrConfigFile());
- h = new TestHarness( dataDir.getAbsolutePath(),
- solrConfig,
- getSchemaFile());
- lrf = h.getRequestFactory
- ("standard",0,20,CommonParams.VERSION,"2.2");
- }
- log.info("####SETUP_END " + getTestName());
- }
/** Causes an exception matching the regex pattern to not be logged. */
public static void ignoreException(String pattern) {
@@ -194,146 +93,8 @@ public abstract class AbstractSolrTestCa
log.info("####PRETEARDOWN " + getTestName());
}
- /**
- * Shuts down the test harness, and makes the best attempt possible
- * to delete dataDir, unless the system property "solr.test.leavedatadir"
- * is set.
- */
- @Override
- public void tearDown() throws Exception {
- log.info("####TEARDOWN_START " + getTestName());
- if (factoryProp == null) {
- System.clearProperty("solr.directoryFactory");
- }
-
- if (h != null) { h.close(); }
- String skip = System.getProperty("solr.test.leavedatadir");
- if (null != skip && 0 != skip.trim().length()) {
- System.err.println("NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath());
- } else {
- if (!recurseDelete(dataDir)) {
- System.err.println("!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!");
- }
- }
-
- resetExceptionIgnores();
- super.tearDown();
- }
-
- /** Validates an update XML String is successful
- */
- public void assertU(String update) {
- assertU(null, update);
- }
-
- /** Validates an update XML String is successful
- */
- public void assertU(String message, String update) {
- checkUpdateU(message, update, true);
- }
-
- /** Validates an update XML String failed
- */
- public void assertFailedU(String update) {
- assertFailedU(null, update);
- }
-
- /** Validates an update XML String failed
- */
- public void assertFailedU(String message, String update) {
- checkUpdateU(message, update, false);
- }
-
- /** Checks the success or failure of an update message
- */
- private void checkUpdateU(String message, String update, boolean shouldSucceed) {
- try {
- String m = (null == message) ? "" : message + " ";
- if (shouldSucceed) {
- String res = h.validateUpdate(update);
- if (res != null) fail(m + "update was not successful: " + res);
- } else {
- String res = h.validateErrorUpdate(update);
- if (res != null) fail(m + "update succeeded, but should have failed: " + res);
- }
- } catch (SAXException e) {
- throw new RuntimeException("Invalid XML", e);
- }
- }
-
- /** Validates a query matches some XPath test expressions and closes the query */
- public void assertQ(SolrQueryRequest req, String... tests) {
- assertQ(null, req, tests);
- }
-
- /** Validates a query matches some XPath test expressions and closes the query */
- public void assertQ(String message, SolrQueryRequest req, String... tests) {
- try {
- String m = (null == message) ? "" : message + " ";
- String response = h.query(req);
- String results = h.validateXPath(response, tests);
- if (null != results) {
- fail(m + "query failed XPath: " + results +
- "\n xml response was: " + response +
- "\n request was: " + req.getParamString());
- }
- } catch (XPathExpressionException e1) {
- throw new RuntimeException("XPath is invalid", e1);
- } catch (Exception e2) {
- throw new RuntimeException("Exception during query", e2);
- }
- }
-
- /** Makes sure a query throws a SolrException with the listed response code */
- public void assertQEx(String message, SolrQueryRequest req, int code ) {
- try {
- h.query(req);
- fail( message );
- } catch (SolrException sex) {
- assertEquals( code, sex.code() );
- } catch (Exception e2) {
- throw new RuntimeException("Exception during query", e2);
- }
- }
-
- public void assertQEx(String message, SolrQueryRequest req, SolrException.ErrorCode code ) {
- try {
- h.query(req);
- fail( message );
- } catch (SolrException e) {
- assertEquals( code.code, e.code() );
- } catch (Exception e2) {
- throw new RuntimeException("Exception during query", e2);
- }
- }
-
-
- /**
- * @see TestHarness#optimize
- */
- public String optimize(String... args) {
- return TestHarness.optimize(args);
- }
- /**
- * @see TestHarness#commit
- */
- public String commit(String... args) {
- return TestHarness.commit(args);
- }
/**
- * Generates a simple <add><doc>... XML String with no options
- *
- * @param fieldsAndValues 0th and Even numbered args are fields names odds are field values.
- * @see #add
- * @see #doc
- */
- public String adoc(String... fieldsAndValues) {
- Doc d = doc(fieldsAndValues);
- return add(d);
- }
-
- /**
* Generates a simple <add><doc>... XML String with the
* commitWithin attribute.
*
@@ -343,53 +104,10 @@ public abstract class AbstractSolrTestCa
* @see #doc
*/
public String adoc(int commitWithin, String... fieldsAndValues) {
- Doc d = doc(fieldsAndValues);
+ XmlDoc d = doc(fieldsAndValues);
return add(d, "commitWithin", String.valueOf(commitWithin));
}
- /**
- * Generates a simple <add><doc>... XML String with no options
- */
- public String adoc(SolrInputDocument sdoc) {
- List<String> fields = new ArrayList<String>();
- for (SolrInputField sf : sdoc) {
- for (Object o : sf.getValues()) {
- fields.add(sf.getName());
- fields.add(o.toString());
- }
- }
- return adoc(fields.toArray(new String[fields.size()]));
- }
-
-
- /**
- * Generates an <add><doc>... XML String with options
- * on the add.
- *
- * @param doc the Document to add
- * @param args 0th and Even numbered args are param names, Odds are param values.
- * @see #add
- * @see #doc
- */
- public String add(Doc doc, String... args) {
- try {
- StringWriter r = new StringWriter();
-
- // this is anoying
- if (null == args || 0 == args.length) {
- r.write("<add>");
- r.write(doc.xml);
- r.write("</add>");
- } else {
- XML.writeUnescapedXML(r, "add", doc.xml, (Object[])args);
- }
-
- return r.getBuffer().toString();
- } catch (IOException e) {
- throw new RuntimeException
- ("this should never happen with a StringWriter", e);
- }
- }
/**
* Generates a <delete>... XML string for an ID
@@ -408,49 +126,7 @@ public abstract class AbstractSolrTestCa
public String delQ(String q, String... args) {
return TestHarness.deleteByQuery(q, args);
}
-
- /**
- * Generates a simple <doc>... XML String with no options
- *
- * @param fieldsAndValues 0th and Even numbered args are fields names, Odds are field values.
- * @see TestHarness#makeSimpleDoc
- */
- public Doc doc(String... fieldsAndValues) {
- Doc d = new Doc();
- d.xml = TestHarness.makeSimpleDoc(fieldsAndValues).toString();
- return d;
- }
- /**
- * Generates a SolrQueryRequest using the LocalRequestFactory
- * @see #lrf
- */
- public SolrQueryRequest req(String... q) {
- return lrf.makeRequest(q);
- }
-
- /**
- * Generates a SolrQueryRequest using the LocalRequestFactory
- * @see #lrf
- */
- public SolrQueryRequest req(String[] params, String... moreParams) {
- String[] allParams = moreParams;
- if (params.length!=0) {
- int len = params.length + moreParams.length;
- allParams = new String[len];
- System.arraycopy(params,0,allParams,0,params.length);
- System.arraycopy(moreParams,0,allParams,params.length,moreParams.length);
- }
-
- return lrf.makeRequest(allParams);
- }
-
- /** Neccessary to make method signatures un-ambiguous */
- public static class Doc {
- public String xml;
- @Override
- public String toString() { return xml; }
- }
public static boolean recurseDelete(File f) {
if (f.isDirectory()) {
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java?rev=1402613&r1=1402612&r2=1402613&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java Fri Oct 26 18:38:59 2012
@@ -72,7 +72,7 @@ import java.util.Map;
*/
public class TestHarness {
String coreName;
- protected CoreContainer container;
+ protected volatile CoreContainer container;
private final ThreadLocal<DocumentBuilder> builderTL = new ThreadLocal<DocumentBuilder>();
private final ThreadLocal<XPath> xpathTL = new ThreadLocal<XPath>();
public UpdateRequestHandler updater;
@@ -124,6 +124,7 @@ public class TestHarness {
public TestHarness(String coreName, CoreContainer.Initializer init) {
try {
+
container = init.initialize();
if (coreName == null)
coreName = CoreContainer.DEFAULT_DEFAULT_CORE_NAME;