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
This commit is contained in:
Sami Siren 2012-09-21 13:43:28 +00:00
parent 468a6650e7
commit b8f9525142
2 changed files with 23 additions and 14 deletions

View File

@ -27,7 +27,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.SolrTestCaseJ4;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -43,19 +42,22 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
public void testShareSchema() throws IOException, ParserConfigurationException, SAXException { public void testShareSchema() throws IOException, ParserConfigurationException, SAXException {
final File workDir = new File(TEMP_DIR, this.getClass().getName());
if (workDir.exists()) { final File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
FileUtils.deleteDirectory(workDir); + "_shareSchema");
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
} }
assertTrue("Failed to mkdirs workDir", workDir.mkdirs()); assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
String solrHome = SolrResourceLoader.locateSolrHome(); FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
File fconf = new File(solrHome, "solr.xml");
final CoreContainer cores = new CoreContainer(solrHome); File fconf = new File(solrHomeDirectory, "solr.xml");
final CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
System.setProperty("shareSchema", "true"); System.setProperty("shareSchema", "true");
cores.load(solrHome, fconf); cores.load(solrHomeDirectory.getAbsolutePath(), fconf);
try { try {
cores.setPersistent(false); cores.setPersistent(false);
assertTrue(cores.isShareSchema()); assertTrue(cores.isShareSchema());
@ -72,6 +74,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
core2.close(); core2.close();
} finally { } finally {
cores.shutdown(); cores.shutdown();
System.clearProperty("shareSchema");
} }
} }
@ -230,8 +233,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
//assert cero cores //assert cero cores
assertEquals("There should not be cores", 0, cores.getCores().size()); assertEquals("There should not be cores", 0, cores.getCores().size());
FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME(), "collection1"), solrHomeDirectory);
//add a new core //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); SolrCore newCore = cores.create(coreDescriptor);
cores.register(newCore, false); cores.register(newCore, false);

View File

@ -257,7 +257,12 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
System.setProperty("collection", "control_collection"); System.setProperty("collection", "control_collection");
String numShards = System.getProperty(ZkStateReader.NUM_SHARDS_PROP); String numShards = System.getProperty(ZkStateReader.NUM_SHARDS_PROP);
System.clearProperty(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"); "control_shard");
System.clearProperty("collection"); System.clearProperty("collection");
if(numShards != null) { if(numShards != null) {
@ -290,7 +295,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
if (sb.length() > 0) sb.append(','); if (sb.length() > 0) sb.append(',');
int cnt = this.jettyIntCntr.incrementAndGet(); int cnt = this.jettyIntCntr.incrementAndGet();
File jettyDir = new File(TEMP_DIR, File jettyDir = new File(TEMP_DIR,
"solrtest-" + "jetty" + cnt + "-" + System.currentTimeMillis()); getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis());
jettyDir.mkdirs(); jettyDir.mkdirs();
org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir); org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty"