fix up test

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1449496 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-02-24 15:34:42 +00:00
parent 4de7dd999c
commit 382e279c1b
1 changed files with 61 additions and 117 deletions

View File

@ -449,16 +449,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
assertTrue(slaveXsltDir.isDirectory());
assertTrue(slaveXsl.exists());
// revert the schema
master.copyConfigFile(CONF_DIR + "schema-replication1.xml", "schema.xml");
masterJetty.stop();
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
slave.copyConfigFile(CONF_DIR + "schema-replication1.xml", "schema.xml");
slaveJetty.stop();
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}
@Test
@ -732,20 +722,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult, slaveQueryResult, 0, null);
assertEquals(null, cmp);
// NOTE: the master only replicates after startup now!
// revert that change.
master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml");
masterJetty.stop();
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
//start slave
slaveJetty.stop();
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}
@Test
@ -775,7 +751,8 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
masterClient.commit();
// now we restart to test what happens with no activity before the slave tries to
// now we restart to test what happens with no activity before the slave
// tries to
// replicate
masterJetty.stop();
masterJetty.start(true);
@ -783,10 +760,10 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// masterClient = createNewSolrServer(masterJetty.getLocalPort());
NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp
.get("response");
assertEquals(nDocs, masterQueryResult.getNumFound());
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
@ -796,27 +773,15 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// get docs from slave and check if number is equal to master
NamedList slaveQueryRsp = rQuery(nDocs, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp
.get("response");
assertEquals(nDocs, slaveQueryResult.getNumFound());
// compare results
String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult, slaveQueryResult, 0, null);
String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult,
slaveQueryResult, 0, null);
assertEquals(null, cmp);
// NOTE: the master only replicates after startup now!
// revert that change.
master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml");
masterJetty.stop();
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
//start slave
slaveJetty.stop();
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
} finally {
resetFactory();
}
@ -887,23 +852,10 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(docs + 2, slaveQueryResult.getNumFound());
// NOTE: revert config on master.
master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml");
masterJetty.stop();
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
//start slave
slaveJetty.stop();
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}
@Test
@Ignore("ignore while i track down the intermittent problem with this test")
//@Ignore("ignore while i track down the intermittent problem with this test")
public void doTestIndexAndConfigAliasReplication() throws Exception {
clearIndexWithReplication();
@ -956,6 +908,9 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
slaveClient.deleteByQuery("*:*");
slaveClient.commit();
//add a doc with new field and commit on master to trigger snappull from slave.
index(masterClient, "id", "2000", "name", "name = " + 2000, "newname", "newname = " + 2000);
masterClient.commit();
@ -968,6 +923,9 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
SolrDocumentList slaveQueryResult2 = (SolrDocumentList) slaveQueryRsp2.get("response");
assertEquals(1, slaveQueryResult2.getNumFound());
// we need to wait until the core is reloaded
rQuery(1, "*:*", slaveClient);
index(slaveClient, "id", "2000", "name", "name = " + 2001, "newname", "newname = " + 2001);
slaveClient.commit();
@ -975,20 +933,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
SolrDocument d = ((SolrDocumentList) slaveQueryRsp.get("response")).get(0);
assertEquals("newname = 2001", (String) d.getFieldValue("newname"));
// revert configs
master.copyConfigFile(CONF_DIR + "solrconfig-master1.xml",
"solrconfig.xml");
master.copyConfigFile(CONF_DIR + "schema-replication1.xml",
"schema.xml");
masterJetty.stop();
masterJetty = createJetty(master);
masterClient = createNewSolrServer(masterJetty.getLocalPort());
slave.copyConfigFile(CONF_DIR + "schema-replication1.xml", "schema.xml");
slaveJetty.stop();
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}