From 65d565b1887a215bad170887b5e3f68cb858dc3b Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 1 Jul 2013 21:33:19 +0000 Subject: [PATCH] tests: force FS in the test method rather than for all replication test methods git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1498704 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/handler/TestReplicationHandler.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java index 635902359da..388bbc8fc75 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -103,7 +103,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { super.setUp(); // System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory"); // For manual testing only - useFactory(null); // force an FS factory. currently MockDirectoryFactory causes SolrCore.initIndex to detect no index and create a new one. + // useFactory(null); // force an FS factory. master = new SolrInstance("master", null); master.setUp(); masterJetty = createJetty(master); @@ -344,14 +344,33 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { * Verify that things still work if an IW has not been opened (and hence the CommitPoints have not been communicated to the deletion policy) */ public void testNoWriter() throws Exception { + useFactory(null); // force a persistent directory + + // stop and start so they see the new directory setting + slaveJetty.stop(); + masterJetty.stop(); + slaveJetty.start(true); + masterJetty.start(true); + index(slaveClient, "id", "123456"); slaveClient.commit(); slaveJetty.stop(); - // System.err.println("############ starting jetty"); - slaveJetty = createJetty(slave); - // System.err.println("############ done starting jetty"); - slaveClient = createNewSolrServer(slaveJetty.getLocalPort()); - pullFromMasterToSlave(); + slaveJetty.start(true); + + // Currently we open a writer on-demand. This is to test that we are correctly testing + // the code path when SolrDeletionPolicy.getLatestCommit() returns null. + // When we are using an ephemeral directory, an IW will always be opened to create the index and hence + // getLatestCommit will always be non-null. + CoreContainer cores = ((SolrDispatchFilter) slaveJetty.getDispatchFilter().getFilter()).getCores(); + Collection theCores = cores.getCores(); + assertEquals(1, theCores.size()); + SolrCore core = (SolrCore)theCores.toArray()[0]; + assertNull( core.getDeletionPolicy().getLatestCommit() ); + + + pullFromMasterToSlave(); // this will cause SnapPuller to be invoked and we will test when SolrDeletionPolicy.getLatestCommit() returns null + + resetFactory(); } /**