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 2013/02/22 23:18:02 UTC
svn commit: r1449241 - in /lucene/dev/branches/branch_4x: ./ dev-tools/
lucene/ lucene/analysis/
lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/
lucene/benchmark/ lucene/classification/ lucene/codecs/ lucene/core/
lucene/cor...
Author: markrmiller
Date: Fri Feb 22 22:18:00 2013
New Revision: 1449241
URL: http://svn.apache.org/r1449241
Log:
SOLR-4471: Improve and clean up TestReplicationHandler.
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/BUILD.txt (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt (props changed)
lucene/dev/branches/branch_4x/lucene/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/MIGRATE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/README.txt (props changed)
lucene/dev/branches/branch_4x/lucene/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java (props changed)
lucene/dev/branches/branch_4x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_4x/lucene/build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/classification/ (props changed)
lucene/dev/branches/branch_4x/lucene/codecs/ (props changed)
lucene/dev/branches/branch_4x/lucene/common-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSortDocValues.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollector.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestTotalHitCountCollector.java (props changed)
lucene/dev/branches/branch_4x/lucene/demo/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/grouping/ (props changed)
lucene/dev/branches/branch_4x/lucene/highlighter/ (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (props changed)
lucene/dev/branches/branch_4x/lucene/join/ (props changed)
lucene/dev/branches/branch_4x/lucene/licenses/ (props changed)
lucene/dev/branches/branch_4x/lucene/memory/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/module-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/queries/ (props changed)
lucene/dev/branches/branch_4x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_4x/lucene/sandbox/ (props changed)
lucene/dev/branches/branch_4x/lucene/site/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/suggest/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/tools/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/solr/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/README.txt (props changed)
lucene/dev/branches/branch_4x/solr/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/solr/build.xml (props changed)
lucene/dev/branches/branch_4x/solr/cloud-dev/ (props changed)
lucene/dev/branches/branch_4x/solr/common-build.xml (props changed)
lucene/dev/branches/branch_4x/solr/contrib/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/scripts/ (props changed)
lucene/dev/branches/branch_4x/solr/site/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/testlogging.properties (props changed)
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1449241&r1=1449240&r2=1449241&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Fri Feb 22 22:18:00 2013
@@ -181,6 +181,9 @@ Other Changes
* SOLR-2470: Added more tests for VelocityResponseWriter
+* SOLR-4471: Improve and clean up TestReplicationHandler.
+ (Amit Nithian via Mark Miller)
+
================== 4.1.0 ==================
Versions of Major Components
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1449241&r1=1449240&r2=1449241&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Fri Feb 22 22:18:00 2013
@@ -58,6 +58,7 @@ import org.apache.solr.common.util.Simpl
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.After;
import org.junit.Before;
+import org.junit.Test;
/**
* Test for ReplicationHandler
@@ -88,6 +89,7 @@ public class TestReplicationHandler exte
@Before
public void setUp() throws Exception {
super.setUp();
+// System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
// For manual testing only
// useFactory(null); // force an FS factory
master = new SolrInstance("master", null);
@@ -252,20 +254,8 @@ public class TestReplicationHandler exte
return res;
}
- public void test() throws Exception {
- doTestReplicateAfterCoreReload();
- doTestDetails();
- doTestReplicateAfterWrite2Slave();
- doTestIndexAndConfigReplication();
- doTestStopPoll();
- doTestSnapPullWithMasterUrl();
- doTestReplicateAfterStartup();
- doTestReplicateAfterStartupWithNoActivity();
- doTestIndexAndConfigAliasReplication();
- doTestBackup();
- }
-
- private void doTestDetails() throws Exception {
+ @Test
+ public void doTestDetails() throws Exception {
{
NamedList<Object> details = getDetails(masterClient);
@@ -318,22 +308,17 @@ public class TestReplicationHandler exte
}
}
- private void doTestReplicateAfterWrite2Slave() throws Exception {
+ @Test
+ public void doTestReplicateAfterWrite2Slave() throws Exception {
clearIndexWithReplication();
nDocs--;
for (int i = 0; i < nDocs; i++) {
index(masterClient, "id", i, "name", "name = " + i);
}
- String masterUrl = "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication?command=disableReplication";
- URL url = new URL(masterUrl);
- InputStream stream = url.openStream();
- try {
- stream.close();
- } catch (IOException e) {
- //e.printStackTrace();
- }
-
+ invokeReplicationCommand(masterJetty.getLocalPort(), "disableReplication");
+ invokeReplicationCommand(slaveJetty.getLocalPort(), "disablepoll");
+
masterClient.commit();
NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
@@ -355,6 +340,7 @@ public class TestReplicationHandler exte
slaveClient.commit(true, true);
+
//this doc is added to slave so it should show an item w/ that result
SolrDocumentList slaveQueryResult = null;
NamedList slaveQueryRsp;
@@ -362,15 +348,11 @@ public class TestReplicationHandler exte
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(1, slaveQueryResult.getNumFound());
- masterUrl = "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication?command=enableReplication";
- url = new URL(masterUrl);
- stream = url.openStream();
- try {
- stream.close();
- } catch (IOException e) {
- //e.printStackTrace();
- }
+ //Let's fetch the index rather than rely on the polling.
+ invokeReplicationCommand(masterJetty.getLocalPort(), "enablereplication");
+ invokeReplicationCommand(slaveJetty.getLocalPort(), "fetchindex");
+ /*
//the slave should have done a full copy of the index so the doc with id:555 should not be there in the slave now
slaveQueryRsp = rQuery(0, "id:555", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
@@ -380,9 +362,26 @@ public class TestReplicationHandler exte
slaveQueryRsp = rQuery(nDocs, "*:*", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(nDocs, slaveQueryResult.getNumFound());
+
+ */
}
- private void doTestIndexAndConfigReplication() throws Exception {
+ //Simple function to wrap the invocation of replication commands on the various
+ //jetty servers.
+ private void invokeReplicationCommand(int pJettyPort, String pCommand) throws IOException
+ {
+ String masterUrl = "http://127.0.0.1:" + pJettyPort + "/solr/replication?command=" + pCommand;
+ try {
+ URL u = new URL(masterUrl);
+ InputStream stream = u.openStream();
+ stream.close();
+ } catch (IOException e) {
+ //e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void doTestIndexAndConfigReplication() throws Exception {
clearIndexWithReplication();
nDocs--;
@@ -451,7 +450,8 @@ public class TestReplicationHandler exte
}
- private void doTestStopPoll() throws Exception {
+ @Test
+ public void doTestStopPoll() throws Exception {
clearIndexWithReplication();
// Test:
@@ -477,14 +477,8 @@ public class TestReplicationHandler exte
assertEquals(null, cmp);
// start stop polling test
- String slaveURL = "http://127.0.0.1:" + slaveJetty.getLocalPort() + "/solr/replication?command=disablepoll";
- URL url = new URL(slaveURL);
- InputStream stream = url.openStream();
- try {
- stream.close();
- } catch (IOException e) {
- //e.printStackTrace();
- }
+ invokeReplicationCommand(slaveJetty.getLocalPort(), "disablepoll");
+
index(masterClient, "id", 501, "name", "name = " + 501);
masterClient.commit();
@@ -503,22 +497,15 @@ public class TestReplicationHandler exte
assertEquals(nDocs, slaveQueryResult.getNumFound());
// re-enable replication
- slaveURL = "http://127.0.0.1:" + slaveJetty.getLocalPort() + "/solr/replication?command=enablepoll";
- url = new URL(slaveURL);
- stream = url.openStream();
- try {
- stream.close();
- } catch (IOException e) {
- //e.printStackTrace();
- }
+ invokeReplicationCommand(slaveJetty.getLocalPort(), "enablepoll");
slaveQueryRsp = rQuery(nDocs+1, "*:*", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(nDocs+1, slaveQueryResult.getNumFound());
}
-
- private void doTestSnapPullWithMasterUrl() throws Exception {
+ @Test
+ public void doTestSnapPullWithMasterUrl() throws Exception {
//change solrconfig on slave
//this has no entry for pollinginterval
slave.copyConfigFile(CONF_DIR + "solrconfig-slave1.xml", "solrconfig.xml");
@@ -823,7 +810,8 @@ public class TestReplicationHandler exte
}
}
- private void doTestReplicateAfterCoreReload() throws Exception {
+ @Test
+ public void doTestReplicateAfterCoreReload() throws Exception {
int docs = TEST_NIGHTLY ? 200000 : 0;
//stop slave
@@ -902,7 +890,8 @@ public class TestReplicationHandler exte
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}
- private void doTestIndexAndConfigAliasReplication() throws Exception {
+ @Test
+ public void doTestIndexAndConfigAliasReplication() throws Exception {
clearIndexWithReplication();
nDocs--;
@@ -975,8 +964,8 @@ public class TestReplicationHandler exte
}
-
- private void doTestBackup() throws Exception {
+ @Test
+ public void doTestBackup() throws Exception {
String configFile = "solrconfig-master1.xml";
boolean addNumberToKeepInRequest = true;
String backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM;
@@ -1222,7 +1211,7 @@ public class TestReplicationHandler exte
}
public void tearDown() throws Exception {
- AbstractSolrTestCase.recurseDelete(homeDir);
+ AbstractSolrTestCase.recurseDelete(homeDir.getParentFile());
}
public void copyConfigFile(String srcFile, String destFile)