mirror of https://github.com/apache/lucene.git
SOLR-1469: fix TestReplicationHandler failures
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@981594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
756fc04196
commit
3885ed48ac
|
@ -80,12 +80,15 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
masterClient.deleteByQuery("*:*");
|
|
||||||
masterClient.commit();
|
NamedList res = query("*:*", masterClient);
|
||||||
rQuery(0, "*:*", masterClient);
|
SolrDocumentList docs = (SolrDocumentList)res.get("response");
|
||||||
slaveClient.deleteByQuery("*:*");
|
if (docs.getNumFound() != 0) {
|
||||||
slaveClient.commit();
|
masterClient.deleteByQuery("*:*");
|
||||||
rQuery(0, "*:*", slaveClient);
|
masterClient.commit();
|
||||||
|
// wait for replication to sync
|
||||||
|
rQuery(0, "*:*", slaveClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -155,6 +158,71 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReplicateAfterWrite2Slave() throws Exception {
|
||||||
|
//add 50 docs to master
|
||||||
|
int nDocs = 50;
|
||||||
|
for (int i = 0; i < nDocs; i++) {
|
||||||
|
index(masterClient, "id", i, "name", "name = " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
String masterUrl = "http://localhost:" + masterJetty.getLocalPort() + "/solr/replication?command=disableReplication";
|
||||||
|
URL url = new URL(masterUrl);
|
||||||
|
InputStream stream = url.openStream();
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
masterClient.commit();
|
||||||
|
|
||||||
|
NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
|
||||||
|
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
|
||||||
|
assertEquals(nDocs, masterQueryResult.getNumFound());
|
||||||
|
|
||||||
|
// Make sure that both the index version and index generation on the slave is
|
||||||
|
// higher than that of the master, just to make the test harder.
|
||||||
|
|
||||||
|
index(slaveClient, "id", 551, "name", "name = " + 551);
|
||||||
|
slaveClient.commit(true, true);
|
||||||
|
index(slaveClient, "id", 552, "name", "name = " + 552);
|
||||||
|
slaveClient.commit(true, true);
|
||||||
|
index(slaveClient, "id", 553, "name", "name = " + 553);
|
||||||
|
slaveClient.commit(true, true);
|
||||||
|
index(slaveClient, "id", 554, "name", "name = " + 554);
|
||||||
|
slaveClient.commit(true, true);
|
||||||
|
index(slaveClient, "id", 555, "name", "name = " + 555);
|
||||||
|
slaveClient.commit(true, true);
|
||||||
|
|
||||||
|
|
||||||
|
//this doc is added to slave so it should show an item w/ that result
|
||||||
|
SolrDocumentList slaveQueryResult = null;
|
||||||
|
NamedList slaveQueryRsp;
|
||||||
|
slaveQueryRsp = rQuery(1, "id:555", slaveClient);
|
||||||
|
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
|
||||||
|
assertEquals(1, slaveQueryResult.getNumFound());
|
||||||
|
|
||||||
|
masterUrl = "http://localhost:" + masterJetty.getLocalPort() + "/solr/replication?command=enableReplication";
|
||||||
|
url = new URL(masterUrl);
|
||||||
|
stream = url.openStream();
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//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");
|
||||||
|
assertEquals(0, slaveQueryResult.getNumFound());
|
||||||
|
|
||||||
|
// make sure we replicated the correct index from the master
|
||||||
|
slaveQueryRsp = rQuery(nDocs, "*:*", slaveClient);
|
||||||
|
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
|
||||||
|
assertEquals(nDocs, slaveQueryResult.getNumFound());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexAndConfigReplication() throws Exception {
|
public void testIndexAndConfigReplication() throws Exception {
|
||||||
|
|
||||||
|
@ -411,65 +479,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReplicateAfterWrite2Slave() throws Exception {
|
|
||||||
//add 50 docs to master
|
|
||||||
int nDocs = 50;
|
|
||||||
for (int i = 0; i < nDocs; i++) {
|
|
||||||
index(masterClient, "id", i, "name", "name = " + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
String masterUrl = "http://localhost:" + masterJetty.getLocalPort() + "/solr/replication?command=disableReplication";
|
|
||||||
URL url = new URL(masterUrl);
|
|
||||||
InputStream stream = url.openStream();
|
|
||||||
try {
|
|
||||||
stream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
masterClient.commit();
|
|
||||||
|
|
||||||
NamedList masterQueryRsp = rQuery(50, "*:*", masterClient);
|
|
||||||
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
|
|
||||||
assertEquals(nDocs, masterQueryResult.getNumFound());
|
|
||||||
|
|
||||||
// Make sure that both the index version and index generation on the slave is
|
|
||||||
// higher than that of the master, just to make the test harder.
|
|
||||||
|
|
||||||
index(slaveClient, "id", 551, "name", "name = " + 551);
|
|
||||||
slaveClient.commit(true, true);
|
|
||||||
index(slaveClient, "id", 552, "name", "name = " + 552);
|
|
||||||
slaveClient.commit(true, true);
|
|
||||||
index(slaveClient, "id", 553, "name", "name = " + 553);
|
|
||||||
slaveClient.commit(true, true);
|
|
||||||
index(slaveClient, "id", 554, "name", "name = " + 554);
|
|
||||||
slaveClient.commit(true, true);
|
|
||||||
index(slaveClient, "id", 555, "name", "name = " + 555);
|
|
||||||
slaveClient.commit(true, true);
|
|
||||||
|
|
||||||
|
|
||||||
//this doc is added to slave so it should show an item w/ that result
|
|
||||||
SolrDocumentList slaveQueryResult = null;
|
|
||||||
NamedList slaveQueryRsp;
|
|
||||||
slaveQueryRsp = rQuery(1, "id:555", slaveClient);
|
|
||||||
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
|
|
||||||
assertEquals(1, slaveQueryResult.getNumFound());
|
|
||||||
|
|
||||||
masterUrl = "http://localhost:" + masterJetty.getLocalPort() + "/solr/replication?command=enableReplication";
|
|
||||||
url = new URL(masterUrl);
|
|
||||||
stream = url.openStream();
|
|
||||||
try {
|
|
||||||
stream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//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");
|
|
||||||
assertEquals(0, slaveQueryResult.getNumFound());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBackup() throws Exception {
|
public void testBackup() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue