From b8f9525142c4dd1b37ca81df4ed09a153fcdbf26 Mon Sep 17 00:00:00 2001 From: Sami Siren Date: Fri, 21 Sep 2012 13:43:28 +0000 Subject: [PATCH] do not write to test-files dir, use dirs that are less likely to collide for jettys git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1388492 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/solr/core/TestCoreContainer.java | 28 +++++++++++-------- .../cloud/AbstractFullDistribZkTestBase.java | 9 ++++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java index 0a59977ee23..da7843d4529 100644 --- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java +++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java @@ -27,7 +27,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathExpressionException; import org.apache.commons.io.FileUtils; -import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.util.IOUtils; import org.apache.solr.SolrTestCaseJ4; import org.junit.BeforeClass; @@ -43,19 +42,22 @@ public class TestCoreContainer extends SolrTestCaseJ4 { public void testShareSchema() throws IOException, ParserConfigurationException, SAXException { - final File workDir = new File(TEMP_DIR, this.getClass().getName()); - - if (workDir.exists()) { - FileUtils.deleteDirectory(workDir); - } - assertTrue("Failed to mkdirs workDir", workDir.mkdirs()); - String solrHome = SolrResourceLoader.locateSolrHome(); - File fconf = new File(solrHome, "solr.xml"); + final File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName() + + "_shareSchema"); - final CoreContainer cores = new CoreContainer(solrHome); + if (solrHomeDirectory.exists()) { + FileUtils.deleteDirectory(solrHomeDirectory); + } + assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs()); + + FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory); + + File fconf = new File(solrHomeDirectory, "solr.xml"); + + final CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath()); System.setProperty("shareSchema", "true"); - cores.load(solrHome, fconf); + cores.load(solrHomeDirectory.getAbsolutePath(), fconf); try { cores.setPersistent(false); assertTrue(cores.isShareSchema()); @@ -72,6 +74,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 { core2.close(); } finally { cores.shutdown(); + System.clearProperty("shareSchema"); } } @@ -230,8 +233,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 { //assert cero cores assertEquals("There should not be cores", 0, cores.getCores().size()); + FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME(), "collection1"), solrHomeDirectory); //add a new core - CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", SolrTestCaseJ4.TEST_HOME() + "/collection1"); + CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", solrHomeDirectory.getAbsolutePath()); SolrCore newCore = cores.create(coreDescriptor); cores.register(newCore, false); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index 6191349bfb9..82d25756cc0 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -257,7 +257,12 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes System.setProperty("collection", "control_collection"); String numShards = System.getProperty(ZkStateReader.NUM_SHARDS_PROP); System.clearProperty(ZkStateReader.NUM_SHARDS_PROP); - controlJetty = createJetty(new File(getSolrHome()), testDir + "/control/data", + + File controlJettyDir = new File(TEMP_DIR, + getClass().getName() + "-controljetty-" + System.currentTimeMillis()); + org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), controlJettyDir); + + controlJetty = createJetty(controlJettyDir, testDir + "/control/data", "control_shard"); System.clearProperty("collection"); if(numShards != null) { @@ -290,7 +295,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes if (sb.length() > 0) sb.append(','); int cnt = this.jettyIntCntr.incrementAndGet(); File jettyDir = new File(TEMP_DIR, - "solrtest-" + "jetty" + cnt + "-" + System.currentTimeMillis()); + getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis()); jettyDir.mkdirs(); org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir); JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty"